Where to save Android GPS (Latitude , Longitude) points?

后端 未结 5 787
一生所求
一生所求 2020-12-05 10:59

On onLocationChanged event I want to save my GPS route (Latitude , Longitude). Later I want to load this data and draw the route.

Who is the best way to do this, by

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 11:57

    Think about the precision (not accuracy) you need to represent the data. Would a couple inches be close enough? Most handheld GPS receivers are lucky to be good to a couple meters. One degree-second of longitude at the equator moves you about 100 feet. If you use a signed 32-bit integer to represent your latitudes and longitudes, LatE6 & LonE6, you could store the largest longitude there is as +/-180,000,000 and the least significant digit is:

    (1 / 1E6) * (3600 sec/deg) * (100 feet/sec) = 0.36 feet or 4 inches.

    I've got to imagine my Garmin uses something like this, not a float with only 24 bits of precision and certainly not a 64 bit double. Conversion between integer and the double shouldn't cost much. You could even pack a lat/lon pair into a long.

提交回复
热议问题