Hi,
here’s my tool to parse and render .OSM(.bz2) files.
https://bitbucket.org/siberiano/osm2python
1. Parses OSM files
It’s not well documented, but the usage is simple:
from osm2py.osm2py import parse_file
parse_file(input_stream, element_callback)
input_stream is a file-like object with osm xml data (can be a file, a bz2 file, an HTTP stream, etc)
element_callback is your callback function that will receive the dictionary with element (node, way, relation, bound if you like) and do something with it.
For example, in the package, osm2json.py is a wrapper that has a callback that dumps json data into a file.
mongo.py saves the elements into MongoDB collections.
2. Renders OSM files
It requires Django 1.3 installed on the python path. Template.py can
- render a data into string (.render(), .dumps())
- stream a rendered template into a file-like object (.dump())
- compose a dummy way of input nodes (to draw a route way for example)
The data must be like what you get from osm2py.parse_file.
I’m working on a routing in python. For now it’s just bidirectional A*, I want to extend it to ALT+Reach. It works on pre-processed graphs and the results are much better than those of pyroute. If anyone’s interested, contact me please.