0

I'm looking at the default Android Calendar database calendar.db, and within it are Latitude/Longitude coordinates, but they are stored as integers.

For example, the latitude is stored as 68970387 and the actual latitude it should be is 68.97029043260628 (it's not exact, but it's close enough)

I've been reading all kinds of things about converting from Radians/Degrees, but none of these conversions work, so it appears that this has been rounded down into an integer, but I've never come across this before.

Does anyone have any information on this kind of latitude/longitude storage format?

Thanks

Tony
  • 3,587
  • 8
  • 44
  • 77
  • It's similar to something I've already tried, which was multiplying the int by 1_000_000, but it doesn't seem to be entirely accurate. Thanks – Tony Apr 16 '21 at 14:55
  • What do you mean by entirely accurate? You're obviously losing precision by truncating, so it never would be. – Henry Twist Apr 16 '21 at 14:56
  • Well the value has been truncated, but Android must have some way of recreating the co-ordinate from this int, otherwise why bother storing it. Yes, precision will be lost, so I'm confused as to why do it at all. – Tony Apr 16 '21 at 14:58
  • It would be impossible to recreate it with the same precision. I really think it's just a storage vs usability trade-off. They just don't need the amount of precision to justify using a larger storage format. – Henry Twist Apr 16 '21 at 14:59
  • (but this is very interesting, I have never seen this done before either) – Henry Twist Apr 16 '21 at 15:00
  • Agreed, it is interesting. I'm guessing Android has some kind of calculation it does to the value to convert it to a double, that's still reasonably accurate to the original location. I'm just not sure what that calculation is :) – Tony Apr 16 '21 at 15:02
  • I'm not sure what you mean, surely it would just be dividing it by `1000000`? – Henry Twist Apr 16 '21 at 15:06
  • 1
    1 meter precision is 0,000009 degrees. As GPS are limited in precision this storage precision is enough for mot of phone usage. GPS is about 3-5 meters, Galileo about 1 meter, GLONASS is bader. – Ptit Xav Apr 16 '21 at 15:07
  • Ah well then an integer would me *more* than enough! – Henry Twist Apr 16 '21 at 15:10
  • 1
    Seems that it's as simple as that then, thanks for the info y'all! – Tony Apr 16 '21 at 15:11

1 Answers1

0

I think you can convert lat\lng to other formats (such as Lambert) and then multiplying it to a number with count of float numbers to convert it to an integer