4

I am trying to store lattitude and longtitude (which is produced by Drawing API) in the mysql database as a spatial datatype. Spatial Datatype supports 15 digit precision in mysql.

According to my usecase, I have to store the exact digit precision in the database. So I need a clarification whether google maps drawing API v3 will produce more than 15 digit precision ? ( I have seen it once with 16 digit precision, After that I am not getting it anymore). Any help is much appreciated.

ArunRaj
  • 1,780
  • 2
  • 26
  • 48
  • Why don't you control lat-lng values before writing to database(I mean in your php-asp.net-java or js or whatever you use) and trim them if they have length more than 15? – alpakyol Mar 17 '14 at 07:56
  • @user3280126 : That would be a poor option in my case. I need exact lattitude and longtitude of each shape which was drawn by user (ITx my usecase). **That is why I want to know the maximum digit precision returned by Google Maps API v3.** If google maps API exceeds 15 digits, I am going to drop spatial datatype. – ArunRaj Mar 17 '14 at 09:01
  • 2
    Then I suggest you to look http://stackoverflow.com/questions/15965166/what-is-the-maximum-length-of-latitude-and-longitude . There is not much information about it, but what I understand is, 15 digit should be enough for accurate information(I don't know your case and extreme cases may need more than 15 digit for sure). – alpakyol Mar 17 '14 at 09:11

1 Answers1

23

There is a difference between "number of digits used to represent a value" and the "number of meaningful digits used to represent a value".

No matter what you use to determine a location of a point on earth, there will be inaccuracies associated with your method. For GPS you are lucky to get 1 m - or a few cm if you use special correction methods.

Since the circumference of the earth is 40,000 km and 360 degrees, one degree (at the equator) corresponds to 111 km; so when you have 0.000 001 degree, you are down to 11 cm. In other words, 3 + 6 digits (in degrees) is about as accurate as you ever ought to care about.

Going to 15 digit (3 + 12) means you are down in the sub-micron range. Do you really care?

As an aside, a double can store about 15 digits of precision (53 bits of significand). So your question is right on the limit of what numbers can typically be represented by computers without taking special precautions. And when you start doing any kinds of calculations on numbers like that you will very quickly lose some precision in the least significant digits.

Floris
  • 45,857
  • 6
  • 70
  • 122