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

I am designing the android mobile application project using java. I downloaded the map from http://downloads.cloudmade.com/ . I got infromation (lat & lon) of each node but there is no information about distance value. I am facing the problem to calculate the shortest path. These day I found the possible solution but it is still confused.

Here is the website seems to be useful: http://wiki.openstreetmap.org/wiki/Distance_maps#Checking_routing_connectivity_of_an_OSM_file . But I cannot find the ROUTE.OSM from the cloudmade.com

As I know, the well-known method is Dijkstra's algorithm. Is there any existing method to get the shortest path between nodes under android development environment ?

Many Thanks!!!!

asked 19 Mar '12, 08:16

yenyip's gravatar image

yenyip
11225
accept rate: 0%

edited 19 Mar '12, 08:32

Please elaborate. What exactly do you want to compute?

  • The shortest path between two variable nodes
  • The shortest path between one fixed and one variable node?
  • The shortest path between one fixed and “all” points?
(21 Mar '12, 20:35) hfs

The shortest path between two variable nodes. The application receives the input (starting point and destination) from the user and calculates the path by Dijkstra's algorithm

(23 Mar '12, 03:50) yenyip

Please how did you get infromation (lat & lon) of each node??

(23 May '18, 17:41) yhsafa

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.

permanent link

answered 22 Mar '12, 20:20

stephan75's gravatar image

stephan75
12.6k556210
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

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).

permanent link

answered 28 Mar '12, 17:39

sanser's gravatar image

sanser
695383955
accept rate: 5%

edited 29 Mar '12, 10:32

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.

permanent link

answered 23 Mar '12, 04:23

Gnonthgol's gravatar image

Gnonthgol ♦
13.8k16103198
accept rate: 16%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

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:

×181
×63

question asked: 19 Mar '12, 08:16

question was seen: 9,852 times

last updated: 23 May '18, 17:41

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