logo separator

[mkgmap-dev] SeaGenerator patch v1

From WanMil wmgcnfg at web.de on Fri Jan 11 18:14:54 GMT 2013

> Hi,
>
> the index for the precomp-sea method stores 131072 * 2 = 262.144 Strings
> with String.intern() in a HashMap (one instance for each job).

That's a bit over estimated because the Strings are interned. Therefore 
131072+<number of sea tiles>+2= ~143000 Strings are used (over all 
jobs). Of course the HashMap remains for each job with 131072 entries.

> Attached is a patch that changes the index to use a byte[512][256] array >
> 131072 bytes.
>
> It reduces run time and memory needs in mkgmap (when --precomp-sea is used)

Why does it reduce the run time? Did you measure it?
Can you please give numbers. How much memory is saved? I don't want to 
commit optimizations that change the readability of code without having 
a good reason.

>
> One problem: The unpatched version would allow to have different formats
> (*.o5m, *.osm.pbf, .osm.gz) in one sea directory.
> The patched version assumes that all files have the same prefix  and
> extension.
> So, if you want to update a precompiled sea tile you have to make sure that
> you keep the name and format.
> I hope this small limit is no problem?

That's ok. An error should be printed if that's not the case.

Please rework the patch a bit.
1. Instead of instantiating an Area object to get minLat etc. you can 
use the Utils.toMapUnit(double) method
2. Document what's in the byte array. Constants improve readability.
3. Maybe create an accessor method to the byte array so you avoid to 
blow up the other code with index calculations.
4. Remove unused variables
5. Instead of x and y use e.g. latIndex and lonIndex as variable names 
so that it is easy to read the code.

By the way: using the ThreadLocal requires loading the index in each 
thread which is not optimal. But at the time implementing it I didn't 
want to bother about synchronizing the load procedure. This might be a 
point where some run time can be saved.

WanMil


>
> Gerd
>
> seaGen_v1.patch
> <http://gis.19327.n5.nabble.com/file/n5743972/seaGen_v1.patch>
>





More information about the mkgmap-dev mailing list