Convert Back Latitude from Hex data GREENTEL

2020-02-11 09:34发布

Currently I am doing a GPS Tracking project based on Django and GREENTEL It uses this protocol http://www.m2msolution.eu/doc/Fejlesztoi_dokumentaciok/GT03/GPRS%20Communication%20Protocol_GT03.pdf

It says how to convert Latitude/ Longitude to Hex.. but I want to convert latitude hex data to the normal form

Conversion method: A Convert the latitude (degrees, minutes) data from GPS module into a new form which represents the value only in minutes; B Multiply the converted value by 30000, and then transform the result to hexadecimal number. For example 22°32.7658′,(22*60+32.7658)*30000 = 40582974,then convert it to hexadecimal number 0x026B3F3E

how to reverse the hex to latitude conversion?

1条回答
We Are One
2楼-- · 2020-02-11 10:13

First you get the hex, convert it back to base 10 and divide it by 30000.

Get the result and divide it by 60, the integer part will be the degrees, the rest will be the minutes.

In python:

a = 0x026B3F3E
b = a/30000.0
degrees = b//60
minutes = b%60

print degrees, ' degrees and ', minutes, 'minutes'
>>> 22.0  degrees and  32.7658 minutes
查看更多
登录 后发表回答