Convert Back Latitude from Hex data GREENTEL

瘦欲@ 提交于 2019-12-18 05:20:49

问题


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:


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


来源:https://stackoverflow.com/questions/7151896/convert-back-latitude-from-hex-data-greentel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!