-
Notifications
You must be signed in to change notification settings - Fork 0
/
type27.go
54 lines (47 loc) · 1.5 KB
/
type27.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
package nmeaais
import (
"fmt"
)
type LongRangeAISBroadcast struct {
MessageType int64
RepeatIndicator int64
MMSI int64
PositionAccuracy bool
RAIM bool
NavigationStatus string
Longitude float64
Latitude float64
SpeedOverGround float64
CourseOverGround float64
GNSSPositionStatus int64
}
func (m *Message) GetAsLongRangeAISBroadcast() (p *LongRangeAISBroadcast, err error) {
defer func() {
if r := recover(); r != nil {
p = nil
var ok bool
err, ok = r.(error)
if !ok {
err = fmt.Errorf("pkg: %v", r)
}
}
}()
var validMessageType int64 = 27
if m.MessageType != validMessageType {
return nil, fmt.Errorf("nmeaais: tried to get message as type %v, but is type %v", validMessageType, m.MessageType)
}
p = &LongRangeAISBroadcast{
MessageType: m.MessageType,
RepeatIndicator: m.RepeatIndicator,
MMSI: m.MMSI,
PositionAccuracy: asBool(asUInt(m.unarmoredPayload, 38, 1)),
RAIM: asBool(asUInt(m.unarmoredPayload, 39, 1)),
NavigationStatus: navigationStatus(asUInt(m.unarmoredPayload, 40, 4)),
Longitude: latlonShort(asInt(m.unarmoredPayload, 44, 18)),
Latitude: latlonShort(asInt(m.unarmoredPayload, 62, 17)),
SpeedOverGround: speedOverGroundLongRange(asUInt(m.unarmoredPayload, 79, 6)),
CourseOverGround: courseOverGroundLongRange(asUInt(m.unarmoredPayload, 85, 9)),
GNSSPositionStatus: int64(asUInt(m.unarmoredPayload, 94, 1)),
}
return
}