What a drama! The article at switch2osm.org could do with some updating. Anyway, to fix the above errors:
Go to ~/src/mapnik-style
and run
python generate_xml.py --dbname gis --world_boundaries "/usr/local/share/world_boundaries" --accept-none
This will reset your mapnik style configuration and fix those %layers
errors.
NOTE: Your world_boundaries
folder location might be different to mine. Find yours by typing find /usr -type d -name "*world_boundaries*" -print
Next, you may have errors like An error occurred while loading the map layer 'default': Could not create datasource for type: 'shape'
. This is because renderd has the wrong plugin directory. To find yours, type find /usr -type d -name "*mapnik*" -print
you'll get something like one of the following (and maybe a few others we don't care about):
- /usr/lib/mapnik
- /usr/local/lib/mapnik
- /usr/lib64/mapnik
Go to the folder you found and check that it has the input
dir. Mine has nothing else in it. This is your renderd mapnik plugin directory. Edit your /usr/local/etc/renderd.conf
file to change the plugin directory to this location.
For reference, my final renderd.conf
file contained:
[renderd]
socketname=/var/run/renderd/renderd.sock
num_threads=4
tile_dir=/var/lib/mod_tile
stats_file=/var/run/renderd/renderd.stats
[mapnik]
plugins_dir=/usr/lib/mapnik/input
font_dir=/usr/share/fonts/truetype/ttf-dejavu
font_dir_recurse=1
[default]
URI=/osm_tiles/
TILEDIR=/var/lib/mod_tile
XML=/home/julian/src/mapnik-style/osm.xml
HOST=localhost
TILESIZE=256
I deleted all the commented lines in renderd.conf
because they didn't seem useful and were creating the syntax errors at the top of the renderd output.
Also, my ~/src/mapnik-style/inc/datasource-settings.xml.inc
file contained:
<Parameter name="type">postgis</Parameter>
<!-- <Parameter name="password"></Parameter> -->
<!-- <Parameter name="host"></Parameter> -->
<!-- <Parameter name="port"></Parameter> -->
<!-- <Parameter name="user"></Parameter> -->
<Parameter name="dbname">gis</Parameter>
<!-- this should be 'false' if you are manually providing the 'extent' -->
<Parameter name="estimate_extent">false</Parameter>
<!-- manually provided extent in epsg 900913 for whole globe -->
<!-- providing this speeds up Mapnik database queries -->
<Parameter name="extent">-20037508,-19929239,20037508,19929239</Parameter>
I think that's everything you need to get rid of these errors. If not, please comment and I'll do my best to update this answer.