6
6
public class SurfacePosition extends ExtendedSquitter {
7
7
private final String address ;
8
8
private int velocityEncoded = 0 ;
9
+ private double velocity = 0 ;
9
10
10
11
private boolean trackValid = false ;
11
12
private int trackEncoded = 0 ;
12
13
13
14
private double lat ;
14
15
private double lon ;
15
16
private boolean positionAvailable = false ;
17
+ private boolean velocityAvailable = false ;
16
18
17
19
public SurfacePosition (short [] data , String address ) {
18
20
super (data );
@@ -22,6 +24,8 @@ public SurfacePosition(short[] data, String address) {
22
24
@ Override
23
25
public SurfacePosition decode () {
24
26
velocityEncoded = ((data [4 ] & 0x7 ) << 4 ) | (data [5 ] >>> 4 );
27
+ velocityAvailable = velocityEncoded != 0 ;
28
+ velocity = decodeEncodedVelocity ();
25
29
26
30
trackValid = ((data [5 ] >>> 3 ) & 0x1 ) == 0x1 ;
27
31
trackEncoded = ((data [5 ] & 0x7 ) << 4 ) | (data [6 ] >>> 4 );
@@ -46,20 +50,31 @@ public SurfacePosition decode() {
46
50
} else {
47
51
this .positionAvailable = false ;
48
52
}
49
- return this ; }
53
+
54
+ return this ;
55
+ }
50
56
51
57
@ Override
52
58
public void apply (Track track ) {
53
59
track .setGroundBit (true );
60
+
54
61
if (positionAvailable ) {
55
62
track .setLatLon (lat , lon );
56
63
}
64
+
65
+ if (velocityAvailable ) {
66
+ track .setGs (velocity );
67
+ }
57
68
}
58
69
59
70
public boolean isPositionAvailable () {
60
71
return positionAvailable ;
61
72
}
62
73
74
+ public boolean isVelocityAvailable () {
75
+ return this .velocityAvailable ;
76
+ }
77
+
63
78
public double getLat () {
64
79
return lat ;
65
80
}
@@ -77,6 +92,22 @@ public int getVelocityEncoded() {
77
92
}
78
93
79
94
public double getVelocity () {
95
+ return this .velocity ;
96
+ }
97
+
98
+ public boolean isTrackValid () {
99
+ return trackValid ;
100
+ }
101
+
102
+ public int getTrackEncoded () {
103
+ return trackEncoded ;
104
+ }
105
+
106
+ public double getTrack () {
107
+ return trackEncoded * 360.0 / 128.0 ;
108
+ }
109
+
110
+ private double decodeEncodedVelocity () {
80
111
if (this .velocityEncoded == 1 ) {
81
112
return 0 ;
82
113
}
@@ -104,18 +135,7 @@ public double getVelocity() {
104
135
if (this .velocityEncoded == 124 ) {
105
136
return 175.0 ;
106
137
}
107
- return 0 ; // Could be either "not available" or "reserved"... just assume zero speed for now
108
- }
109
138
110
- public boolean isTrackValid () {
111
- return trackValid ;
112
- }
113
-
114
- public int getTrackEncoded () {
115
- return trackEncoded ;
116
- }
117
-
118
- public double getTrack () {
119
- return trackEncoded * 360.0 / 128.0 ;
139
+ return 0 ; // Could be either "not available" or "reserved"... just assume zero speed for now
120
140
}
121
141
}
0 commit comments