Android Question Bearing to ?

hookshy

Well-Known Member
Licensed User
Longtime User
How do you calculate direction of travel using bearing ?
I want to determine if the user is heading a given point of known latitude and longitude ?
 

Rick in North Carolina

Member
Licensed User
Longtime User
You can use the GPS Location object:

B4X:
Sub GPS_LocationChanged (Location1 As Location)
    meLoc.Latitude = Location1.Latitude
    meLoc.Longitude = Location1.Longitude
End Sub
B4X:
rvLoc.Latitude = latt
rvLoc.Longitude = longt
bearing = meLoc.BearingTo(rvLoc)
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
Yes this is easy to calculate degree from my current location "meloc" to given point rvloc and for example if the result is 0 degree this means that
the direction of the given point is north relative to my location .
Problem is that this calculation isn't enough to decide if i am heading north , I may be heading 30 degree N-V . I must calculate the diference of degree from my curent direction and the direction to the given point !
I guess the question would be how to calculate the current bearing ...or where I am heading to ? May be someting is missing ...hope to find out what !
Thank you !
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
B4X:
Sub Location_LocationChanged (Longitude As Double, Latitude As Double, Altitude As Double, Accuracy As Float, Bearing As Float, Provider As String, Speed As Float, Time As Long)

End Sub
I do not understand what is the meaning of bering in the locationchanged event when bearing is always 0 in my tests...somewere is somethin wrong :confused:
 
Last edited:
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
I think valid bearing is received by the location event when you request gps listennig without parameters
lm.requestgpslistening(0,0) no time delay ,no distance offset ...but i must do some tests
 
Upvote 0
Top