Calculate The Distance Between Two Geographical Points
(Latitude / Longitude)

The following function returns the distance in feet between two geographical points (Latitude/Longitude).
Function getDistance(ByVal StartLongitude As Double, ByVal StartLatitude As Double, ByVal EndLongitude As Double, ByVal EndLatitude As Double, ByVal Type As String) As Double
Dim distance As Double = Math.Abs(3280.839895013 * (6378.7 * (Math.Acos(Math.Cos(StartLatitude / (180 / Math.PI)) * Math.Cos(StartLongitude / (180 / Math.PI)) * Math.Cos(EndLatitude / (180 / Math.PI)) * Math.Cos(EndLongitude / (180 / Math.PI)) + Math.Cos(StartLatitude / (180 / Math.PI)) * Math.Sin(StartLongitude / (180 / Math.PI)) * Math.Cos(EndLatitude / (180 / Math.PI)) * Math.Sin(EndLongitude / (180 / Math.PI)) + Math.Sin(StartLatitude / (180 / Math.PI)) * Math.Sin(EndLatitude / (180 / Math.PI))))))
Return distance
End Function

No comments:

Post a Comment