Hello people! I am new to OSM so I am sorry if my question seems stupid to someone. Currently I am doing a Java project using real world map data, so naturally OSM was my choice to obtain the data. The idea of the project is simple - osm data (in my case in json format) is parsed and loaded into the java and from there I build a weighted directed graph to represent the whole map. All calculations that I need to do are done on the graph. So far i've made a simple module to parse the nodes and ways from the OSM json file thus I have the nodes and the edges of my graph. The problem is that OSM data did not have any info on the length of the ways/streets. I need that information because this is going to be the weights on my graph. I tried using JOSM, it had a measurement tool which gave me the lengths of the road segments but I have absolutely no idea how it works. Is there a way to obtain this kind of data? Are there any other services on the internet that provide real world map data but with lengths of street segments included? Thanks for you help! If you have any clarifying questions I will gladly answer! asked 04 Oct '15, 18:03 PepeTheFrog aseerel4c26 ♦ |
Each node has a real-world coordinate. To get the length of a way, calculate the distance based on the coordinates of its nodes (WGS84 projection). A popular formula for these calculations is the Haversine formula, and you'll find example implementations for many programming languages on the web. Way lengths are not explicitly saved in the OSM data. If you are doing a routing software, have a look at the many open source routing software which uses OSM data. answered 04 Oct '15, 21:21 aseerel4c26 ♦ Frederik Ramm ♦ Esp. the trafficmining framework might be interesting to you to play around with routing, without struggling to much with our raw data ;-)
(04 Oct '15, 21:26)
iii
It's not only related to routing, i have other stuff to do as well, but thanks anyway! I have also found this, for anyone who is trying to tackle the same problem, it might be useful: https://skorasaurus.wordpress.com/2014/05/07/how-i-measured-clevelands-length-of-roads-with-postgis-and-osm/
(04 Oct '15, 22:58)
PepeTheFrog
|