logo separator

Tile clipping

01
Jul

A new feature has been added to mkgmap to clip all features exactly to a bounding box. This allows you to create tiles that meet exactly without overlapping. The general idea is that you start with an area that is slightly larger and then chop it down with in mkgmap. It will work even if a line crosses the area without any nodes being inside. The example uses osmosis, but any software that adds the bound element to the osm file will work and I will probably add an option to specify the bounding box manually later as well.

This is quick example that I made to try it out. Normally you would probably have larger tiles. First I ran osmosis on a uk osm file to create two small tiles. Two bounding boxes were created that shared a vertical side at -0.24 degrees longitude.

osmosis --rx uk-080623.osm.gz enableDateParsing=no \
    --tee 2 outPipe.0=a outPipe.1=b \
    --bb inPipe.0=a completeWays=yes top=51.65 bottom=51.55 left=-0.34 right=-0.24 \
    --bb inPipe.0=b completeWays=yes top=51.65 bottom=51.55 left=-0.24 right=-0.14 \
    --wx uk-test-1.osm.gz \
    --wx uk-test-2.osm.gz 

The completeWays argument makes osmosis include the whole way when any part of it is inside the bounding box. This is essential otherwise there will be gaps between the tiles. Thats all there is to it really. You can now run mkgmap on those tiles normally.

A picture probably says it better than words. Here you can see the clipping in action in QLandkarte displaying one of the tiles produced. This screenshot was taken before points were excluded from the bounding box, which is why you can see a few stray ones outside the box.

clipping example

Here is what the same data file would look like before clipping.

example without clipping

Posted by steve on 1 Jul 2008

Latest commits

  • mkgmap-r4923 failed-render.patch:.
    08 jan 2025
  • mkgmap-r4922 improve AngleChecker to fix wrong or missing routing hints where roads are spltting or crossing at sharp angles..
    31 aug 2024
  • mkgmap-r4921 fix split() so that there are no gaps between the 4 children.
    10 jun 2024
  • mkgmap-r4920 update file sizes in unit tests, no functional change.
    10 jun 2024
  • splitter-r654 - add note that splitter doesn't handle holes in *.poly files.
    05 apr 2024
See more...