1 | = osm2pgrouting data converter = |
---|
2 | |
---|
3 | This tool makes it easy to import OpenStreetMap data and use it with pgRouting. |
---|
4 | It creates topology automatically and creates tables for feature types and road |
---|
5 | classes. |
---|
6 | osm2pgrouting was primarily written by Daniel Wendt and is now hosted on the |
---|
7 | pgRouting project site: |
---|
8 | http://pgrouting.postlbs.org/wiki/tools/osm2pgrouting |
---|
9 | |
---|
10 | == How to install (Ubuntu 8.04) == |
---|
11 | |
---|
12 | Check out the latest version from SVN repository: |
---|
13 | {{{ |
---|
14 | svn checkout http://pgrouting.postlbs.org/svn/pgrouting/tools/osm2pgrouting/trunk osm2pgrouting |
---|
15 | }}} |
---|
16 | |
---|
17 | Required packages/libraries: |
---|
18 | |
---|
19 | 1. PostgreSQL |
---|
20 | 2. PostGIS |
---|
21 | 3. pgRouting |
---|
22 | 4. Boost library |
---|
23 | 5. Expat library |
---|
24 | 6. libpq library |
---|
25 | |
---|
26 | Note: if you already compiled pgRouting point 1. to 4. should already be |
---|
27 | installed. |
---|
28 | |
---|
29 | Then compile |
---|
30 | {{{ |
---|
31 | cd osm2pgrouting |
---|
32 | make |
---|
33 | }}} |
---|
34 | |
---|
35 | == How to use == |
---|
36 | |
---|
37 | 1. First you need to create a database and add PostGIS and pgRouting functions: |
---|
38 | {{{ |
---|
39 | createdb -U postgres osm |
---|
40 | createlang -U postgres plpgsql osm |
---|
41 | |
---|
42 | psql -U postgres -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql osm |
---|
43 | psql -U postgres -f /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql osm |
---|
44 | |
---|
45 | psql -U postgres -f /usr/share/postlbs/routing_core.sql osm |
---|
46 | psql -U postgres -f /usr/share/postlbs/routing_core_wrappers.sql osm |
---|
47 | psql -U postgres -f /usr/share/postlbs/routing_topology.sql osm |
---|
48 | }}} |
---|
49 | |
---|
50 | 2. You can define the features and attributes to be imported from the |
---|
51 | OpenStreetMap XML file in the configuration file (default: mapconfig.xml) |
---|
52 | |
---|
53 | 3. 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 | |
---|
62 | Other 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 | |
---|
76 | 4. Connect to your database and see the tables that have been created |
---|
77 | {{{ |
---|
78 | psql -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 | |
---|
94 | Note: If tables are missing you might have forgotten to add PostGIS or pgRouting |
---|
95 | functions to your database. |
---|
96 | |
---|
97 | Let's do some more advanced routing with those extra information about road |
---|
98 | types and road classes. |
---|