pgRouting

Changeset 236

Show
Ignore:
Timestamp:
09/23/08 14:00:32 (2 months ago)
Author:
daniel
Message:

workshop: osm2pgrouting chapter + fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/workshop/FOSS4G2008/Docs/10_osm2pgrouting.chapter

    r233 r236  
    1 Before you can use this tool for importing Openstreetmap data, 
    2 you need to install 
     1= osm2pgrouting data converter = 
    32 
    4 1. postgresl 
    5 2. postgis 
    6 3. pgrouting 
    7 4. boost 
    8 5. expat 
     3This tool makes it easy to import OpenStreetMap data and use it with pgRouting. 
     4It creates topology automatically and creates tables for feature types and road  
     5classes.  
     6osm2pgrouting was primarily written by Daniel Wendt and is now hosted on the  
     7pgRouting project site: 
     8http://pgrouting.postlbs.org/wiki/tools/osm2pgrouting 
    99 
    10 and to prepare a database. 
     10== How to install (Ubuntu 8.04) == 
    1111 
    12 For compiling this tool, you will need boost, libpq and expat: 
    13 Then just type: make 
     12Check out the latest version from SVN repository: 
     13{{{ 
     14svn checkout http://pgrouting.postlbs.org/svn/pgrouting/tools/osm2pgrouting/trunk osm2pgrouting 
     15}}} 
    1416 
    15 Start the program like this: 
     17Required packages/libraries: 
    1618 
    17 ./osm2pgrouting -file your-OSM-XML-File.osm -conf mapconfig.xml -dbname routing -user postgres -clean 
     191. PostgreSQL 
     202. PostGIS 
     213. pgRouting 
     224. Boost library 
     235. Expat library 
     246. libpq library 
    1825 
    19 all available parameters are: 
     26Note: if you already compiled pgRouting point 1. to 4. should already be  
     27installed. 
    2028 
    21 required:  
    22 -file <file>  -- name of your osm xml file 
    23 -dbname <dbname> -- name of your database 
    24 -user <user> -- name of the user, which have write access to the database 
    25 -conf <file> -- name of your configuration xml file 
    26 optional: 
    27 -host <host>  -- host of your postgresql database (default: 127.0.0.1) 
    28 -port <port> -- port of your database (default: 5432) 
    29 -passwd <passwd> --  password for database access 
    30 -clean -- drop peviously created tables 
     29Then compile 
     30{{{ 
     31cd osm2pgrouting 
     32make 
     33}}} 
     34 
     35== How to use == 
     36 
     371. First you need to create a database and add PostGIS and pgRouting functions: 
     38{{{ 
     39createdb -U postgres osm 
     40createlang -U postgres plpgsql osm 
     41 
     42psql -U postgres -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql osm 
     43psql -U postgres -f /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql osm 
     44 
     45psql -U postgres -f /usr/share/postlbs/routing_core.sql osm 
     46psql -U postgres -f /usr/share/postlbs/routing_core_wrappers.sql osm 
     47psql -U postgres -f /usr/share/postlbs/routing_topology.sql osm 
     48}}} 
     49 
     502. You can define the features and attributes to be imported from the  
     51OpenStreetMap XML file in the configuration file (default: mapconfig.xml) 
     52 
     533. Open a terminal window and run osm2pgrouting with the following paramters 
     54{{{ 
     55./osm2pgrouting -file /home/foss4g/capetown_20080829.osm \ 
     56                                -conf mapconfig.xml \ 
     57                                -dbname osm \ 
     58                                -user postgres \ 
     59                                -clean 
     60}}} 
     61 
     62Other available parameters are: 
     63{{{ 
     64 * required:  
     65        -file   <file>          -- name of your osm xml file 
     66        -dbname <dbname>        -- name of your database 
     67        -user   <user>          -- name of the user, which have write access to the database 
     68        -conf   <file>          -- name of your configuration xml file 
     69 * optional: 
     70        -host   <host>          -- host of your postgresql database (default: 127.0.0.1) 
     71        -port   <port>          -- port of your database (default: 5432) 
     72        -passwd <passwd>        --  password for database access 
     73        -clean                          -- drop peviously created tables 
     74}}} 
     75 
     764. Connect to your database and see the tables that have been created 
     77{{{ 
     78psql -U postgres osm 
     79\d 
     80                 List of relations 
     81 Schema |        Name         |   Type   |  Owner    
     82--------+---------------------+----------+---------- 
     83 public | classes             | table    | postgres 
     84 public | geometry_columns    | table    | postgres 
     85 public | nodes               | table    | postgres 
     86 public | spatial_ref_sys     | table    | postgres 
     87 public | types               | table    | postgres 
     88 public | vertices_tmp        | table    | postgres 
     89 public | vertices_tmp_id_seq | sequence | postgres 
     90 public | ways                | table    | postgres 
     91(8 rows) 
     92}}} 
     93 
     94Note: If tables are missing you might have forgotten to add PostGIS or pgRouting  
     95functions to your database. 
     96 
     97Let's do some more advanced routing with those extra information about road 
     98types and road classes. 
  • branches/workshop/FOSS4G2008/Docs/11_pgrouting.weighted.chapter

    r235 r236  
    11= Advanced usage of pgRouting shortest path search = 
    22 
    3 An ordinary shortest path query result usualy looks like this: 
     3An ordinary shortest path query with result usualy looks like this: 
    44 
    55{{{ 
     
    9595 
    9696The idea behind these two tables is to specify a factor to be multiplied with  
    97 the cost of link (usually length): 
     97the cost of each link (usually length): 
    9898 
    9999{{{