TopOSM install guide

From Teknologisk videncenter
Jump to: navigation, search

Install dependencies

aptitude install apache2 python-mapnik mapnik-utils gdal-bin gdal-contrib python-gdal libgdal-dev proj libproj-dev python-pyproj python-numpy imagemagick gcc g++ optipng subversion postgresql postgresql-contrib postgresql-server-dev-8.4 postgis wget libxml2-dev python-libxml2 libgeos-dev libbz2-dev make htop python-cairo python-cairo-dev osm2pgsql unzip python-pypdf libboost-all-dev libicu-dev libpng-dev libjpeg-dev libtiff-dev libz-dev libfreetype6-dev libxml2-dev libproj-dev libcairo-dev libcairomm-1.0-dev python-cairo-dev libpq-dev libgdal-dev libsqlite3-dev libcurl4-gnutls-dev libsigc++-dev libsigc++-2.0-dev ttf-sil-gentium ttf-mscorefonts-installer ttf-adf-accanthis ttf-adf-baskervald ttf-adf-berenis ttf-adf-gillius ttf-adf-ikarius ttf-adf-irianis ttf-adf-libris ttf-adf-mekanus ttf-adf-oldania ttf-adf-romande ttf-adf-switzera ttf-adf-tribun ttf-adf-universalis ttf-adf-verana git

Ubuntu 12.04

PostgreSQL installation

Install and initialize postgre on ubuntu 12.04

apt-get install postgresql-9.1-postgis postgresql-contrib-9.1
su postgres
createuser -SdR gisuser
createdb -E UTF8 -O gisuser gis
createlang plpgsql 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

Allow gisuser to do easy login

gedit /etc/postgresql/9.1/main/pg_hba.conf

Change peer and md5 on the last lines to trust


# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5

reload the service with service portgresql reload

test the connection with the user we just created:

root@toposm:/var/www# psql gis gisuser
psql (9.1.5)
Type "help" for help.

gis=> \d
               List of relations
 Schema |       Name        | Type  |  Owner
--------+-------------------+-------+----------
 public | geography_columns | view  | postgres
 public | geometry_columns  | table | gisuser
 public | spatial_ref_sys   | table | gisuser
(3 rows)

gis=>

Ubuntu 11.04

Install and initialize postgre on ubuntu 11.04

aptitude install postgresql-8.4-postgis postgresql-contrib-8.4
su postgres
createuser -SdR gisuser
createdb -E UTF8 -O gisuser gis
createlang plpgsql gis
psql -d gis -f /usr/share/postgresql/8.4/contrib/_int.sql  #could cause "Please use a database without intarray" error on newer osm2pgsql
psql -d gis -f /usr/share/postgresql/8.4/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/8.4/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

Allow gisuser to do easy login

nano /etc/postgresql/8.4/main/pg_hba.conf

Change ident and md5 on the last lines to trust


# "local" is for Unix domain socket connections only
local   all             all                                     ident
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5

reload the service with service postgresql reload

test the connection with the user we just created:

root@toposm:~# psql gis gisuser
psql (8.4.13)
Type "help" for help.

gis=> \d
               List of relations
 Schema |       Name        | Type  |  Owner
--------+-------------------+-------+----------
 public | geography_columns | view  | postgres
 public | geometry_columns  | table | gisuser
 public | spatial_ref_sys   | table | gisuser
(3 rows)

Build local patched Mapnik

Der skal installeres boosts i en nyere version først >= 1.47

cd /tmp
wget -c 'http://sourceforge.net/projects/boost/files/boost/1.50.0/boost_1_50_0.tar.bz2/download'
tar xf download
cd boost_1_50_0
./bootstrap.sh
./b2 install
BOOST_INCLUDES=/tmp/boostinst/boost_1_51_0
BOOST_LIBS=/tmp/boostinst/boost_1_51_0/stage/lib
git clone https://github.com/mapnik/mapnik.git
git clone https://github.com/Ahlzen/TopOSM
cd mapnik
patch -p0 < <toposm-dir>/mapnik2_erase_patch.diff
python scons/scons.py configure \
    INPUT_PLUGINS=raster,osm,gdal,shape,postgis,ogr \
    PREFIX=$HOME PYTHON_PREFIX=$HOME
python scons/scons.py
python scons/scons.py install

Links