I am building a geolocation based app and i want to know which data type is best for storing lat/long i am using doubleValue but i think we can be more precise like 10 decimal places .
我正在构建一个基于地理定位的应用程序,我想知道哪种数据类型最适合存储lat/long,我使用的是doubleValue,但我认为我们可以更精确,比如10位小数。
4 个解决方案
#1
12
double
is the value used by the iOS itself. iOS uses CLLocationDegrees
to represent lat/long values which is a typedef of double.
double是iOS本身使用的值。iOS使用CLLocationDegrees来表示lat/long值,这是double类型的类型定义。
IMO, using double
/CLLocationDegrees
would be the best choice.
IMO,使用双/CLLocationDegrees是最好的选择。
#2
5
Looking at the definition of CLLocationCoordinate2D:
看CLLocationCoordinate2D的定义:
typedef struct {
CLLocationDegrees latitude;
CLLocationDegrees longitude;
}
CLLocationCoordinate2D;
and then the location of CLLocationDegrees;
然后是CLLocationDegrees的位置;
typedef double CLLocationDegrees;
we can see that the precision is given as double. Thus, you can't make it better than that.
我们可以看出精度是双倍的。因此,你不能让它变得更好。
#3
3
There's already an answer to that in the iOS SDK :)
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!
看一下CLLocationCoordinate2D -它是由CoreLocation用来存储它的lat/lngs使用CLLocationDegrees类型。如果那是准确的CoreLocation给你那是一个accuarate,它将会得到!
#4
2
No it will not, because the lat/long iOS
will use is also a double.
不,它不会,因为lat/long的iOS将使用的也是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;
#1
12
double
is the value used by the iOS itself. iOS uses CLLocationDegrees
to represent lat/long values which is a typedef of double.
double是iOS本身使用的值。iOS使用CLLocationDegrees来表示lat/long值,这是double类型的类型定义。
IMO, using double
/CLLocationDegrees
would be the best choice.
IMO,使用双/CLLocationDegrees是最好的选择。
#2
5
Looking at the definition of CLLocationCoordinate2D:
看CLLocationCoordinate2D的定义:
typedef struct {
CLLocationDegrees latitude;
CLLocationDegrees longitude;
}
CLLocationCoordinate2D;
and then the location of CLLocationDegrees;
然后是CLLocationDegrees的位置;
typedef double CLLocationDegrees;
we can see that the precision is given as double. Thus, you can't make it better than that.
我们可以看出精度是双倍的。因此,你不能让它变得更好。
#3
3
There's already an answer to that in the iOS SDK :)
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!
看一下CLLocationCoordinate2D -它是由CoreLocation用来存储它的lat/lngs使用CLLocationDegrees类型。如果那是准确的CoreLocation给你那是一个accuarate,它将会得到!
#4
2
No it will not, because the lat/long iOS
will use is also a double.
不,它不会,因为lat/long的iOS将使用的也是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;