views:

50

answers:

2

hi ,

in my application i am collecting latitude and longitude when user dialed call or receive call at that time i am calling one function with NSTimer with delay of 15sec , and again i am collecting latitude and longitude.

the problem is that while i am calculating distance between them it give minimum distance 0.87 miles or 1 miles even if i am not moving i used following formula

double    distance = (sin(gpslatitudeOld/57.2958) * sin(gpslatitudeNew/57.2958)) + (cos(gpslatitudeOld/57.2958) * cos(gpslatitudeNew/57.2958) * cos(gpslongitudeNew/57.2958 - gpslongitudeOld/57.2958));

from site (http://www.meridianworlddata.com/Distance-Calculation.asp)

i also used

[newLocation getDistanceFrom:startingPoint]

but still not getting other result , in one forum i read that there will be up down of 1mile in two latitude and longitude. so is there any solution fro that ???

A: 

The earth is not a perfect sphere, so doing simple trigonometry is going to get you large errors. I believe the problem is that it is actually rather flat at the poles, and kinda bulging in the middle (a lot of us get that problem as we age...)

The typical model that I've seen used to account for this is WSG-84. It is possible your platform already has a library to deal with this though.

T.E.D.
+1  A: 

Try the aviation formulary website. http://williams.best.vwh.net/avform.htm

There are formulas there to compensate for the roundness of the earth when calculating large distances.

TomH