Tiledata2

From OpenStreetMap Wiki
Jump to navigation Jump to search

An implementation of the Tile data server using protocol buffers as the storage mechanism (similar to PBF file format).

Processing data

initialParse.py:

  • uses SAX XML parser to read OSM XML files
  • stores node and way locations into SQLite database (db.dat)
  • turns POIs and ways into protocol buffer objects, and stores them in sqlite databases (poi.dat, way.dat)

generateTiles.py:

  • for each zoom-15 tile:
    • adds all the ways which cross that tile to a protocol buffer object and stores it in a sqlite database (map.dat)

Using data

getMap.py contains a library to retrieve the data for any tile

mobileEncoding.py has sample functions to display the map objects


Structure

Defined in this file

Download

http://svn.openstreetmap.org/applications/utils/export/tiledata2/

Running

Convert protocol buffer definition into actual python code

pb/generate.sh

Parse the OSM file

initialParse.py < data.osm

Put all the ways into their tiles

generateTiles.py

See/share the results

ls -lh data/map.dat

Display a sample tile

from getMap import *
printMap(getMap(16372,10891))

Use the data


from getMap import *
mapData = getMap(16372,10891)
for w in mapData.way:
  for t in w.tag:
    print "%s = %s" % (t.k, t.v)
  for n in w.node:
    print "%f, %f" % (n.lat, n.lon) # n.id also available