pythongpscoordinatesgistracker

Convert Integer to Lat long geo position


I have python script that tracks teltonika GPS tracker. GPS data are parsed to integer like 514511623, 2201796 so devision to 10000000 gives me lat, long. But when tracker passed London coordinates are coming like this 516631273, 4293416810 so devision give me wrong longitude. Any idea how to convert it properly


Solution

  • I am not familiar with teltonika GPS tracker. But it seems that the longitude number you are getting has something to do with negative integer. The location is very close to Greenwich where longitude is 0. At the beginning it was 0.22... longitude. Then, it went to negative longitude area. But the GPS receiver only deals with positive integer number. Assuming it uses 32 bit unsigned integer, the max inter is 2**32 = 4294967296 If you subtract that number from 4293416810

    4293416810 - 4294967296 = -1550486
    -1550486/1e7 = -0.1550486 longitude
    

    So the longitude has changed from 0.2201796 to -0.1550486 when you get closer to Greenwich.