开发者

What is the best and most precise data type for storing latitude longitude in iphone xcode?

I am building a geolocation based app and i want to know which data type is best for storing lat/long i am开发者_StackOverflow社区 using doubleValue but i think we can be more precise like 10 decimal places .


double is the value used by the iOS itself. iOS uses CLLocationDegrees to represent lat/long values which is a typedef of double.

IMO, using double/CLLocationDegrees would be the best choice.


Looking at the definition of CLLocationCoordinate2D:

typedef struct {
    CLLocationDegrees latitude;
    CLLocationDegrees longitude;
} 
CLLocationCoordinate2D;

and then the location of CLLocationDegrees;

typedef double CLLocationDegrees;

we can see that the precision is given as double. Thus, you can't make it better than that.


There's already an answer to that in the iOS SDK :)

Take a look at CLLocationCoordinate2D - it's used by CoreLocation to store it's lat/lngs using the CLLocationDegrees type. If that's the accuracy CoreLocation gives you then that's a accuarate as it's going to get!


No it will not, because the lat/long iOS will use is also a double.

/*
 *  CLLocationDegrees
 *  
 *  Discussion:
 *    Type used to represent a latitude or longitude coordinate in degrees under the WGS 84 reference
 *    frame. The degree can be positive (North and East) or negative (South and West).  
 */
typedef double CLLocationDegrees;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜