Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Spheroidal long-lat distance calculation
Message
De
15/02/2007 17:43:47
Mike Yearwood
Toronto, Ontario, Canada
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01196313
Message ID:
01196328
Vues:
12
>May be the old discussion can help a little
>Re: Distance calculation by lattitude/longitude Thread #1052304 Message #1052330

Nope. Cetin referenced the FoxPro 2.x developer's guide and Neil McDonald both reference a formula which, according to the wikipedia page, is the least accurate. I'll keep it around IAC. Another mentioned decoding GPS satellite data.

>
>>Hey all
>>
>>I've been trying to use the third formula on this page:
>>
>>http://en.wikipedia.org/wiki/Great-circle_distance
>>
>>The formula is unnamed, but is indicated as being the most accurate.
>>
>>My trig is pretty rusty, and I don't think I ever did it on a sphere. :)
>>
>>I'm plugging in the sample lat-long for BNA and LAX and I'm not getting the same results.
>>
>>I've converted everything to radians. They name a formula in the "worked example" but that name is not referenced elsewhere on the page, so I'm not even sure which formula they're trying to demonstrate.
>>
>>Can anyone show me what I'm missing?
>>
>>Thanks!
>>
>>
CLEAR
>>SET DECIMALS TO 5
>>
>>m.lat1 = 36.12
>>m.long1 = -86.67
>>?"lat1",m.lat1,"long1",m.long1
>>
>>m.lat2 = 33.94
>>m.long2 = -118.40
>>?"lat2",m.lat2,"long2",m.long2
>>
>>m.DeltaSigma = MyDistance(m.lat1,m.long1,m.lat2,m.long2)
>>
>>?"delta-sigma",m.DeltaSigma
>>
>>m.Dist = m.DeltaSigma * 6372.795
>>?m.Dist
>>RETURN
>>
>>
>>FUNCTION myDistance
>>LPARAMETERS m.lat1, m.long1, m.lat2, m.long2
>>LOCAL m.rlat1, m.rlong1, m.rlat2, m.rlong2
>>
>>m.rlat1 = DTOR(m.lat1)
>>m.rlong1 = DTOR(m.long1)
>>?"rlat1",m.rlat1,"rlong1",m.rlong1
>>
>>m.rlat2 = DTOR(m.lat2)
>>m.rlong2 = DTOR(m.long2)
>>?"rlat2",m.rlat2,"rlong2",m.rlong2
>>
>>m.DeltaLong = m.long2 - m.long1
>>
>>m.rDeltaLong = DTOR(m.DeltaLong)
>>
>>m.DeltaSigma = ;
>>  atan( ;
>>    SQRT(;
>>      (COS(m.rlat2) * SIN(m.rDeltaLong))^2 + ;
>>      (COS(m.rlat1) * SIN(m.rlat2) - SIN(m.rlat1) * COS(m.rlat2) * COS(m.rDeltaLong))^2;
>>    ) ;
>>    / ;
>>      (SIN(m.rlat1) * SIN(m.rlat2)) + (COS(m.rlat1) * COS(m.rlat2) * COS(m.rDeltaLong)) ;
>>  )
>>
>>return m.DeltaSigma
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform