forked from adrianmo/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvtg.go
32 lines (29 loc) · 805 Bytes
/
vtg.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
package nmea
const (
// TypeVTG type for VTG sentences
TypeVTG = "VTG"
)
// VTG represents track & speed data.
// http://aprs.gids.nl/nmea/#vtg
type VTG struct {
BaseSentence
TrueTrack float64
MagneticTrack float64
GroundSpeedKnots float64
GroundSpeedKPH float64
Mode string
}
// newVTG parses the VTG sentence into this struct.
// e.g: $GPVTG,360.0,T,348.7,M,000.0,N,000.0,K*43
func newVTG(s BaseSentence) (VTG, error) {
p := NewParser(s)
p.AssertType(TypeVTG)
return VTG{
BaseSentence: s,
TrueTrack: p.Float64(0, "true track"),
MagneticTrack: p.Float64(2, "magnetic track"),
GroundSpeedKnots: p.Float64(4, "ground speed (knots)"),
GroundSpeedKPH: p.Float64(6, "ground speed (km/h)"),
Mode: p.String(8, "Mode"),
}, p.Err()
}