source: subversion/utils/mapnik/install.txt @ 2026

Last change on this file since 2026 was 2018, checked in by joerg, 13 years ago

mapnik: improve and resort install.txt to make installing mapnik easier

M install.txt

File size: 5.2 KB
Line 
1# This is a start for an (almost) cut'n past installation description for mapnik-osm-renderer
2
3# ------ Install some stuff
4  sudo apt-get install \
5                build-essential libfreetype6-dev libltdl3-dev \
6                libpng12-dev  libtiff4-dev libboost-thread-dev\
7                libboost-filesystem-dev \
8                libboost-serialization-dev libboost-regex-dev\
9                libboost-python-dev  proj python-imaging scons \
10                libboost-program-options-dev postgresql-doc-8.1 \
11                postgresql-8.1 postgresql-8.1-plruby \
12                postgresql-client-8.1 postgresql-contrib-8.1\
13                postgresql-plperl-8.1 postgresql-plpython-8.1 \
14                postgresql-server-dev-8.1 postgresql-8.1-postgis \
15                libboost-python-dev python2.4-dev \
16                libwww-perl libxml-parser-perl libfile-slurp-perl \
17                libtimedate-perl libdate-manip-perl imagemagick
18
19# ---- get software from OSM-SVN and compile
20  cd
21  svn co http://svn.openstreetmap.org/
22
23  # compile UTF8sanitize
24  ( cd ~/svn.openstreetmap.org/utils/planet.osm/C; make)
25  # compile osmsql
26  (cd ~/svn.openstreetmap.org/utils/osm2pgsql/; make)
27
28# ---- Install mapnik
29  cd ~/svn.openstreetmap.org/utils/mapnik.berlios
30  python scons/scons.py
31  sudo python scons/scons.py install
32  sudo python scons/scons.py PGSQL_INCLUDES=/usr/include/postgresql \
33       PGSQL_LIBS=/usr/lib/postgresql/8.1/lib install
34
35
36# ----------- Create Database and Grant rights
37
38  export user_name=`whoami`
39  # or with a different user. 'steve' is the example user here ;-)
40  export user_name="steve"
41  sudo -u postgres createdb -Upostgres  -EUTF8 mapnik
42  sudo -u postgres createuser -Upostgres -S -D -R $user_name
43  echo "GRANT ALL ON SCHEMA PUBLIC TO $user_name;" | sudo -u postgres psql -Upostgres mapnik
44  sudo -u postgres createlang plpgsql mapnik
45  sudo -u postgres psql -Upostgres mapnik </usr/share/postgresql-8.1-postgis/lwpostgis.sql \
46     2>&1 | grep -v -e 'FEHLER:  aktuelle Transaktion' \
47     -e 'ERROR:  current transaction is aborted' \
48     -e 'CREATE FUNCTION' -e OPERATOR
49
50
51  echo "GRANT ALL on geometry_columns TO $user_name;" | sudo -u postgres psql -Upostgres mapnik
52  echo "GRANT ALL on spatial_ref_sys TO $user_name;" | sudo -u postgres psql -Upostgres mapnik
53  echo "DROP TABLE planet_osm ;"| sudo -u postgres psql -Upostgres mapnik
54  echo "CREATE TABLE planet_osm (   osm_type    char(1),
55       osm_id      bigint,   name        text,   place       text,   landuse     text,
56       leisure     text,   waterway    text,   highway     text,   amenity     text,
57       tourism     text,   learning    text);" | sudo -u postgres psql -Upostgres mapnik
58  echo "SELECT AddGeometryColumn('planet_osm', 'way', 4326, 'GEOMETRY', 2);" | sudo -u postgres psql -Upostgres mapnik
59  echo "ALTER TABLE planet_osm ADD CONSTRAINT pk__planet_osm PRIMARY KEY (osm_type, osm_id);" | sudo -u postgres psql -Upostgres mapnik
60  echo "CREATE INDEX planet_spatial_idx ON planet_osm USING gist (way GIST_GEOMETRY_OPS);" | sudo -u postgres psql -Upostgres mapnik
61  echo "GRANT ALL ON SCHEMA PUBLIC TO $user_name;" | sudo -u postgres psql -Upostgres mapnik
62  echo "GRANT ALL ON TABLE planet_osm TO $user_name;" | sudo -u postgres psql -Upostgres mapnik
63
64 
65# ---- Install and run planet-mirror --> planet.sql
66  # Get newest planet.osm. This will takes some time
67  ~/svn.openstreetmap.org/utils/planet-mirror/planet-mirror.pl -v
68  bunzip2 --keep `~/svn.openstreetmap.org/utils/planet-mirror/planet-mirror.pl -print-filename`
69  export planet_name=`~/svn.openstreetmap.org/utils/planet-mirror/planet-mirror.pl -print-filename`
70  echo "export planet_name='$planet_name'"
71  # convert osm --> sql. takes about 10 minutes on a 3GHz (2GB-Ram) Machine
72  date; time ~/svn.openstreetmap.org/utils/osm2pgsql/osm2pgsql $planet_name > $planet_name.sql
73
74  # Now we need the result from the osm2pgsql command
75  export planet_name=`~/svn.openstreetmap.org/utils/planet-mirror/planet-mirror.pl -print-filename`
76  date;time sudo -u postgres psql -Upostgres mapnik <${planet_name}.sql >~/insert.log
77  # takes about 10 minutes on a 3GHz  (2GB-Ram) machine
78
79  # Test if you can read the Database
80  echo "SELECT * from planet_osm LIMIT 5;" |  psql  mapnik -h /var/run/postgresql -p 5433
81
82
83# From here on the cut'n paste part stops
84
85vi ~/svn.openstreetmap.org/utils/mapnik/generate_tiles.py
86vi ~/svn.openstreetmap.org/utils/mapnik/osm.xml
87and change the path to your installation:
88 /home/mapnik/
89
90vi ~/svn.openstreetmap.org/utils/mapnik/osm.xml
91   replace with your username:
92      <Parameter name="user">steve</Parameter>
93   replace /home/mapnik/ with your home-directory
94
95   set the host connection to your local machine:
96      <Parameter name="host">/var/run/postgresql</Parameter>
97
98   remove this for local connections:
99#      <Parameter name="port">5432</Parameter>
100
101
102vi ~/svn.openstreetmap.org/utils/mapnik/generate_tiles.py
103    replace with your area
104    bbox = (-2, 50.0,1.0,52.0)
105
106
107# ---------- And now, we start the rendering
108export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
109python ~/svn.openstreetmap.org/utils/mapnik/generate_tiles.py
110
111# ---------- Upload the tiles-output to dev.openstreetmap.org or  mail a tar file to steve
112rsync --size-only -r -e ssh ~/osm/tiles dev.openstreetmap.org:
Note: See TracBrowser for help on using the repository browser.