Skip to content

Commit

Permalink
update gps20 protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
yeahugo committed Apr 14, 2015
1 parent ea68153 commit b2c6582
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions adapter/gps20.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,24 @@ def decode(cls,datastring):

re_location = '^(\d+)(\d{2}\.\d+)$'
(h, m) = re.match(re_location, latitude).groups()
h = float(h)
m = float(m)
latitude = h + m/60
latitude = float(h) + float(m)/60
if 'S' == latitude_hemisphere:
latitude = -latitude

(h, m) = re.match(re_location, longitude).groups()
h = float(h)
m = float(m)
longitude = h + m/60
longitude = float(h) + float(m)/60
if 'W' == longitude_hemisphere:
longitude = -longitude

message.latitude = latitude
message.longitude = longitude
return message
else:
return None

@classmethod
def response_to(cls, message):
if not message:
return
elif config.MESSAGE_TYPE_LOCATION_FULL == message.message_type:
return

0 comments on commit b2c6582

Please sign in to comment.