-
Notifications
You must be signed in to change notification settings - Fork 19
/
INSTALL
526 lines (353 loc) · 16.9 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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
OCitySMap installation instructions
===================================
These instructions refer to software dependencies by using Ubuntu
Lucid (14.04) package names. Minor adaptations might be needed for
other distributions or for the precise Debian or Ubuntu release you
are using. They have been tested on several x86_64 hosts.
1. Installation of PostgreSQL and PostGIS
sudo aptitude install postgresql postgresql-contrib
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 data types 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. Download postgis 2.1
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo aptitude update
sudo aptitude dist-upgrade # Or safe-upgrade if you prefer
sudo aptitude install postgresql-9.3-postgis-2.1
If nothing happens, you may have to check the output of "apt-get
policy postgresql-9.3-postgis-2.1" and adjust your apt preferences. A
sensible default preferences configuration file for this repository could
be:
Package: *
Pin: release o=LP-PPA-ubuntugis-ubuntugis-unstable
Pin-Priority: 700
c. Install PostGIS support in Postgres
sudo -u postgres \
psql \
-f /usr/share/postgresql/9.3/contrib/postgis-2.1/postgis.sql \
-d maposmatic
Provide comments (Optional):
sudo -u postgres \
psql \
-f /usr/share/postgresql/9.3/contrib/postgis-2.1/postgis_comments.sql \
-d maposmatic
d. Add the list of spatial referential systems
sudo -u postgres \
psql \
-f /usr/share/postgresql/9.3/contrib/postgis-2.1/spatial_ref_sys.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
e. Add hstore extension support
echo "CREATE EXTENSION hstore;" | 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.
a. If needed, install SVN
sudo aptitude install subversion
b. Grab osm2pgsql code
svn co http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/
# Tested revisions: r27862
c. Install the build dependencies
sudo apt-get build-dep osm2pgsql
d. Compile
cd osm2pgsql
./autogen.sh
./configure # with --prefix=.... as needed
make
e. Install
Provided you supplied the correct --prefix=... option, just enter:
make install
6. Download the OSM data
We give the example for Luxembourg.
wget http://download.geofabrik.de/osm/europe/luxembourg.osm.bz2
7. Import the OSM data
osm2pgsql -s -c -d maposmatic -m -U maposmatic -W \
-H localhost -k luxembourg.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).
If you want to add other OSM DB files, replace the '-c' option
with a '-a' option in the subsequent files you are adding: if you
keep the '-c' option, it will erase any previous GIS data you may
have. For example:
osm2pgsql -s -a -d maposmatic -m -U maposmatic -W \
-H localhost -k ile-de-france.osm.bz2
8. Install Mapnik
We need Mapnik 2.1.0, which is not yet available in stable
Debian/Ubuntu, so we need to compile it from source.
a. Install the dependencies
# Base dependencies (0.7.0 by default on lucid, a good start)
sudo apt-get build-dep python-mapnik
# Upgrade to libboost >= 1.41
sudo add-apt-repository ppa:thomasjj/backports
sudo aptitude update
sudo aptitude dist-upgrade # Or safe-upgrade if you prefer
sudo aptitude purge libboost1.40-dev
sudo aptitude install libboost1.46-dev libboost-date-time1.46-dev \
libboost-filesystem1.46-dev libboost-iostreams1.46-dev \
libboost-program-options1.46-dev libboost-python1.46-dev \
libboost-regex1.46-dev libboost-serialization1.46-dev \
libboost-system1.46-dev libboost-thread1.46-dev
b. Download the latest Mapnik from its Git repository
git clone git://github.com/mapnik/mapnik.git
cd mapnik
c. Compile and install Mapnik
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
d. If building Mapnik failed
Cloning the repository (step 8b) implicitly runs 'git checkout HEAD',
giving you the latest version. Should you run into trouble either installing
or running this latest version, you can use the version we know to work:
git checkout c88fcc8f # Note: replace this with commit hash of version on dev.m.o
python scons/scons.py -c # Clean up failed build
Repeat step 8c.
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 \
mapnik2-osm
# Tested revision: r28170
b. Installation of static data
In addition to the OpenStreetMap data, some other static data are
used to render the maps (world boundaries, etc.)
cd mapnik2-osm
sh ./get-coastlines.sh
c. Enabling unifont
In order to get correct rendering for Korean, Chinese or Japanese
character, the unifont font must be used. In order do enable it:
sudo aptitude install ttf-unifont
(on debian, mapnik2 uses only ttf-dejavu, correct fontscollectionpath
in /usr/lib/python2.7/dist-packages/mapnik2/paths.py, replace
'/usr/share/fonts/truetype/ttf-dejavu' by '/usr/share/fonts'. Bug
report #665798).
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 git-email
b. Grab the sources
git clone git://git.savannah.nongnu.org/maposmatic/ocitysmap.git
c. Install dependencies
sudo aptitude install python-psycopg2 python-gdal \
python-gtk2 python-cairo \
python-shapely
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.
d. Configuration file
Create a ~/.ocitysmap.conf configuration file, modeled after the
provided ocitysmap.conf.dist file.
12. Run OCitySMap
./render.py -t "Ceci n'est pas Paris" --osmid=-411354 # Contern, LU
./render.py -t "Ceci n'est pas Paris" --osmid=-943886 # Chevreuse, FR
Appendix A: Installation of maposmatic-printable stylesheet
------------------------------------------------------------
This step builds on step 10 "Install Mapnik-OSM" and step 11
"Installation of OCitySMap".
a. Copy stylesheet/maposmatic-printable/symbols/* (i.e. all files in
symbols/ directory) into mapnik2-osm/symbols/ directory.
b. Add absolute path to file stylesheet/maposmatic-printable/osm.xml
into ~/.ocitysmap.conf.
c. Configure the stylesheet with database parameters and relevant
directories:
cd stylesheet/maposmatic-printable/
python ./generate_xml.py --dbname maposmatic --host 'localhost' \
--user maposmatic --port 5432 \
--password 'ereiamjh' \
--world_boundaries mapnik2-osm/world_boundaries \
--symbols mapnik2-osm/symbols
Appendix B: installation of the MapQuest stylesheet
-------------------------------------------------
The above instructions, at step 10, describe how to set up ocitysmap
with the default Mapnik stylesheet for OpenStreetMap. It is possible
to install other stylesheets, such as the stylesheets made available
by MapQuest. The instructions below detail how to install those
additional stylesheets, making the assumption that ocitysmap is
properly configured and running with the default OSM stylesheet.
First, grab the MapQuest stylesheets:
git clone git://github.com/MapQuest/MapQuest-Mapnik-Style.git
(tested versions:
9d6c5503194c58fc1f9f760b4e5af8a1602dfb30
6f7ea2723c07a1db2d17c2336dd3a0b3dd2d6fe9)
Go into the MapQuest-Mapnik-Style directory, in which we will do all
the configuration.
With above tested version, there is a bug in the stylesheet. That should
be fixed using a patch provided in the support/ directory.
patch -p1 < /path/to/ocitysmap/support/mapquest-stylesheet-eu-fix.patch
patch -p1 < /path/to/ocitysmap/support/mapquest-stylesheet-uk-fix.patch
First, those stylesheets require the same "world boundaries"
information as the original OSM stylesheet, so we are going to share
these informations by creating a symbolic link:
ln -s /path/to/original/osm/stylesheet/world_boundaries world_boundaries
In addition to those world boundaries, the MapQuest stylesheets need a
few other files. Download the corresponding tarball:
wget http://developer.mapquest.com/content/static/geotiffs/mercator_tiffs.tar
Unpack this archive, and put the four mq_world_mercator_*.tiff files
directory into the world_boundaries/ directory (this directory is
shared with the original OSM stylesheet, but this is not a problem as
the mq_world_mercator_*.tiff files are not used by the original OSM
stylesheet).
Now, to the configuration of the stylesheet itself (use the
.inc.template files):
vi mapquest_inc/fontset-settings.xml.inc.template
Not much to change here, the default value is fine. If you want to use
the same font for the original OSM stylesheet and the MapQuest one,
replace "Arial" by "DejaVu".
Create the .inc files from the templates:
python /path/to/mapnik2-osm/generate_xml.py --inc mapquest_inc \
--symbols mapquest_symbols \
--dbname maposmatic \
--host 'localhost' \
--user maposmatic --port 5432 \
--password 'ereiamjh'
The final step is to integrate this new stylesheet in ocitysmap. To do
so, edit your ~/.ocitysmap.conf file, and add a new stylesheet
section, like:
[mapquest_eu]
name: MapQuestEu
description: MapQuest Europe stylesheet
path: /path/to/MapQuest-Mapnik-Style/mapquest-eu.xml
Don't forget to add "mapquest_eu" to the available_stylesheets
variable, which lists all available stylesheets.
You can then use it in render.py with the -s option:
./render.py -s MapQuestEu ...
Note that in addition to the MapQuest Europe stylesheet
(mapquest-eu.xml), the Git repository also contains the MapQuest US
and MapQuest UK stylesheets (mapquest-us.xml and mapquest-uk.xml),
that you can similarly add to your ocitysmap.conf file.
Appendix C: installation of the Stamen Toner stylesheet
-------------------------------------------------------
Toner is a black and white stylesheet initialy provided by Stamen
(http://maps.stamen.com/#toner). The instructions below detail how to install
this stylesheets, making the assumption that ocitysmap is properly configured
and running with the default OSM stylesheet.
1. Cascadenik installation
Cascadenik implements cascading stylesheets for Mapnik. Cascadenik is a
requisite for Toner stylesheet.
# install dependancies
sudo aptitude install python-cssutils python-imaging
# clone the repository
git clone https://github.com/mapnik/Cascadenik.git
cd Cascadenik/
git checkout mapnik2 # switch to mapnik2 branch
When tested (rev. 7dc2587) Cascadenik mapnik2 branch was not fully functionnal
(at least with mapnik 2.1). If no correction has been made since a patch is
provided to fix that:
git checkout 7dc2587
git am --signoff < /path/to/ocitysmap/stylesheet/toner/0001-Fixes-output.py-to-make-it-compatible-with-mapnik-2..patch
Then you can install it:
python setup.py install
2. Coastline table
Toner stylesheet reads the coastline datas in the postgis database. We need to
import it in our database.
cd path/to/mapnik-osm/world_boundaries
shp2pgsql -s 900913 -I processed_p.shp coastline \
| psql -U maposmatic -d maposmatic -h localhost
3. Natural Earth Data database
Toner stylesheet uses many data from the natural earth database
(http://www.naturalearthdata.com/). We are going to import all theses datas
inside another postgis database.
mkdir naturalearth
cd naturalearth
wget http://kelso.it/x/nevector # download all Natural Earth Data shape
# files cf. http://www.naturalearthdata.com/downloads/
unzip nevector
sudo su postgres
# create db
createdb -E UTF-8 -O maposmatic naturalearth
# add geographic extensions
psql -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql \
-d naturalearth
psql -f /usr/share/postgresql/9.1/contrib/postgis_comments.sql \
-d naturalearth
psql -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql \
-d naturalearth
# fix permissions
echo "ALTER TABLE geometry_columns OWNER TO maposmatic;
ALTER TABLE spatial_ref_sys OWNER TO maposmatic;" | psql -d naturalearth
# import data from shapefiles
for FILE in `find . -name *.shp`; do \
BASE=`basename $FILE .shp`; \
shp2pgsql -W LATIN1 -s 900913 -I $FILE $BASE \
| psql naturalearth; done
# fix permissions
for FILE in `find . -name *.shp`; do BASE=`basename $FILE .shp`; \
echo "ALTER TABLE "$BASE" OWNER TO maposmatic;" \
| psql -d naturalearth ; done
4. Install Toner
git clone https://github.com/Citytracking/toner.git
The installation has been tested with the commit 58369be
git checkout 58369be
4.1 Install toner specific datas
Toner stylesheet is provided with some labels and some roads. We are
importing them in the naturalearth database.
cd /path/to/toner/
# fixes manualy set database parameters with ours
sed -i 's/psql -d toner -U osm/psql -h localhost -d naturalearth -U maposmatic/' \
import_toner_v2_shps.sh
# if you don't want to type too many times the database pass
vim ~/.pgpass
localhost::naturalearth:maposmatic:maposmatic_password
chmod 0600 ~/.pgpass
# import
sh import_toner_v2_shps.sh
4.2 Specific planet views
A specific view is used for motorway in the OSM database.
cd /path/to/toner/osm
psql -h localhost -U maposmatic maposmatic < motorways.pgsql
Other views are necessary.
cd /path/to/toner/mapnik/
psql -h localhost -U maposmatic maposmatic < views.pgsql
4.3 Stylesheet generation
cd /path/to/toner/mapnik/
cp /path/to/ocitysmap/stylesheet/toner/style-toner-ocitysmap.mml .
cp /path/to/ocitysmap/stylesheet/toner/labels-ocitysmap.mss .
# configure database access: change host, name, user and password
# for each database listed at top of the file
vim style-toner-ocitysmap.mml
# generate the stylesheet
/path/to/cascadenik/cascadenik-compile.py style-toner-ocitysmap.mml \
/tmp/style-toner-ocitysmap.xml
mv /tmp/style-toner-ocitysmap.xml /path/to/ocitysmap/stylesheet/toner/
5. ocitysmap configuration
Edit properly the configuration file.
vim /home/$USER/.ocitysmap.conf
[Toner]
name: Toner
description: Stamen Toner stylesheet
path: /path/to/ocitysmap/stylesheet/toner/style-toner-ocitysmap.xml
Don't forget to add "Toner" to the available_stylesheets variable, which lists
all available stylesheets.