check the current position

ThePuiu

Active Member
Licensed User
Longtime User
Hi, i want to make a simple app that let me know if I'm near of a point whose GPS's coordinates are known. Which is the algorithm that check if a current point P(lat, lng) is less than x meters of a point Z (Lat1, Lng1)?
Thank you!
 

ThePuiu

Active Member
Licensed User
Longtime User
now, i try to get direction from current position to the given point P(x,y). I use:
Bearing = CurrentLocation.BearingTo(LocationP)

what is the obtained number ? is the angle between the direction of movement and position of point P? How to use this information to draw an arrow on the screen indicating the direction to the point P?

I use:
B4X:
GPS_LocationChanged (Location1 As Location)
....................
GRAPH.DrawBitmapRotated(Arrow,Null,R1,Bearing) 
....................
where Arrow is a bitmap with an arrow that point to the top.
but the result is unsatisfactory...what i'm doing wrong?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
The number given is the Bearing from the CurrentLocation to LocationP. ZERO = North.
You can use this Bearing to rotate the arrow, the top of the device would be the north. If the device has a compass you could draw the arrow according to the position of the device and showing the real direction the arrow pointing to LocationP.

Best regards.
 
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
I tried to use the following code to determine the north:
B4X:
Sub MF_SensorChanged(Values() As Float)
Dim se As SensorExtender
se = Sender
Select se.GetType
Case se.TYPE_ACCELEROMETER
rACC = se.LowPassFilter(Values,rACC,se.FILTERING_FACTOR_Recommended)
Ready = True
Case se.TYPE_MAGNETIC_FIELD
If Ready Then
Ready = False
Dim R(16) As Float
Dim i(16) As Float
If se.GetRotationMatrix(R,i,Values,rACC) Then
Dim ORi(3) As Float
ORi = se.GetOrientation(R)
Dim ORi0 As Float
ORi0 = ORi(0)* 180 / cPI
If ORi0 < 0 Then    
ORi0 = 360 + ORi0 
End If
Angle = ORi0
Else
End If
End If
End Select
End Sub
----------------------------------------
Sub Timer1_Tick
GRAPH.DrawBitmapRotated(Rose,Null,rectRose,Angle)
Activity.Invalidate2(rectRose)
End Sub
but the result is clearly wrong. What should I do?
TY!

------------------------------------------------------------------------------
------------------------------------------------------------------------------
late edit:
It seems it's display orientation ... in my application, it is set to portrait only. What should I modify to work correctly in portrait mode?
 
Last edited:
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
same program installed on Samsung Tab7 and HTC Desire looks north with a difference of 180 degrees! There is possibility the sensor in the phone is not "very" accurate?
 
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
pls, someone help me!
Where i can found a more detailed explanations of this values: ORi = se.GetOrientation(R)?
 
Upvote 0
Top