How would you most effectively store latitude and longitude data?

This question comes from the homework that I have been given. You can place your storage system in one of the following three formats:

DD MM SS.S

DD MM.MMM

DD.DDDDD

You want to maximize the amount of data that you can save using as few bytes as possible.

My decision is based on the first format. I used 3 bytes for latitude: 8 bits for DD (-90 to 90), 6 bits for MM (0-59) and 10 bits for SS.S (0-59.9). Then I used 25 bits for longitude: 9 bits for DDD (-180 to 180), 6 bits for MM and 10 for SS.S. This solution does not fit perfectly on the byte boundary, but I decided that the next read can be saved immediately after the previous one, and 8 reads will only use 49 bytes.

I am curious what methods others may come up with. Is there a more efficient way to store this data? As a note, I looked at the store based on the offset, but the problem did not indicate how much the values ​​can change between readings, so I assume that any changes are possible.

+3
source share
3 answers

Your suggested method is not optimal. You use 10 bits (1024 possible values) to store a value in the range (0..599). This is a waste of space.

If you use 3 bytes for latitude, you must map the range [0, 2 ^ 24-1] to the range [-90, 90]. Therefore, each of the 2 ^ 24 values ​​is 180/2 ^ 24 degrees, which is 0.086 seconds.

0,1- , 23 24 ( 0,077 ). 47 49 .

?

, 0,1 , log2 (180 * 60 * 60 * 10 * 360 * 60 * 60 * 10) 46,256. , 46256 (5782 ) 1000 (lat, lon) , .

?

. , , . .

+2

:

DD.DDDDD, , 15, : , .

, , : , , , ( , ).

32 ( "float" ) - - , , .

, , , , , , , . , , , fp !

+1

, , . , , , . . - , .

0

Source: https://habr.com/ru/post/1790628/


All Articles