NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

# How to find the distance values in osm file?

 1 Did you ever had a look at the OSM wiki, the endless source of knowledge? At Routing you get an overview about routing with OSM data. Or go to the Android section and search for apps that are opensource and have routing features. answered 22 Mar '12, 20:20 stephan75 12.6k●5●56●210 accept rate: 6% Thanks stephan75. Actually I have tried to use the apps listed in Android section. I have read the OSM wiki but still cannot get the distance values. Normally, which method should be used ? (23 Mar '12, 03:47) yenyip
 0 If I understand you right you want to make a routing engine for android. For the first this have been done before and you might be better of using one of those open source implementations. The first thing you have to learn is how the osm data is. There are a lot of tags that describe who can travel where and how fast and so forth. In the end you want to create a weighted graph of this data that you can store. Then you can run dijkstras algorithm on that graph. When you finaly have a route you can calculate the distance from point to point and add them up. As you might imagine this is quite the task and it will take a lot of development to get the routing engine fast enough that you can use it. My recomendations is that you take a look at some of the open source applications for android that supports offline routing, and try to reuse their code. answered 23 Mar '12, 04:23 Gnonthgol ♦ 13.8k●16●103●198 accept rate: 16%
 1 Well, apart from the useful advices, you are still missing the answer to your question: how to calculate the distance on the WGS'84 sphere between two points defined by P1(Lat1,Lon1) and P2(Lat2,Lon2)? If you don't minde, try this: X1=cos(C x Lat1) x cos(C x Lon1); X2=cos(C x Lat2) x cos(C x Lon2); Y1=cos(C x Lat1) x sin(C x Lon1); Y2=cos(C x Lat2) x sin(C x Lon2); Z1=sin(C x Lat1); Z2=sin(C x Lat2); (main-circle)distance(P1,P2)=R x acos(X1 x X2 + Y1 x Y2 + Z1 x Z2); Where R=6378137 and C=PI/180=0.0174532925 and distance in meters. Assumed, latitude and longitude are given in decimal degrees (if in radians, take C=1). answered 28 Mar '12, 17:39 sanser 695●38●39●55 accept rate: 5%

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×181
×63

question asked: 19 Mar '12, 08:16

question was seen: 9,497 times

last updated: 23 May '18, 17:41

### Related questions

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum