Changeset 30504 in osm for applications/editors/josm/plugins/livegps
- Timestamp:
- 2014-06-30T20:48:13+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsAcquirer.java
r30351 r30504 259 259 private LiveGpsData ParseJSON(String line) { 260 260 JsonObject report; 261 String type; 262 double lat = 0; 263 double lon = 0; 261 double lat, lon; 264 262 float speed = 0; 265 263 float course = 0; … … 269 267 try { 270 268 report = Json.createReader(new StringReader(line)).readObject(); 271 type = report.getString("class");272 269 } catch (JsonException jex) { 273 270 Main.warn("LiveGps: line read from gpsd is not a JSON object:" + line); 274 271 return null; 275 272 } 276 if (! type.equals("TPV"))273 if (!report.getString("class").equals("TPV") || report.getInt("mode") < 2) 277 274 return null; 278 275 279 try {280 lat = report.getJsonNumber("lat").doubleValue();281 lon = report.getJsonNumber("lon").doubleValue(); 282 speed = (new Float(report.getJsonNumber("speed").doubleValue())).floatValue();283 course = (new Float(report.getJsonNumber("track").doubleValue())).floatValue();284 JsonNumber epxJson = report.getJsonNumber("epx");285 if (epxJson != null)286 epx = (new Float(epxJson.doubleValue())).floatValue(); 287 JsonNumber epyJson = report.getJsonNumber("epy");288 if (epyJson != null)289 epy = (new Float(epyJson.doubleValue())).floatValue();290 291 return new LiveGpsData(lat, lon, course, speed, epx, epy);292 } catch (JsonException je) {293 Main.debug(je.getMessage());294 }295 296 return n ull;276 lat = report.getJsonNumber("lat").doubleValue(); 277 lon = report.getJsonNumber("lon").doubleValue(); 278 279 JsonNumber epxJson = report.getJsonNumber("epx"); 280 JsonNumber epyJson = report.getJsonNumber("epy"); 281 JsonNumber speedJson = report.getJsonNumber("speed"); 282 JsonNumber trackJson = report.getJsonNumber("track"); 283 284 if (speedJson != null) 285 speed = (float )speedJson.doubleValue(); 286 if (trackJson != null) 287 course = (float )trackJson.doubleValue(); 288 if (epxJson != null) 289 epx = (float )epxJson.doubleValue(); 290 if (epyJson != null) 291 epy = (float )epyJson.doubleValue(); 292 293 return new LiveGpsData(lat, lon, course, speed, epx, epy); 297 294 } 298 295
Note:
See TracChangeset
for help on using the changeset viewer.