Table des matières

Hackfest 2009

Au programme : http://thomas.enix.org/Hackfest2009

Autres pages

Installation et configuration de PostgreSQL/PostGIS

Jouons avec PostGIS

select name, st_distance(geom, st_geomfromtext('POINT(0 0)', 4002)) from cities;
 name |   st_distance    
------+------------------
 Plop |  14.142135623731
 Plap | 28.2842712474619
 Plip | 31.6227766016838
select name, st_area(geom) from communes;
  name  | st_area 
--------+---------
 Ville1 |      25
select name, st_perimeter(geom) from communes;
  name  |   st_perimeter   
--------+------------------
 Ville1 | 72.2358526421388
select name, st_astext(geom) from communes;
  name  |             st_astext              
--------+------------------------------------
 Ville1 | POLYGON((10 10,15 20,30 40,10 10))

Référence

OpenStreetMap dans PostGIS

Ressources

OpenStreetMap

Installation Ubuntu par PXE

Installation mapnik

$ cd mapnik-0.6.1/
$ python scons/scons.py configure INPUT_PLUGINS=all \
  OPTIMIZATION=3 PREFIX=/usr/local/stow/mapnik-0.6.1 \
  PYTHON_PREFIX=/usr/local/stow/mapnik-0.6.1/ \
  SYSTEM_FONTS=/usr/share/fonts/truetype/ttf-dejavu/
$ python scons/scons.py
$ export PYTHONPATH="/home/thomas/sys/lib/python2.6/site-packages"
$ export LD_LIBRARY_PATH="/home/thomas/sys/lib"
$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
>>> 
$ svn checkout http://svn.openstreetmap.org/applications/rendering/mapnik mapnik-osm
$ cd mapnik-osm/
$ diff -u ./set-mapnik-env.orig  ./set-mapnik-env
--- ./set-mapnik-env.orig	2009-08-23 18:39:24.000000000 +0200
+++ ./set-mapnik-env	2009-08-23 18:43:28.000000000 +0200
@@ -30,26 +30,26 @@
 
 # This is the name of the *local* version of the Mapnik map file after it has
 # been run through the cutomize-mapnik-map script.
-export MAPNIK_MAP_FILE=~/mapnik/osm.xml
+export MAPNIK_MAP_FILE=~/osm/mapnik-osm/osm.xml
 
 # This is the directory where the icons and symbols for Mapnik are. If
 # you have checked out the OSM subversion directory into a directory
 # called ~/svn.openstreetmap.org, the symbols will be in
 # ~/svn.openstreetmap.org/applications/rendering/mapnik/symbols
-export MAPNIK_SYMBOLS_DIR=~/mapnik/symbols
+export MAPNIK_SYMBOLS_DIR=~/osm/mapnik-osm/symbols
 
 # This is the directory where you upacked the world_boundaries.tar.bz2
 # file you got from
 # http://artem.dev.openstreetmap.org/files/world_boundaries.tar.bz2
-export MAPNIK_WORLD_BOUNDARIES_DIR=~/mapnik/world_boundaries
+export MAPNIK_WORLD_BOUNDARIES_DIR=~/osm/mapnik-osm/world_boundaries
 
 # Directory where the created map tiles should be stored. Must end with
 # a slash (/)
-export MAPNIK_TILE_DIR=~/mapnik/tiles/
+export MAPNIK_TILE_DIR=~/osm/mapnik-osm/tiles/
 
 # This is the name of the server running the PostgreSQL database. Leave
 # this empty if your database is on the local machine.
-export MAPNIK_DBHOST=""
+export MAPNIK_DBHOST="localhost"
 
 # This is the TCP port where the PostgreSQL server is listening. The
 # default port for PostgreSQL is 5432. Leave this empty if your database
@@ -57,13 +57,13 @@
 export MAPNIK_DBPORT=""
 
 # This is the name of the database where the OSM data is stored.
-export MAPNIK_DBNAME='osm'
+export MAPNIK_DBNAME='testdb'
 
 # This is the username we should use to log into the PostgreSQL database.
-export MAPNIK_DBUSER=`whoami`
+export MAPNIK_DBUSER="test"
 
 # This is the password we should use to log into the PostgreSQL database.
-export MAPNIK_DBPASS=""
+export MAPNIK_DBPASS="test"
 
 # This is the prefix used in the table names. Matches the -p option in osm2pgsql
 # Unspecified defaults to "planet_osm"
$ . ./set-mapnik-env
$ ./customize-mapnik-map >$MAPNIK_MAP_FILE

Modifier osm.xml.

$ wget http://tile.openstreetmap.org/world_boundaries-spherical.tgz
$ wget http://tile.openstreetmap.org/processed_p.zip
$ wget http://tile.openstreetmap.org/shoreline_300.tar.bz2
$ cd /home/thomas/osm/mapnik-osm/
$ tar xzf ~/osm/world_boundaries-spherical.tgz
$ unzip ~/osm/processed_p.zip
$ mv coastlines/* world_boundaries/
$ rmdir coastlines
$ tar xjf ~/osm/shoreline_300.tar.bz2 -C world_boundaries
--- generate_image.py	(revision 17214)
+++ generate_image.py	(working copy)
@@ -14,6 +14,7 @@
 # pixel size so will appear smaller on a large image.
 
 from mapnik import *
+import cairo
 import sys, os
 
 if __name__ == "__main__":
@@ -26,12 +27,13 @@
     #---------------------------------------------------
     #  Change this to the bounding box you want
     #
-    ll = (-6.5, 49.5, 2.1, 59)
+    #ll = (-6.5, 49.5, 2.1, 59)
+    ll = (-1.0901, 44.4883, -1.0637, 44.4778)
     #---------------------------------------------------
 
-    z = 10
-    imgx = 500 * z
-    imgy = 1000 * z
+    z = 17
+    imgx = 500 
+    imgy = 1000 
 
     m = Map(imgx,imgy)
     load_map(m,mapfile)
@@ -44,3 +46,8 @@
     render(m, im)
     view = im.view(0,0,imgx,imgy) # x,y,width,height
     view.save(map_uri,'png')
+
+    # SVG
+    surface = cairo.SVGSurface('image.svg', m.width, m.height)
+    render(m, surface)
+
$ ./generate_image.py
$ gthumb image.png
$ firefox image.svg

Préfixes pour les voies urbaines

Liste des déterminants :

Liste des appellations particulières de rues :

Mais aussi :

Les dénominations suivantes s'appliquent à des voies qui ne sont pas des rues, soit parce qu'elles ne se trouvent pas en zone urbaine, soit qu'elles en sont complètement isolées. Ces voies ne remplissent donc qu'une fonction de circulation exclusivement :

Cairo