1

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's gravatar image

PepeTheFrog
26113
accept rate: 0%

edited 04 Oct '15, 21:21

aseerel4c26's gravatar image

aseerel4c26 ♦
32.2k16239552


One Answer:
3

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.

permanent link

answered 04 Oct '15, 21:21

aseerel4c26's gravatar image

aseerel4c26 ♦
32.2k16239552
accept rate: 18%

edited 04 Oct '15, 22:37

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
73.3k866641137

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

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×110
×66
×17
×14
×8

question asked: 04 Oct '15, 18:03

question was seen: 4,549 times

last updated: 04 Oct '15, 22:58

powered by OSQA