Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Spheroidal long-lat distance calculation
Message
De
17/02/2007 08:10:52
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
16/02/2007 20:01:30
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
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:
01196804
Vues:
21
>>>>>>
>>>>>>The formula is unnamed, but is indicated as being the most accurate.
>>>>>>
>>>>>This one looks simplier (from Fox2x samples):
>>>>
>>>>Simpler isn't always better. "Samples" are seldom the best practice.
>>>>
>>>>The wikipedia page says the third formula is the most accurate and that the others have large rounding errors at close distances.
>>>>
>>>>Thanks
>>>
>>>Wikipedia says:) Did you really see that rounding error?
>>
>>Cetin. You are trusting that the fox2x sample is correct? Do you know it is?
>>
>>I just went here: http://www.acscdg.com/
>>
>>It's got a weird UI, Set it to miles. Enter my address: 120 parsell square toronto M1B 2A6 click find. The point will appear. Click start a course. Click on the point and an X appears and it is listed as point 0 in the left.
>>
>>Now enter 16 william kitchen blvd M1P 2B7 and click find. This second point appears. Click on this point and a new X appears. It will be listed as point 1. The distance is shown as 3.7 miles. Click end at last point.
>>
>>The formula Naomi referred to and you provided in message #1052327 should have converted degrees to radians. I almost dismissed it because I can tell you from personal experience 16 William Kitchen Blvd is not 271 miles from my house. :)
>>
>>I see in the one you just provided you converted degrees to radians. The two formulae are producing the same results for these pairs (my address and 125 parsell) 43.797283,-79.214771,43.797293,-79.214723 with SET DECIMALS TO 10
>>
>>According to both calculations the distance is .004 miles or 21 feet. The two addresses are approximately 100 feet apart.
>>
>>Unfortunately I cannot obtain known examples of long/lat pairs with higher precision than those.
>
>It's already converted to radians in the formula. Where did 271 miles came from?

The message #1052327 does not convert to radians.


>
>I checked that site and right the distance is 3.7 miles after roundation and something like 3.68.... with the formula I sent. The difference is due to that sites' great circle diameter IMHO. In miles I had 3978. However with kilometers our results are near (formula 5.8980... and site 5.9). That site is using D M S system and I think you're mixing it with decimal degrees (it is not radians - you still need to convert to radians). If you're talking on a lat/lon system with values like 43.4613 then it's decimals.
>
>I'm not exact on feet to metrics conversion but the lat/lon pair you provided is approximately 4 meters apart (13-14 feets). The formula I provided is using kilometers for the great circle. It's different according to sources and you can find values such as 6372.795, 6278 etc or 3978 miles.

>If you do the calculation using pen/paper and phytagorian theorem then you would see that it really matches what that formula returns (4 meters) not 100 feet (it's about 30-32 meters, right? something impossible for earth with those lat/lon). You're trusting to a map service I think but most of the satellite resolutions published are 30m (Landsat TM were 30 and 7.5 as I remember). AVHRR are worse with 900m resolution. Ikonos and alike have 1m resolution. Earthlink provides 15cm resolution data for NY area.

I'm saying the calculations are returning 20 feet, but the other house is approximately 100 feet away.

>
>PS: Here is supporting converter:
>
>? GeoDist(d2d(43.4618),d2d(-79.1645),d2d(43.4750),d2d(-79.1253))
>
>FUNCTION D2D(tnDegrees)
>  return INT(m.tnDegrees) + ;
>    (INT(ntom(m.tnDegrees)*100)%100 * 60 + ;
>    ntom(m.tnDegrees)*10000%100)/3600
>
>Function GeoDist
>  parameters lat1,lng1,lat2,lng2
>  *
>  * Degrees to radian
>  *
>  lat1 = Dtor(lat1)
>  lat2 = Dtor(lat2)
>  lng1 = Dtor(lng1)
>  lng2 = Dtor(lng2)
>
>*  return 6372.795 * acos(sin(lat1) * sin(lat2) +;
>    cos(lat1) * cos(lat2) * cos(lng2 - lng1)) && kilometers
>  return 3978 * acos(sin(lat1) * sin(lat2) +;
>    cos(lat1) * cos(lat2) * cos(lng2 - lng1)) && miles - 3978 off the top of my head
>
Thanks for that.

>PS: Iim trusting that calculation because I also do GPS interface (both nondifferential and differential) and it always matched the results (it should be trustable I guided a plane for aerial photography using VFP+GPS - even in a larger scale when I used it to test GPS NMEA logging I could draw my car's path from home to work parking lot, well in parking lot it looked like it made an error less then a meter).
>Cetin

I'm worried about distances of a meter and less.

Thanks
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform