Local Tile Server Setup Take 2

Created by: Lester Caine, Last modification: 12 Nov 2015 (20:39 GMT)

Information on configuring a suitable datasource can be found on OSM Replication of Data, but the base code framework and an empty database needs to exist first.

The server is running a text mode install of SUSE13.2 with PHP5.6.9 along with Firebird 2.5.4 but augmented by Postgres 9.3 to allow the extraction of the data using osm2pgsql program, but I'd prefer to be working from nginx rather than apache given the much faster performance when handling the rest of my php based web service.

All of the required packages other than the code distribution development files can be found in the openSUSE repository 'Geo' section.
The list of packages to install has not been noted, so I need to establish exactly which ones are bring used.

osmosis  0.44-2
osm2pgsql  0.89.0
mapnik  2.2.0-2
mapnik-devel  2.2.0-2
postgresql  9.2-4.1.2
postgresql-contrib  9.2-4.1.2
postgis2  2.1.5-1
git (See Code Management ... using Hg as the source code management platform)
python 2.7.8 normally already installed for mercurial/hg
subversion 1.8.13-2 Included in code management
proj 4.9.2
gdal  1.11.3

Checked via suse package management so no install scripts have been used.

zypper install osmosis osm2pgsql mapnik mapnik-devel postgresql postgresql-contrib postgis2 proj gdal 

Working in reverse order of the crib sheets used to set this up, which need combining into one crib sheet.

  1. Minutely_Mapnik Switch to switch2osm.org
  2. Osmosis Handle planet files
  3. PostGIS - Installation
  4. Osm2pgsql
  5. Mapnik - OpenSuseInstallation Think this is out of date now. Built in Geo: repository
  6. Build your own openstreetmap server lucid
  7. project-osrm.org

Need to sort out a clean directory structure for this, but the curent planning uses /srv/maps as the base for all the map based material.

Create database

You have to create a user in Postgresql that will be used to create all tables and data. Then some SQL scripts containing vital mapping-related instructions need to be executed. These instructions generate the user gisuser and the password "something". To change that, replace all occurrences of "gisuser" and "something", respectively.

su - postgres
postgres createuser --superuser gisuser 
createdb -E UTF8 -O gisuser gis
psql -d gis -c "ALTER USER gisuser WITH PASSWORD 'something';"

Activate PostGIS

You need to activate PostGIS on the newly created database. After the activation, the following command should list the tables geometry_columns and spatial_ref_sys:

psql --username=gisuser --dbname=gis --command="\d"

Currently stuck at this point as this gives an authentication error ... switched pg_.conf to 'md5' without any change. Yes I restarted postgres
but it does not stop the next stage running ...

psql -d gis -f /usr/share/postgresql93/contrib/postgis-2.1/postgis.sql
psql -d gis -f /usr/share/osm2pgsql/900913.sql
psql -d gis -c="ALTER TABLE geometry_columns OWNER TO gisuser; ALTER TABLE spatial_ref_sys OWNER TO gisuser;"

Load Database

cd /srv/maps/planet/
osm2pgsql --bbox -14.5,49,3,61 --slim great_britain.osm.pbf

The processing of the United Kingdom took just over 2 hours on the 8 core machine with 32Gb of RAM.

Update planet extract

See OSM Replication of Data for notes on configuring the cron update and setting up processing of that.

Building tile cache

Currently while I have a couple of style sheet frameworks downloaded neither is as yet producing usable tiles.

Mapnik style
mkdir /srv/maps/mapnik
cd /srv/maps/mapnik
git clone git://github.com/openstreetmap/mapnik-stylesheets.git
cd mapnik-stylesheets
./get-coastlines.sh ( had to strip bunzip2 check from script ... not actually used and SUSE does not support )
./generate_xml.py  --accept-none --dbname gis --symbols ./symbols/ --world_boundaries ./world_boundaries/
export MAPNIK_MAP_FILE="osm.xml" 
export MAPNIK_TILE_DIR="/srv/maps/osm/tiles"


Download from https://github.com/gravitystorm/openstreetmap-carto/archive/master.zip and extract to /srv/maps/openstreetmap-carto/. Run get-shapefiles.sh in that directory to build the rest of the infrastructure for the map theme.

Tile building as well as creating the OSRM routing data is on the todo list.