I am planning to use .osm data for solving graph problems (TSP, VRP, etc.). After solving routes using the osm xml data, I plan to plot the results on a osm image using markers for vertices and paths so the end user could see the routes in a readable and comprehensible image. The problem is the data given on osm xml data is only latitude longitude values. So how is it scaled in the image given zoom level and bounding box? Or any suggestions on solving this problem? asked 30 Jul '11, 13:58 jplaras |
The tiles offered by the OpenStreetMap tile servers are in the spherical mercator projection. As described in the wiki you can convert from latitude to longitude using the following formulae:
If you do so you normally only keep the integral part of xtile and ytile which determine the name of the tile in the http://a.tile.openstreetmap.org/zoom/xtile/ytile.png naming scheme. You can however keep the fractional part of xtile and ytile and multiply by 256 - the width of the tile - and derive which pixel of the tile contains the longitude and latitude that you started with. This allows you to plot your coordinates on top of standard OpenStreetMap tiles. answered 30 Jul '11, 17:35 petschge |