logo separator

A tile splitter

16
Jan

Increasingly, as OSM gets bigger and bigger, people are having to face the problem that a map has to be split into tiles. There are various approaches that can be used, notably osmcut, and they work well enough at producing a map set that works. However to produce the best map additional features are desirable.

I not really interested in getting into the realm of splitting up xml files, but given its increasing importance I wrote a utility to split a large OSM file up into tiles in a way that is suitable for creating Garmin maps. I'm really hoping that others will look at this and do something better.

First of all, lets look at the features that I think are essential when splitting into tiles.

  • Adapts the size of each area based on the amount of detail present. There is a maximum size that each .img file can be. If you divide into equal sized pieces then you have to choose that size based on the most densely populated part of the map, leading to many small tiles. By having variable sized tiles, you can cover a whole country with a small number of tiles without hitting the dreaded 'Map too big' message.
  • Breaks maps on exact low zoom boundaries. Latitude and longitude values have to be rounded to particular integral amounts. At high zoom levels the resolution is a matter of centimeters on the ground. At low zooms however the possible divisions are a considerable distance apart. The tile boundaries are recorded at a low zoom in the overview map and so unless the positions are exact at the zoom level on the map, they will be either overlap or have gaps when the boundary is rounded to the nearest unit.
  • Features are cut exactly on the boundary. The resulting tiles do not overlap, nor do they have gaps between them. A road that crosses from one tile to another will be cut exactly on the boundary, and one part will be in the first tile and the other part in the second. Polygons are are also cut into two (or more) polygons, each sharing an edge at the tile boundary.
  • A line that crosses a tile corner, but does not actually have a point within the tile will still be included.

Although not essential, this splitter also has the following features:

  • The calculated areas can be saved and re-used in another run. This is so you can produce an updated map that has the same tile boundaries.
  • A template arguments file is produced that can be given to mkgmap with the -c argument to prepare the maps. It can be edited to describe the areas more accurately (for example the town or area the individual map tile covers).
  • Can set the maximum number of nodes that are contained in each tile.

To achieve some of these points, the splitter and mkgmap work together. The splitter calculates the exact file boundaries and places a <bounds> element in the .osm file with these exact coordinates. The splitter however extracts a somewhat larger, oversized, area into each .osm file and leaves mkgmap to cut the features exactly on the boundary. This overlap must be large enough so that there are nodes outside the boundary for every feature that crosses more than one tile. The default oversize amount works fine in towns, it may need to be increased in areas with widely spaced nodes.

Other desirable features that you might want in a tile splitter, that are not catered for with this one.

  • Ability to adjust the areas to match geographical areas or counties better. With the automatic way of splitting areas up, they may be hard to describe as they can cut across cities or countries in ways that are inconvenient to describe.
  • Even an automatic way of determining the areas might be better by detecting highly feature rich parts of the map and using them as the centers of areas about which the tiles are grown around. Or alternatively explicitly using regional capitals to base the tiles around.
  • Speed. This splitter is quite slow. It takes me 30 minutes to split the whole of Europe as defined by the Cloudmade extract, whereas it only takes 10 minutes to compile the generated files with mkgmap.
  • A more even split. With this splitter tiles often have many fewer than the maximum number of nodes in a tile.

For details of the splitter see the tile splitter page.

Posted by steve on 16 Jan 2009

Latest commits

  • splitter-r654 - add note that splitter doesn't handle holes in *.poly files.
    05 apr 2024
  • mkgmap-r4919 Avoid possible integer overflow in blocksize calculation when gmapsupp contains large number of tiles.
    04 apr 2024
  • mkgmap-r4918 add surface=chipseal to group of surfaces which means paved.
    06 mar 2024
  • mkgmap-r4917 fix typos in documentation: $LONG_DATE$ -> $LONGDATE$, $SHORT_DATE$ -> $SHORTDATE$.
    18 feb 2024
  • mkgmap-r4916 sortResource_v3.patch (with updated date in comment) by Ticker Berkin.
    13 oct 2023
See more...