It’s taken me quite a bit of time but I’ve finally got an open streetmap tileserver working on my laptop. The main issue appears to have been that I was following the manual Ubuntu set-up instructions rather than building a tile server from packages. Which isn’t to say that using packages was plain sailing. This post will outline some of the problems I ran into and how I solved them.
(Bear in mind that I’d already tried to install OSM using the manual method on the laptop and fragments of these installs were still on the system. Installation might be a lot easier on a clean OS. However, it’s worth documenting the issues in case anyone runs into the same issues and is googling for them)
The main point of this post is to say that I have managed the open streetmap set-up and now have a map of Brighton working on my laptop:
The installed slippymap.html page is great as the radio buttons on the top right allow you to compare a remote instance against the local one – useful for finding out where you are when things aren’t working, or you only have a small area set up. Now I’ve fixed this, I can get on with actually using the server.
The main problems I had to solve with the packaging method were:
Mod-tile dpkg installtion hangs
The command to install mod-tile hung. Googling around, I found a patch for this – a line was missing from the libapache2-mod-tile.postinst script. Editing the script and re-running the installation fixed this issue.
osm2psql didn’t work
When I ran the command osm2pgsql I received an error:
Osm2pgsql failed due to ERROR: SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, 'POINT', 2 ) failed: ERROR: AddGeometryColumns() - invalid SRID
This seemed to have been caused by not having set up data in the spatial_ref_sys table. To check this see if there are any lines from the SQL query
SELECT * FROM spatial_ref_sys;
If not, then this is easily fixed:
psql --username=postgres --dbname=gis --file=/usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
After re-running this script, the osm2psql script worked. Note that this may have been a problem due to me incorrectly removing previous installation attempts.
Tiles not rendering
This is more of a generic issue. Basically, when the slippymap page is working, but the images are not being generated, a lot of missing images will be displayed:
You can open the blank tiles in a new page and see there where they are being generated from. Some of the help online suggested that it could be down to the slippymap.html pointing to the wrong OSM server (it defaults to localhost). In my case it was a permissions issue:
Database permissions not set correctly
There seems to be a minor issue with the installation scripts. This was fixed by explicitly setting up the postgis user.
I was able to diagnose this issue by running renderd as a foreground process (ie renderd -f) and seeing permissions errors such as the following:
renderd: An error occurred while loading the map layer 'default': : FATAL: role "www-data" does not exist (encountered during parsing of layer 'landcover' in map '/etc/mapnik-osm-data/osm.xml') renderd: An error occurred while loading the map layer 'default': : FATAL: role "www-data" does not exist (encountered during parsing of layer 'landcover' in map '/etc/mapnik-osm-data/osm.xml')