-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.py
66 lines (57 loc) · 1.43 KB
/
functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import datetime
columns = {
'RMC': ['Date', 'Time', 'X', 'Y',
'Latitude', 'Longitude'],
'VTG': ['Heading', 'Knots', 'M/H', 'KM/H'],
'GGA': ['Altitude (m)', 'Altitude (ft)'],
'GLL': ['Valid?']
}
def RMCData(msg):
'''
Date, Time, X, Y, Latitude, Longitude
Brasilia Time (BRT), UTC -3
'''
try:
UTC = datetime.datetime.combine(msg.datestamp, msg.timestamp)
BR = UTC - datetime.timedelta(hours=3)
return [BR.date().isoformat(), BR.time().isoformat(), msg.longitude,
msg.latitude, msg.latitude, msg.longitude]
except:
return ['', '', msg.longitude, msg.latitude, msg.latitude, msg.longitude]
def VTGData(msg):
'''
Heading, Knots, M/H, KM/H
'''
try:
knot = float(msg.spd_over_grnd_kts)
knot2mh = 1.15078
miles = knot2mh * knot
heading = msg.true_track
kmhr = msg.spd_over_grnd_kmph
return [heading, knot, miles, kmhr]
except:
return ['', '', '', '']
def GGAData(msg):
'''
Altitude (m), Altitude (ft)
'''
meter2feet = 3.28084
try:
feet = meter2feet * msg.altitude
return [msg.altitude, feet]
except:
return ['', '']
def GLLData(msg):
'''
Valid?
'''
status = False
if msg.status == 'A':
status = True
return [status]
functions = {
'RMC': RMCData,
'VTG': VTGData,
'GGA': GGAData,
'GLL': GLLData,
}