Outils pour utilisateurs

Outils du site


hackfest2009:hackfest2009

Hackfest 2009

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

  •  IRC OSM : #osm-fr sur irc.oftc.net

Autres pages

Installation et configuration de PostgreSQL/PostGIS

  • Paquet installé pour PostGIS : postgresql-8.3-postgis. Cela installe le serveur et le client PostgreSQL, ainsi que l'extension Postgis. À noter que le paquet postgis installe seulement quelques outils liés à PostGIS, pas PostGIS lui-même.
  • Paquet installé pour une interface graphique d'administration de PostgreSQL: pgadmin3
  • Configuration du mot de passe de l'utilisateur postgres du serveur de base de données (pas l'utilisateur Unix !), voir https://help.ubuntu.com/community/PostgreSQL#Basic%20Server%20Setup

Jouons avec PostGIS

  • Connexion à la base de données: psql -h localhost -U test testdb
  • Création d'une table: create table cities (name varchar);. On ne peut pas créer directement au create table les champs géographiques, car il faut non seulement créer un champ dans la table, mais aussi créer une entrée dans la date spéciale geometry_columns
  • Ajout du champ géographique: select addgeometrycolumn('cities', 'geom', 4002, 'POINT', 2);. cities est la table, geom est le nom du champ, 4002 est le SRID, POINT le type du champ et 2 la dimension
  • Insertion de quelques entrées dans la table:
    • insert into cities (name, geom) values ('Plop', st_geomfromtext('POINT(10 10)', 4002));. La fonction st_geomfromtext() sert à créer le bazar binaire qui sera stocké dans la table à partir d'une description en WKT (Well-Known Text) de l'information géographique. On doit également spécifier le SRID dans lequel la donnée géographique est passée.
    • insert into cities (name, geom) values ('Plap', st_geomfromtext('POINT(20 20)', 4002));
    • insert into cities (name, geom) values ('Plip', st_geomfromtext('POINT(30 10)', 4002));
  • Jouons avec les données en calculant les distances entre toutes les entrées de la table et le point de coordonnées (0,0)
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
  • Jouons avec les polygones.
    • Création d'une table: create table communes (name varchar);.
    • Création du champ géographique: select addgeometrycolumn('communes', 'geom', 4002, 'POLYGON', 2);
    • Insertion d'une donnée: insert into communes (name, geom) values ('Ville1', st_geomfromtext('POLYGON( (10 10, 15 20, 30 40, 10 10) )', 4002));
    • Calcul de la surface:
select name, st_area(geom) from communes;
  name  | st_area 
--------+---------
 Ville1 |      25
  • Calcul du périmètre
select name, st_perimeter(geom) from communes;
  name  |   st_perimeter   
--------+------------------
 Ville1 | 72.2358526421388
  • Affichage de la donnée géographique sous forme texte (lisible!) avec la fonction st_astext()
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

  • Chargement de france.osm dans le pgsql de Thomas avec osm2pgsql (svn rel 17214) : osm2pgsql -c -d testdb -m -U test -H surf.local Desktop/france.osm.bz2

Ressources

OpenStreetMap

  • Requête pour calculer la bounding box d'une commune, en supposant que les limites administratives de celles-ci existent dans OSM : select st_astext(st_transform(st_setsrid(st_box2d(way), 900913), 4002)) from planet_osm_polygon where name='Toulouse';

Installation Ubuntu par PXE

Installation mapnik

  • compilation
$ 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 :

  • de
  • du
  • de la
  • des
  • d'

Liste des appellations particulières de rues :

  • Allée f.
  • Avenue f.
  • Boulevard m.
  • Carrefour m.
  • Chaussée f.
  • Chemin m.
  • Cité f.
  • Clos m.
  • Côte f.
  • Cour f.
  • Cours m.
  • Degré m.
  • Esplanade f.
  • Impasse f.
  • Liaison f.
  • Mail m.
  • Montée f.
  • Passage m.
  • Place f.
  • Placette f.
  • Pont m.
  • Promenade f.
  • Quai m.
  • Résidence f.
  • Rond-Point m.
  • Rang m.
  • Route f.
  • Ruelle f.
  • Square m.
  • Traboule f.
  • Traverse f.
  • Venelle f.
  • Voie f.

Mais aussi :

  • Berge
  • Cul-de-Sac
  • Escalier
  • Parvis
  • Passerelle
  • Giratoire
  • Jardin

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 :

  • Autoroute f.
  • Bretelle
  • Sente f.
  • Sentier m.

Cairo

hackfest2009/hackfest2009.txt · Dernière modification: 2009/09/11 12:02 par 88.173.105.122