PPRuNe Forums - View Single Post - Track Changes
Thread: Track Changes
View Single Post
Old 29th February 2008 | 15:58
  #8 (permalink)  
ppppilot
 
Joined: Dec 2007
Posts: 256
Likes: 0
From: Over the clouds
Hi Yflex.
I have developed a program for Visual Basic that take data from GPS and calculates the distance and the ETA. Use this code if that helps you. You must only write the correct coordinates in the same format they are written now and will give you distances on WPTDIS value.

WPT1=”010203N0040506W”
WPT2=”020304N0050607W”
LatWpt1 = (Val(Left(WPT1, 2)) * 3600) + (Val(Mid(WPT1, 3, 2)) * 60)
LatWpt1 = LatWpt1 + Val(Mid(WPT1, 6, 2))
LatWpt1 = LatWpt1 / 206265
If Mid(WPT1, 7, 1) = "S" Then LatWpt1 = 0 – LatWpt1
LonWpt1 = (Val(Mid(WPT1,8,3)) * 3600) + (Val(Mid(WPT1, 11, 2)) * 60)
LonWpt1 = LonWpt1 + Val(Mid(WPT1, 13, 2))
LonWpt1 = LonWpt1 / 206265
If Right(WPT1, 1) = "E" Then LonWpt1 = 0 - LonWpt1

LatWpt2 = (Val(Left(WPT2, 2)) * 3600) + (Val(Mid(WPT2, 3, 2)) * 60)
LatWpt2 = LatWpt2 + Val(Mid(WPT2, 6, 2))
LatWpt2 = LatWpt2 / 206265
If Mid(WPT2, 7, 1) = "S" Then LatWpt2 = 0 – LatWpt2
LonWpt2 = (Val(Mid(WPT2,8,3)) * 3600) + (Val(Mid(WPT2, 11, 2)) * 60)
LonWpt2 = LonWpt2 + Val(Mid(WPT2, 13, 2))
LonWpt2 = LonWpt2 / 206265
If Right(WPT2, 1) = "E" Then LonWpt2 = 0 – LonWpt2

WptDis = Sqr((Sin((LatWpt1 - LatWpt2) / 2)) ^ 2 + Cos(LatWpt1) * Cos(LatWpt2) * (Sin((LonWpt1 – LonWpt2) / 2)) ^ 2)
WptDis = 2 * (Atn(WptDis / Sqr(-WptDis * WptDis + 1)))
WptDis = WptDis * 3437.7475
WptDis = Round(WptDis, 2)

Tailwinds
ppppilot is offline  
Reply