Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 using doubleValue but i think we can be more precise like 10 decimal places .

like image 521
IphoneBites Avatar asked Sep 01 '11 12:09

IphoneBites


People also ask

What data type should I use for latitude and longitude?

precision you should use DECIMAL . Latitudes range from -90 to +90 (degrees), so DECIMAL(10,8) is ok for that, but longitudes range from -180 to +180 (degrees) so you need DECIMAL(11,8) .

Which of the following is the best data type to store latitude and longitude coordinates that are in decimal degrees?

The most precise available option is DOUBLE . The most common seen type used is DECIMAL(8,6)/(9,6) .

How do you store latitude and longitude in a database?

Storing Latitude & Longitude data as Floats or Decimal This is one of the most fundamental ways of storing geocoordinate data. Latitude & longitude values can be represented & stored in a SQL database using decimal points (Decimal degrees) rather than degrees (or Degrees Minutes Seconds).

What data type is GPS coordinates?

Most GPS devices provide coordinates in the Degrees, Minutes and Seconds (DMS) format, or most commonly the Decimal Degrees (DD) format. The popular Google Maps provides their coordinates in both DMS and DD formats.


2 Answers

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.

like image 197
EmptyStack Avatar answered Oct 06 '22 20:10

EmptyStack


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.

like image 25
James Webster Avatar answered Oct 06 '22 19:10

James Webster