Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Spheroidal long-lat distance calculation
Message
De
15/02/2007 17:51:07
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:
01196330
Vues:
31
Hi William - or is Bill OK?

>If you're not in a big hurry I can dig out my VFP code for this when I get home on Saturday. I had to do great circle distance and bearing calculations for an RF coordination and engineering package and a whole bunch of RF engineers tested and verified the accuracy..

I'd like to see it. Dragan corrected my parentheses.

>
>>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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform