如何计算GPS数据

How to compute GPS data?

本文关键字:GPS 数据 计算 何计算      更新时间:2023-10-16

我需要使用以下信息计算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)的值。基于信息,我如何计算纬度并转换为Mantissa(7位)和指数(19位)部分。另外,标志位怎么样?例如,值87.45需要以87存储到7位的方式存储,其中19位存储了值45。

2)类似的经度值可以为 -180,需要8位才能根据信息来适应180(2 ^8)的值) 部分。另外,标志位怎么样?

例如,值130.50需要以130存储到8位的方式存储,其中18位存储该值50。

我认为您在看这个错误的……您的身份为52位值,其中包含LAT和LON作为整数值,对吗?不用担心曼蒂萨(Mantissa)。您需要将输入的两个部分视为单独的整数,然后将每个部分除以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