forked from adrianmo/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpgrme.go
55 lines (47 loc) · 1.32 KB
/
pgrme.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
46
47
48
49
50
51
52
53
54
55
package nmea
const (
// TypePGRME type for PGRME sentences
TypePGRME = "GRME"
// ErrorUnit must be meters (M)
ErrorUnit = "M"
)
// PGRME is Estimated Position Error (Garmin proprietary sentence)
// http://aprs.gids.nl/nmea/#rme
type PGRME struct {
BaseSentence
Horizontal float64 // Estimated horizontal position error (HPE) in metres
Vertical float64 // Estimated vertical position error (VPE) in metres
Spherical float64 // Overall spherical equivalent position error in meters
}
func (s PGRME) ToMap() (map[string]interface{}, error) {
m := map[string]interface{}{
"horizontal": s.Horizontal,
"vertical": s.Vertical,
"spherical": s.Spherical,
}
bm, err := s.BaseSentence.toMap()
if err != nil {
return m, err
}
for k, v := range bm {
m[k] = v
}
return m, nil
}
// newPGRME constructor
func newPGRME(s BaseSentence) (PGRME, error) {
p := NewParser(s)
p.AssertType(TypePGRME)
horizontal := p.Float64(0, "horizontal error")
_ = p.EnumString(1, "horizontal error unit", ErrorUnit)
vertial := p.Float64(2, "vertical error")
_ = p.EnumString(3, "vertical error unit", ErrorUnit)
spherical := p.Float64(4, "spherical error")
_ = p.EnumString(5, "spherical error unit", ErrorUnit)
return PGRME{
BaseSentence: s,
Horizontal: horizontal,
Vertical: vertial,
Spherical: spherical,
}, p.Err()
}