forked from HVelosoETI/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rmc.go
45 lines (42 loc) · 1.14 KB
/
rmc.go
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
package nmea
const (
// TypeRMC type for RMC sentences
TypeRMC = "RMC"
// ValidRMC character
ValidRMC = "A"
// InvalidRMC character
InvalidRMC = "V"
)
// RMC is the Recommended Minimum Specific GNSS data.
// http://aprs.gids.nl/nmea/#rmc
type RMC struct {
BaseSentence
Time Time // Time Stamp
Validity string // validity - A-ok, V-invalid
Latitude float64 // Latitude
Longitude float64 // Longitude
Speed float64 // Speed in knots
Course float64 // True course
Date Date // Date
Variation float64 // Magnetic variation
}
// newRMC constructor
func newRMC(s BaseSentence) (RMC, error) {
p := newParser(s)
p.AssertType(TypeRMC)
m := RMC{
BaseSentence: s,
Time: p.Time(0, "time"),
Validity: p.EnumString(1, "validity", ValidRMC, InvalidRMC),
Latitude: p.LatLong(2, 3, "latitude"),
Longitude: p.LatLong(4, 5, "longitude"),
Speed: p.Float64(6, "speed"),
Course: p.Float64(7, "course"),
Date: p.Date(8, "date"),
Variation: p.Float64(9, "variation"),
}
if p.EnumString(10, "direction", West, East) == West {
m.Variation = 0 - m.Variation
}
return m, p.Err()
}