File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed
main/java/de/taimos/gpsd4java
test/java/de/taimos/gpsd4java/backend Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,7 @@ protected IGPSObject parsePRN(final JSONObject json) {
254
254
sat .setElevation (json .optInt ("el" , -1 ));
255
255
sat .setSignalStrength (json .optInt ("ss" , -1 ));
256
256
sat .setUsed (json .optBoolean ("used" , false ));
257
+ sat .setGnssId (json .optInt ("gnssid" , -1 ));
257
258
gps = sat ;
258
259
return gps ;
259
260
}
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ public class SATObject implements IGPSObject {
36
36
37
37
private int signalStrength = -1 ;
38
38
39
+ private int gnssId = -1 ;
40
+
39
41
private boolean used = false ;
40
42
41
43
/**
@@ -132,6 +134,24 @@ public void setUsed(final boolean used) {
132
134
this .used = used ;
133
135
}
134
136
137
+ /**
138
+ * The GNSSID field of the satellite, if available.
139
+ *
140
+ * @return gnssId
141
+ */
142
+ public int getGnssId () {
143
+ return gnssId ;
144
+ }
145
+
146
+ /**
147
+ * The GNSSID field of the satellite, if available.
148
+ *
149
+ * @param gnssId the GNSSID field to set
150
+ */
151
+ public void setGnssId (final int gnssId ) {
152
+ this .gnssId = gnssId ;
153
+ }
154
+
135
155
@ Override
136
156
public int hashCode () {
137
157
final int prime = 31 ;
@@ -145,6 +165,8 @@ public int hashCode() {
145
165
result = (prime * result ) + (int ) (temp ^ (temp >>> 32 ));
146
166
temp = Double .doubleToLongBits (this .signalStrength );
147
167
result = (prime * result ) + (int ) (temp ^ (temp >>> 32 ));
168
+ temp = Double .doubleToLongBits (this .gnssId );
169
+ result = (prime * result ) + (int ) (temp ^ (temp >>> 32 ));
148
170
result = (prime * result ) + ((this .used ) ? 1 : 0 );
149
171
return result ;
150
172
}
Original file line number Diff line number Diff line change
1
+ package de .taimos .gpsd4java .backend ;
2
+
3
+ import de .taimos .gpsd4java .types .SATObject ;
4
+ import org .json .JSONObject ;
5
+ import org .junit .Assert ;
6
+ import org .junit .Before ;
7
+ import org .junit .Test ;
8
+
9
+ public class ResultParserTest {
10
+
11
+ private ResultParser resultParser ;
12
+
13
+ @ Before
14
+ public void before () {
15
+ this .resultParser = new ResultParser ();
16
+ }
17
+
18
+ @ Test
19
+ public void testSatObject () {
20
+ final JSONObject json = new JSONObject ();
21
+ json .put ("PRN" , 12 );
22
+ json .put ("gnssid" , 44 );
23
+ json .put ("svid" , 12 );
24
+ json .put ("az" , 229 );
25
+ json .put ("el" , 24 );
26
+ json .put ("prRes" , 22.9 );
27
+ json .put ("qual" , 1 );
28
+ json .put ("ss" , 0 );
29
+ json .put ("used" , false );
30
+ json .put ("health" , 1 );
31
+ final SATObject satObject = (SATObject ) this .resultParser .parsePRN (json );
32
+ Assert .assertEquals (12 , satObject .getPRN ());
33
+ Assert .assertEquals (44 , satObject .getGnssId ());
34
+ Assert .assertEquals (229 , satObject .getAzimuth ());
35
+ Assert .assertEquals (24 , satObject .getElevation ());
36
+ Assert .assertFalse (satObject .getUsed ());
37
+ Assert .assertEquals (0 , satObject .getSignalStrength ());
38
+ }
39
+
40
+ }
You can’t perform that action at this time.
0 commit comments