forked from adrianmo/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhdt.go
41 lines (37 loc) · 806 Bytes
/
hdt.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
package nmea
const (
// TypeHDT type for HDT sentences
TypeHDT = "HDT"
)
// HDT is the Actual vessel heading in degrees True.
// http://aprs.gids.nl/nmea/#hdt
type HDT struct {
BaseSentence
Heading float64 // Heading in degrees
True bool // Heading is relative to true north
}
func (s HDT) ToMap() (map[string]interface{}, error) {
m := map[string]interface{}{
"heading": s.Heading,
"true": s.True,
}
bm, err := s.BaseSentence.toMap()
if err != nil {
return m, err
}
for k, v := range bm {
m[k] = v
}
return m, nil
}
// newHDT constructor
func newHDT(s BaseSentence) (HDT, error) {
p := NewParser(s)
p.AssertType(TypeHDT)
m := HDT{
BaseSentence: s,
Heading: p.Float64(0, "heading"),
True: p.EnumString(1, "true", "T") == "T",
}
return m, p.Err()
}