I’ve grown quite fond of the OpenStreetMap project, especially the self-hosting solution that comes with it. Of course, I would need an entire server farm to come even close the what Google Maps is capable of, but with the use of the imposm3 tool, well, one can get very interesting results!
I will be using imposm3 for the imports and updates, mapnik for the rendering engine and mod_tile to generate and serve files over the almighty intrawebz.
Why not osm2pgsql ?
If you’ve ever tried importing an entire country with osm2pgsql, you’ll know how much of a pain that is. It took me about 18 hours to import France, and don’t even get me started on diff imports or later country imports.
If I want to have a somewhat sexy self-hosted mapping solution, at least let me have daily diffs and decent performance from the ground up!
That’s where imposm rocked my world! It reduced importing time to a mere 2.5 hours, and I found the tables to be most convenient: some tables are “generalized” to account for various zoom levels, meaning it won’t have to process as much data when only low detail is required. Also, it’s way easier to figure out where all the objects are: roads/paths/tracks/highways are in osm_roads, buildings are in osm_buildings, areas are in osm_areas, etc.
Why can’t I just use that with mapnik then ?
Well, you can, but the generated osm.xml file only works with osm2pgsql imports. That’s when I figured out I needed to understand how this file works, and build my own for imposm3.
Installink mapnik (with libxml2)
Next, you’ll need to create /etc/renderd.conf:
Then, put this in your Apache vhost: