Please have a look at https://github.com/Tristramg/osm4routing2
This tool provides an OpenStreetMap data parser to turn them into a nodes-edges adapted for routing applications.
The input is an OpenStreetMap XML file. The file can be read:
The output can be:
In both output you'll get two files/tables:
nodes that contain
edges that contain
The accessibility is an integer describing the edge for every mean of transport. As for cars an bikes the driving direction might change those properties, the are direct (source->target direction) an reverse (target->source direction) information.
The integers mean:
You need:
# Just run the following command
sudo python setup.py install
# Run it
osm4routing --help
# If you don't have the rights to install it system-wide, or don't want to, use virtualenv:
# Create a virtual environment and activate it
python virtualenv.py env
source env/bin/activate
python setup.py install
osm4routing --help
Get the .osm XML file of the region that interests you. For limited regions, use the export tools from the web interface. For bigger regions you might find what you want at http://download.geofabrik.de/osm/ Osmosis can help you to have a smaller region from a big dump http://wiki.openstreetmap.org/wiki/Osmosis
To know the options, run: osm4routing --help
OSM data can get very big and can be very consuming, don't try to parse the whole world ;) On my laptop from 2006 (core2duo 1.66Ghz, 2Gb Ram, slow hard drive), it takes 20 minutes to parse 8Gb uncompressed (0.5Gb as bzip2) and represents France in June 2010
Only if you want to use the spatial abilities of postgis, please read those extra informations in order to a have spatial database The usual way to get is to execute the following commands (the location of lwpostgis.sql and spatial_ref_sys.sql depend on your installation).
createdb yourdatabase
createlang plpgsql yourdatabase
psql -d yourdatabase -f lwpostgis.sql
psql -d yourdatabase -f spatial_ref_sys.sql