forked from adrianmo/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrot.go
41 lines (37 loc) · 746 Bytes
/
rot.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 (
// TypeROT type for ROT sentences
TypeROT = "ROT"
)
// ROT rate of turn
// http://aprs.gids.nl/nmea/#hdt
type ROT struct {
BaseSentence
Rate float64 // rate of turn, degrees/minute, "-" bow turns to port
Status string
}
func (s ROT) ToMap() (map[string]interface{}, error) {
m := map[string]interface{}{
"rate": s.Rate,
"status": s.Status,
}
bm, err := s.BaseSentence.toMap()
if err != nil {
return m, err
}
for k, v := range bm {
m[k] = v
}
return m, nil
}
// newROT constructor
func newROT(s BaseSentence) (ROT, error) {
p := NewParser(s)
p.AssertType(TypeROT)
m := ROT{
BaseSentence: s,
Rate: p.Float64(0, "Rate"),
Status: p.String(1, "Status"),
}
return m, p.Err()
}