-
Notifications
You must be signed in to change notification settings - Fork 268
Description
A few possibilities and thoughts:
Don't add ways to waystore unless they're needed by relations
See #292.
Lazy geometry assembly
At present we create our geometries whenever our Lua process asks for an object to be written. This is in linestringCached, polygonCached and multiPolygonCached in osm_lua_processing.cpp.
We could consider creating them lazily, i.e. only when writing each tile. The advantage of this is that we could purge the geometries when memory is getting low; they could subsequently be recreated next time we need them.
One challenge would be calculating the bbox if we haven't generated the geometry yet. A naive approach would simply take the min/max of the node coordinates - not sure whether this would suffice in the case of large geometries.
(This would rule out the approach in #292, because we'd need the waystore to stick around so that we could generate the geometries on demand.)
Use rtree for OutputObjects
Rather than adding each OutputObject to a list for each z14 tile, we could store an rtree of OutputObjects' bounding boxes, and then query the rtree when writing each tile. (This may need some thought for large, irregularly shaped objects. Performance might be an issue too.)
Support osmium add-locations-to-ways
This tool pre-processes the .pbf to add node lon/lat to the ways themselves. As a result, you don't need to read them into a node store. I've added support for this to my OSRM fork and it's fairly straightforward. (Explanation, docs.)
Optimise bitpacking in OutputObject
This isn't too efficient at present (8,8,8,1,4). We could reduce geomType to 2 bits and maybe z_order to 6. Not sure how much of a difference this would make - possibly none if the following variables are aligned to 4-byte boundaries, for example.
Support a "split layer" or "split region" approach
People have reported success splitting the planet into parts, running tilemaker over each one, and merging the resulting mbtiles. Alternatively, filter the planet by thematic layer, run tilemaker and merge. We could provide tooling to support this - it doesn't have to be in the tilemaker executable, it could be a bash/Ruby/Lua/whatever script that invokes tilemaker, osmium etc. as required.
Look at shapefile reading
A good starting point might be looking at the result of reading in shapefiles - it looks to me as if we're using many GB to read the coastlines for the whole world, when the shapefile itself is only around 1GB total.