proper/best type for storing latitude and longitude

前端 未结 13 807
天涯浪人
天涯浪人 2020-12-07 11:21

In a system level programming language like C, C++ or D, what is the best type/encoding for storing latitude and longitude?

The options I see are:

  • IEEE
13条回答
  •  失恋的感觉
    2020-12-07 11:51

    http://www.esri.com/news/arcuser/0400/wdside.html
    At the equator, an arc-second of longitude approximately equals an arc-second of latitude, which is 1/60th of a nautical mile (or 101.27 feet or 30.87 meters).

    32-bit float contains 23 explicit bits of data.
    180 * 3600 requires log2(648000) = 19.305634287546711769425914064259 bits of data. Note that sign bit is stored separately and therefore we need to amount only for 180 degrees.
    After subtracting from 23 the bits for log2(648000) we have remaining extra 3.694365712453288230574085935741 bits for sub-second data.
    That is 2 ^ 3.694365712453288230574085935741 = 12.945382716049382716049382716053 parts per second.
    Therefore a float data type can have 30.87 / 12.945382716049382716049382716053 ~= 2.38 meters precision at equator.

提交回复
热议问题