Last active
March 10, 2016 20:26
-
-
Save lealhugui/128d978fe7112ca93b34 to your computer and use it in GitHub Desktop.
This file contains 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
lat_slice = dict() | |
lat_slice["p1"] = (52,54) | |
lat_slice["p2"] = (52,54) | |
lat_slice["p3"] = (52,54) | |
lon_slice = dict() | |
lon_slice["p1"] = (60,62) | |
lon_slice["p2"] = (62,64) | |
lon_slice["p3"] = (64,66) | |
def translate_coordinate(data, degree_bin, degree_slice, **kwargs): | |
format_degree_mask = kwargs.get("format_degree_mask","{0}{1}") | |
format_min_mask = kwargs.get("format_min_mask", "{0}.{1}{2}") | |
signal = kwargs.get("lat_signal", "") | |
degrees = int(degree_bin[1:8], 2) | |
if degrees[:1] == "1": | |
lat_signal = "-" | |
l_min = format_min_mask.format( | |
str(int(str(data[degree_slice["p1"](0)]:degree_slice["p1"](1)], 'UTF8'), 16)).zfill(2), | |
str(int(str(data[degree_slice["p2"](0):degree_slice["p2"](1)], 'UTF8'), 16)).zfill(2), | |
str(int(str(data[degree_slice["p3"](0):degree_slice["p1"](1)], 'UTF8'), 16)).zfill(2) | |
) | |
result = format_degree_mask.format( | |
signal, | |
str((degrees + (float(l_min) / 60))) | |
) | |
return result | |
# Uso: | |
d="002967317985401300001021400010c1400002004114190aff9e004354b3092545002d00000a0310ec" | |
latitude = translate_coordinate(d, Helpers.hexToBinary(d[50:52]), lat_slice) | |
longitude = translate_coordinate(d, Helpers.hexToBinary(d[58:60]), lon_slice) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment