Question

I'm trying to store GPS data in a Sqlite database. I retrieve the data from a KML file via DDMS and I store it in a GeoPoint this way:

GeoPoint p = new GeoPoint(latitude,longitude)

The problem is that GeoPoint() accepts lon and lat only as int, as it is not defined for double format. Now if I have 45.3242355 as longitude this is stored in Sqlite as int-453242355. And I want to use this to draw a line on the map between geopoints, but I can as this format of integer is out from tje range of latitude and longitude. Can someone tell me how should I proceed to get my real format data back?

Was it helpful?

Solution

Multiply it by 10^-6 (1e-6) (and to convert from a double to their integer format, multiply by 10^6 (1e6)). The integer format used by GeoPoint isn't losing data, it's just in microdegrees instead of degrees, as specified by the documentation.

(This is similar to the way a currency field might store a value of $2.36 as "236" to simplify arithmetic and avoid expensive float math and FP errors).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top