3

Lately I've noticed some of the resources (sample applications, blogs, and websites) I use for GPS / GIS stuff store the latitude and longitude as integers rather than decimal or string. I understand why a formatted string is not the preferred way to store lat / lon. But why not store the value as a decimal? Is there any advantage to storing as an integer and later dividing by 1,000,000 to get the actual decimal value?

DenaliHardtail
  • 27,362
  • 56
  • 154
  • 233
  • see related question http://stackoverflow.com/questions/1370170/database-sql-how-to-store-longitude-latitude-data – zellus Nov 06 '10 at 16:16

1 Answers1

2

Possibly. An integer requires only four bytes of storage. An IEEE double precision floating point number is 8 bytes. So storing a lat / lon as an integer would halve the memory requirement.

Jim Mischel
  • 131,090
  • 20
  • 188
  • 351
  • I changed my lat/lon columns from float(10,6) to int(4) after multiplying all of them by 1000000. However, on a table with 100k rows, I see the storage size (without index) has INCREASED by about 5%. How is this possible? I've reloaded the table, flushed it, etc. – kouton Mar 10 '14 at 03:20
  • 2
    @Reddox: You'll need to post a question. Show your before and after representations, and perhaps somebody will have an answer. – Jim Mischel Mar 10 '14 at 03:35