Distance Calculator

PatrikL

Member
Licensed User
This sub is usable in GPS programs -
B4X:
Sub Calc
result.Text = sqrt(69.1 * (Lat2.Text - Lat1.Text) * 69.1 * (Lat2.Text - Lat1.Text) + 69.1 * (Lon2.Text - Lon1.Text) * cos(lat1.Text/57.3) * 69.1 * (Lon2.Text - Lon1.Text) * cos(lat1.Text/57.3))
End Sub
(Source: http://www.meridianworlddata.com/Distance-Calculation.asp )
- create 5x TextBox - Lat1,2; Lon1,2; result and one Button - Calc
My sample is here:
distance.JPG
 

Attachments

  • gpsdistance.zip
    109.1 KB · Views: 404
Last edited:

sho431

New Member
Good idea, i try to find formula via google :)

I need :sign0085:

B4X:
distanceEast=(Lon2.Text - Lon1.Text) 
distanceNorth=(Lat2.Text - Lat1.Text)
direction= Atan(distanceNorth/distanceEast) Mod (2 * cPI)
direction = (direction)*(180/cPI)
If direction < 0 Then
direction+= 360
  End If
 

PatrikL

Member
Licensed User
2 sho431
- i try repair that sub, but it don't work :sign0085:
From where is that formula?
 
Top