-
Notifications
You must be signed in to change notification settings - Fork 0
/
INSTALL
307 lines (208 loc) · 9.73 KB
/
INSTALL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
OCitySMap installation instructions
===================================
These instructions refer to software dependencies by using
Debian/Ubuntu package names. Minor adaptations might be needed for
other distributions or for the precise Debian or Ubuntu release you
are using (here respectively Lenny and Intrepid or Jaunty).
1. Installation of PostgreSQL and PostGIS
sudo aptitude install postgresql-8.3-postgis postgresql-contrib-8.3
2. Creation of a new PostgreSQL user
sudo -u postgres createuser -P -S -D -R maposmatic
Enter the password twice (we use later 'ereiamjh' as example
password).
3. Creation of the database
sudo -u postgres createdb -E UTF8 -O maposmatic maposmatic
(see http://wiki.openstreetmap.org/wiki/Mapnik/PostGIS)
You can now try to connect to the database, using:
psql -h localhost -U maposmatic maposmatic
If it doesn't work, fix your configuration.
4. Enable PostGIS on the database
PostGIS is in fact a set of functions and datatypes for
PostgreSQL, and every PostgreSQL database needing these features
must be initialized as follows. We do this initialization of the
database with superuser privileges, and then later fix the table
owners so that our normal user can use the database.
a. Enable the plpgsql language on the maposmatic database
sudo -u postgres createlang plpgsql maposmatic
b. Add the low-level PostGIS infrastructure
sudo -u postgres \
psql \
-f /usr/share/postgresql-8.3-postgis/lwpostgis.sql \
-d maposmatic
c. Add the list of spatial referential systems
sudo -u postgres \
psql \
-f /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql \
-d maposmatic
d. Add the intarray extension for diff files support (osc)
sudo -u postgres \
psql \
-f /usr/share/postgresql/8.3/contrib/_int.sql \
-d maposmatic
e. Change the owner of the new tables to maposmatic
echo "ALTER TABLE geometry_columns OWNER TO maposmatic;
ALTER TABLE spatial_ref_sys OWNER TO maposmatic;" | \
sudo -u postgres psql -d maposmatic
5. Installation of osm2pgsql
osm2pgsql is the tool that takes OSM data as input, and creates a
PostGIS database from it. At the time of the writing of this
document, the osm2pgsql packaged in Debian/Ubuntu is not recent
enough, so we grab a fresh version from SVN (we used revision
17318).
a. If needed, install SVN
sudo aptitude install subversion
b. Grab osm2pgsql code
svn co http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/
c. Install the build dependencies
sudo aptitude install build-essential libxml2-dev libgeos-dev \
libpq-dev libbz2-dev proj libbz2-dev
d. Compile
cd osm2pgsql
make
e. Install
Just copy the osm2pgsql binary somewhere in your PATH or link to
it like:
ln -s /path/to/osm2pgsql/osm2pgsql /usr/local/bin/osm2pgsql
6. Import the Google spatial referential system
The osm2pgsql tool creates data in the PostGIS database relative
to the 900913 (Google in leet language) spatial referential
system. As this system is not included in the default PostGIS
installation, we must add it manually. It is available in
osm2pgsql source code.
psql -h localhost \
-U maposmatic \
-f /path/to/osm2pgsql/900913.sql \
-d maposmatic
7. Download the OSM data
We give the example for France.
wget http://download.geofabrik.de/osm/europe/france.osm.bz2
8. Import the OSM data
osm2pgsql -S '/path/to/osm2pgsql/default.style' \
-s -c -d maposmatic -m -U maposmatic -W \
-H localhost france.osm.bz2
If you have a lot of RAM, remove '-s', it will make the import
faster. If you miss RAM (and have a lot of time available) you can
also use the '-C' option together with '-s'. (See osm2pgsql -h).
9. Install Mapnik
We used Mapnik 0.6.1, which was not yet available in stable
Debian/Ubuntu at the time we set up MapOSMatic, so we compiled it
from source.
a. Install the dependencies
sudo aptitude install \
libboost-dev libicu-dev libstdc++6-dev python-dev \
libfreetype6-dev libjpeg62-dev libltdl3-dev libpng12-dev \
libtiff4-dev libtiffxx0c2 python-imaging proj libcairo2-dev \
python-cairo-dev libcairomm-1.0-dev libpixman-1-dev \
libpthread-stubs0-dev ttf-dejavu ttf-dejavu-core \
ttf-dejavu-extra ttf-unifont libgdal-dev python-gdal \
postgresql-server-dev-8.3 postgresql-contrib-8.3 libxslt1-dev \
libxml2-dev
b. Download Mapnik
wget http://download.berlios.de/mapnik/mapnik-0.6.1.tar.bz2
c. Patch Mapnik
In order to make Mapnik search recursively for fonts in the
SYSTEM_FONTS directory (see below), we had to patch Mapnik. Note
that this is because we still use Mapnik 0.6.1. Later versions of
Mapnik already search recursively for fonts by default. The patch
to apply follows:
===============================================================================
diff -ru mapnik-0.6.1.orig/bindings/python/mapnik/__init__.py mapnik-0.6.1/bindings/python/mapnik/__init__.py
--- mapnik-0.6.1.orig/bindings/python/mapnik/__init__.py 2009-07-14 11:09:16.000000000 +0200
+++ mapnik-0.6.1/bindings/python/mapnik/__init__.py 2010-03-20 15:04:27.000000000 +0100
@@ -41,6 +41,8 @@
"""
+import os
+
from sys import getdlopenflags,setdlopenflags
try:
from dl import RTLD_NOW, RTLD_GLOBAL
@@ -377,17 +379,18 @@
major_version = version / 100000
return '%s.%s.%s' % ( major_version, minor_version,patch_level)
+def register_fonts(path=fontscollectionpath):
+ """Recursively register fonts using path argument as base directory"""
+ for dirpath, _, filenames in os.walk(path):
+ for filename in filenames:
+ if os.path.splitext(filename)[1] == '.ttf':
+ FontEngine.instance().register_font(os.path.join(dirpath, filename))
+
#register datasources
from mapnik import DatasourceCache
DatasourceCache.instance().register_datasources('%s' % inputpluginspath)
#register some fonts
-from mapnik import FontEngine
-from glob import glob
-fonts = glob('%s/*.ttf' % fontscollectionpath)
-if len( fonts ) == 0:
- print "### WARNING: No ttf files found in '%s'." % fontscollectionpath
-else:
- map(FontEngine.instance().register_font, fonts)
+register_fonts()
#set dlopen flags back to the original
setdlopenflags(flags)
===============================================================================
d. Compile and install Mapnik
tar xvjf mapnik-0.6.1.tar.bz2
cd mapnik-0.6.1
python scons/scons.py configure INPUT_PLUGINS=all \
OPTIMIZATION=3 SYSTEM_FONTS=/usr/share/fonts/
(You can also path PREFIX=... and PYTHON_PREFIX=.... if you don't
want a system-wide installation)
python scons/scons.py
python scons/scons.py install
e. Check the installation
Run a Python interpreter, and run "import mapnik". If it doesn't
work and you didn't do a system-wide installation of Mapnik, don't
forget to set the PYTHONPATH and LD_LIBRARY_PATH environment
variables.
10. Install Mapnik-OSM
Mapnik-OSM is the set of files that tell Mapnik how to render
OpenStreetMap maps.
a. Download
svn co http://svn.openstreetmap.org/applications/rendering/mapnik mapnik-osm
b. Installation of static data
In addition to the OpenStreetMap data, some other static data are
used to render the maps (world boundaries, etc.)
wget http://tile.openstreetmap.org/world_boundaries-spherical.tgz
cd /path/to/mapnik-osm/
tar xzf ~/download/world_boundaries-spherical.tgz
wget http://tile.openstreetmap.org/processed_p.tar.bz2
tar xjf ~/download/processed_p.tar.bz2 -C /path/to/mapnik-osm/world_boundaries
wget http://tile.openstreetmap.org/shoreline_300.tar.bz2
tar xjf ~/download/shoreline_300.tar.bz2 -C /path/to/mapnik-osm/world_boundaries
wget http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/10m-populated-places.zip
unzip 10m-populated-places.zip -d /path/to/mapnik-osm/world_boundaries
wget http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/110m-admin-0-boundary-lines.zip
unzip 110m-admin-0-boundary-lines.zip -d /path/to/mapnik-osm/world_boundaries
c. Enabling unifont
In order to get correct rendering for Korean, Chineese or Japanese
character, the unifont font must be used. In order do enable it,
edit inc/fontset-settings.xml.inc, and uncomment the following
line :
<Font face_name="unifont Medium" />
in the book-fonts, bold-fonts and oblique-fonts sections.
d. Configuration
python ./generate_xml.py --dbname maposmatic --host 'localhost' \
--user maposmatic --port 5432 \
--password 'ereiamjh'
11. Installation of OCitySMap
a. Install Git if needed
sudo aptitude install git-core
b. Grab the sources
git clone git://git.savannah.nongnu.org/maposmatic/ocitysmap.git
c. Initialize OCitySMap SQL stuff
psql -h localhost \
-U maposmatic \
-f /path/to/ocitysmap/ocitysmap-init.sql \
-d maposmatic
d. Install dependencies
sudo aptitude install python-psycopg2 python-gdal \
python-gtk2 python-cairo
Note that python-gtk2 is not needed for any graphical interface,
but because it contains Pango and PangoCairo that we use to render
text on the map.
e. Configuration file
Create a ~/.ocitysmap.conf configuration file, modeled after the
provided ocitysmap.conf file.
12. Run OCitySMap
./ocitysmap-render -f png -c Sanguinet