Last active
December 23, 2015 09:19
-
-
Save cwacek/6613735 to your computer and use it in GitHub Desktop.
Decode SAFEST Coordinate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c = "0302A3DC4081535367C002B9D21D0E7379408F39625AD67A70400000000000000000D43E85729743E63F" | |
import struct | |
decoded = c.decode('hex') | |
dim, vartype = struct.unpack('=bb', decoded[:2]) | |
fmt = 'f' if vartype == 1 else 'd' | |
fmtsz = 4 if fmt == 'f' else 8 | |
coords = struct.unpack_from('{0}{1}'.format(dim, fmt), | |
decoded[2:]) | |
height, error = struct.unpack_from('{0}{1}'.format(2, fmt), | |
decoded[2:], dim * fmtsz) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment