openhaystack-python icon indicating copy to clipboard operation
openhaystack-python copied to clipboard

Lat and Long are unpacked incorrectly

Open que5o opened this issue 4 years ago • 0 comments

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.

que5o avatar Jan 04 '22 23:01 que5o