2016-11-27 90 views
-1

我需要使用提供的以下信息来计算GPS数据。如何计算GPS数据?

Bits  size description 
Bits 0-25 26 Latitude Location latitude Latitude as 26-bit integer * 100,000 
Bits 26-51 26 Longitude Location longitude Longitude as 26-bit integer * 100,000 

基于上述信息,我明白 1)纬度值可以是+ -90.xxxxxx即它需要7个比特,以容纳90(2^7)的值。根据这些信息,我如何计算纬度并将其转换为尾数(7位)和指数(19位)部分。另外,标志位怎么样?例如值87.45需要以87的方式存储到7位,其中19位存储值45.

2)类似的经度值可以是+ -180,这需要8位来容纳基于该信息的180(2^8)如何计算经度并将其转换为尾数(8位)和指数(18位)部分。另外,标志位怎么样?

例如值130.50需要被存储在130被存储到8位,其中18位存储值50

回答

1

我认为你正在寻找这种错误的方式...你是给定一个包含lat和lon作为整数值的52位值,对吗?不要担心尾数。您需要将输入的两个部分看作单独的整数,并将每个部分除以100,000以获得度数。

试着这么做:

#include <stdint.h> 
int main() { 
    int64_t input = yourGpsVal(); 
    // note: lat/lon may be the wrong way round 
    // strip off the rightmost 26 bits and convert to double 
    double lat = (input >> 26)/100000.; 
    // zero the bits left of the rightmost 26 and convert to double 
    double lon = (input % (1 << 26))/100000.; 
} 

看一看这个演示上Wandbox。 http://melpon.org/wandbox/permlink/xtiDOfMKH0wK5LIC