Skip to content

Instantly share code, notes, and snippets.

@kieste
Last active Dec 11, 2015
Embed
What would you like to do?
Installing OSM Rendering Toolchain on Ubuntu 12.04 (13.01.2013)
Quelle: https://github.com/mapnik/mapnik/wiki/UbuntuInstallation
# be fully up to date before starting:
sudo apt-get update
sudo apt-get upgrade
apt-get install wget
# ensure add-apt-repository is installed:
sudo apt-get install -y python-software-properties
# Mapnik v2.1.0
sudo add-apt-repository ppa:mapnik/v2.1.0
sudo apt-get update
sudo apt-get install libmapnik mapnik-utils python-mapnik
# Font Pfad anlegen
mkdir -p /usr/lib/mapnik/fonts
ln -s /usr/share/fonts/truetype/unifont/*.ttf /usr/share/fonts/truetype/ttf-dejavu/*.ttf /usr/lib/mapnik/fonts/
# Postgres und Postgis:
# Quelle: http://wiki.openstreetmap.org/wiki/Mapnik/PostGIS
sudo apt-get install postgresql-9.1-postgis postgresql-contrib-9.1
sudo -u postgres -i -H
createuser -SdR gisuser
createdb -E UTF8 -O gisuser gis
psql -d gis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
# to populate the table spatial_ref_sys (mandatory for use with osm2pgsql):
psql -d gis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
psql gis -c "ALTER TABLE geometry_columns OWNER TO gisuser"
psql gis -c "ALTER TABLE spatial_ref_sys OWNER TO gisuser"
exit
# In Datei /etc/postgresql/9.1/main/pg_hba.conf
local all all trust
host all all 127.0.0.1/32 trust
# Postgres Config tunen:
mcedit /etc/postgresql/9.1/main/postgresql.conf
shared_buffers = 1024MB
maintenance_work_mem = 1024MB
work_mem = 1024MB
checkpoint_segments = 20
autovacuum = off
# sudo mcedit /etc/sysctl.conf
kernel.shmmax = 3758096384
# Neustart:
sudo reboot
# Compiling Osm2pgsql
# Quelle: http://wiki.openstreetmap.org/wiki/Osm2pgsql#From_source_.28generic.29
# need the following dependencies:
apt-get install build-essential libxml2-dev libgeos++-dev libpq-dev libbz2-dev proj libtool automake
apt-get install git-core
cd /data/src
git clone https://github.com/openstreetmap/osm2pgsql.git
cd osm2pgsql/
./autogen.sh
./configure
sed -i 's/-g -O2/-O2 -march=native -fomit-frame-pointer/' Makefile
make
make install
wget http://download.geofabrik.de/openstreetmap/europe/germany.osm.bz2
mkdir /data/raw_osm_data
cd /data/raw_osm_data
sudo -u postgres -i
osm2pgsql --slim -d gis -C 20000 --number-processes 3 /data/raw_osm_data/germany.osm
# Tirex:
# Quelle: http://wiki.openstreetmap.org/wiki/DE:HowTo_Mapnik_%26_Tirex
apt-get install subversion
svn co http://svn.openstreetmap.org/applications/rendering/mapnik/@r29194 osm-mapnik2
sudo mv osm-mapnik2 /usr/share/
cd /usr/share/osm-mapnik2
cp inc/datasource-settings.xml.inc.template inc/datasource-settings.xml.inc
cp inc/fontset-settings.xml.inc.template inc/fontset-settings.xml.inc
cp inc/settings.xml.inc.template inc/settings.xml.inc
# edit inc/datasource-settings.xml.inc
<Parameter name="type">postgis</Parameter>
<Parameter name="password"></Parameter>
<Parameter name="host">/var/run/postgresql/</Parameter>
<Parameter name="port"></Parameter>
<Parameter name="user">gisuser</Parameter>
<Parameter name="dbname">gis</Parameter>
<Parameter name="estimate_extent">false</Parameter>
<Parameter name="extent">-20037508,-19929239,20037508,19929239</Parameter>
# edit inc/settings.xml.inc
<!ENTITY symbols "/usr/share/osm-mapnik2/symbols">
<!ENTITY osm2pgsql_projection "&srs900913;">
<!ENTITY dwithin_900913 "0.1">
<!ENTITY dwithin_4326 "0.00001">
<!ENTITY dwithin_node_way "&dwithin_900913;">
<!ENTITY world_boundaries "/usr/share/osm-mapnik2/world_boundaries">
<!ENTITY prefix "planet_osm">
# Hole World Boundaries:
apt-get install unzip
cd /usr/share/osm-mapnik
./get-coastlines.sh
# Das eigentliche Tirex:
apt-get install debhelper devscripts libipc-sharelite-perl libjson-perl libgd-gd2-perl libwww-perl libboost-program-options-dev
apt-get install libmapnik-dev
cd /data/src
svn co http://svn.openstreetmap.org/applications/utils/tirex/
cd tirex
# Patch einspielen:
wget https://gist.github.com/raw/3899892/05e41c562a88fbbe7dd4c15d37abaaa3fffc9c22/tirex.diff
patch -p0 < tirex.diff
make deb
make deb-clean
cd ..
dpkg -i tirex-backend-mapnik_0.4.1*.deb tirex-core_0.4.1*.deb tirex-example-map_0.4.1*.deb
# Tirex Config bearbeiten
# mcedit /etc/tirex/renderer/mapnik/osm.conf
name=osm
tiledir=/var/lib/tirex/tiles/osm
maxz=18
mapfile=/usr/share/osm-mapnik2/osm.xml
# Tiles Cache Verzeichnis auf /data anlegen:
mkdir /data/tirex_tiles
mkdir /data/tirex_tiles/osm
chown tirex:tirex /data/tirex_tiles/osm
ln -s /data/tirex_tiles/osm /var/lib/tirex/tiles/osm
# ??? chown tirex:tirex /var/lib/tirex/tiles/osm
# Tirex neu starten
/etc/init.d/tirex-master restart
/etc/init.d/tirex-backend-manager restart
tirex-status --once --extended
# Keep in mind:
If you want to add a new key but avoid re-importing the full database,
you can add the key to osm2pgsql's style file, somehow generate an .osm
file that contains only the objects that have this tag, wrap this .osm
file into a "<osmChange><modify>...</modify></osmChange>" instead of
"<osm>...</osm>" and throw it at osm2pgsql in append mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment