3

这个问题来自给我的家庭作业。您可以使用以下三种格式之一建立您的存储系统:

DD MM SS.S

嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯嗯

DD.DDDDD

您希望通过使用尽可能少的字节来最大化可以存储的数据量。

我的解决方案基于第一种格式。我用 3 个字节表示纬度:8 位用于 DD(-90 到 90),6 位用于 MM(0-59),10 位用于 SS.S(0-59.9)。然后我使用 25 位作为经度:9 位用于 DDD(-180 到 180),6 位用于 MM,10 位用于 SS.S。这个解决方案不太适合字节边界,但我认为下一个读数可以立即存储在前一个读数之后,8 个读数仅使用 49 个字节。

我很好奇其他人可以提出什么方法。有没有更有效的方法来存储这些数据?作为说明,我考虑了基于偏移的存储,但问题没有表明读数之间的值可能会发生多少变化,所以我假设任何变化都是可能的。

4

3 回答 3

2

您建议的方法不是最佳的。您正在使用 10 位(1024 个可能的值)来存储范围(0..599)中的值。这是浪费空间。

如果您将使用 3 个字节作为纬度,则应将范围 [0, 2^24-1] 映射到范围 [-90, 90]。因此,每个 2^24 值代表 180/2^24 度,即 0.086 秒。

如果您只需要 0.1 秒的精度,则纬度需要 23 位,经度需要 24 位(您将获得 0.077 秒的精度)。那是 47 位而不是 49 位,准确度更高。

我们还能做得更好吗?

0.1 秒精度所需的确切位数是 log2(180*60*60*10 * 360*60*60*10) < 46.256。这意味着您可以使用 46256 位(5782 字节)来存储 1000 个(纬度,经度)对,但所涉及的数学运算需要处理非常大的整数。

我们还能做得更好吗?

这取决于。如果您的数据集具有浓度,您可以只存储一些点以及与这些点的相对距离,使用较少的位。应该使用聚类算法。

于 2011-02-18T20:15:12.620 回答
1

Sticking to existing technology:

If you used half precision floating point numbers to store only the DD.DDDDD data, you can be a lot more space-efficent, but you'd have to accept an exponent bias of 15, which means: The coordinates stored might not be exact, but at an offset from the original value.

This is due to the way floating point numbers are stored, essentially: A normalized significant is multiplied by an exponent to result in a number, instead of just storing a single value (as in integer numbers, the way you calculated the numbers for your solution).

The next highest commonly used floating point number mechanism uses 32 bits (the type "float" in many programming languages) - still efficient, but larger than your custom format.

If, however, you would design your own custom floating point type as well, and you gradually added more bits, your results would become more exact and it would STILL be more efficient than the solution you first found. Just play around with the number of bits used for significant and exponent, and find out how close your fp approximations come to the desired result in degrees!

于 2011-02-08T11:57:29.530 回答
0

好吧,如果这是为了大量读数,那么您可以尝试差分方法。从绝对位置开始,然后开始保存增量更改,理想情况下,这应该需要更少的位,具体取决于更改的性质。这有效地压缩了流。但不知何故,我不认为这就是这个家庭作业的目的。

于 2011-02-18T21:10:55.857 回答