Alex Rivera | Logout

Problem Storing Latitude and Longitude values in MySQL database

Asked 2011-05-31T13:17:39.703
17

I want to store the values of latitude and longitude fetched from Google Maps GeoCoding API in a MySQL database. The values are in float format.

12.9274529

77.5905970

And when I want to store it in database (which is datatype float) it rounds up float and store it in following format:

12.9275

77.5906

Am I using the wrong datatype? If yes then what datatype should I be using to store latitude and longitude values?

Update :

here is the CREATE TABLE as requestted by Allin

CREATE TABLE `properties` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(100) NOT NULL,
  `description` text,
  `latitude` float DEFAULT NULL,
  `longitude` float DEFAULT NULL,
  `landmark` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `serial` (`serial`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
Edit
Report

3 Answers

8
answered 2011-05-31T14:03:24.410
2

The optimal setup in my experience is DOUBLE(11,8), keep in mind that lat/lng could be > 99

answered 2012-05-15T09:21:04.370
0

Decimal (10,8) is more than enough. Some GPS devices provide more accurate position.

answered 2011-05-31T13:25:23.013

Your Answer