openhaystack-python
openhaystack-python copied to clipboard
Lat and Long are unpacked incorrectly
Your code in the __decode_tag function does not properly unpack the coordinate data. Your code is not properly handling the sign of, e.g. longitude, so I was getting longitudes >180 where they should be negative instead. I made the below fix that solved my problem.
#current incorrect code
latitude = int.from_bytes(data[0:4], 'big', signed=True) / 10000000.0
longitude = int.from_bytes(data[4:8], 'big', signed=True) / 10000000.0
#correct
latitude = struct.unpack('>i',data[0:4])[0] / 10000000.0
longitude = struct.unpack('>i',data[4:8])[0] / 10000000.0
I know these both look like they should do the same thing, but they apparently do not. I was getting bad data until I updated these lines.