Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell direction of two geo points

i've 3 geo points

(start Position)11.986242477259117, 79.84657287597656`

(middle position)11.984521304799278, 79.84583258628845

(end postion)11.985014568760436, 79.844491481781

I've get knowledge from How to draw a path on a map using kml file?

and i've drawed the line between geo points lik this.

enter image description here

i've calculate the distance using How to calculate distance between two locations using their longitude and latitude value

My question is, when user stands near on "A" (start position), i want to tell the direction, you hav move to "North","East","West","South" like this,.

if user wrongly move other direction, Need to tell like "You hav mov wrong direction" and say correct direction.

How to get the direction between two geo points.?

I've get the degee from Get direction (compass) with two longitude/latitude points

it returns some degree, But i'm unbale to tell the correct direction.

How to get the direction between two geo points.?

like image 390
RVG Avatar asked Aug 04 '12 07:08

RVG


1 Answers

check this method if it can help you:

location.getBearing()

Returns the direction of travel in degrees East of true North. If hasBearing() is false, 0.0 is returned.

Use this method or sensor for getting device's direction.

After that get the direction of your two points in degrees using this:

location.bearingTo(dest)

Returns the approximate initial bearing in degrees East of true North when traveling along the shortest path between this location and the given location. The shortest path is defined using the WGS84 ellipsoid. Locations that are (nearly) antipodal may produce meaningless results.

like image 110
Bobs Avatar answered Sep 24 '22 05:09

Bobs