Changeset 14083 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/nmea/NmeaReader.java
r14067 r14083 432 432 if (!accu.isEmpty() && currentwp != null) { 433 433 double speed = Double.parseDouble(accu); 434 speed /= 3.6; // speed in m/s 435 currentwp.put("speed", Double.toString(speed)); 434 currentwp.put("speed", Double.toString(speed)); // speed in km/h 436 435 } 437 436 } … … 481 480 if (!accu.isEmpty() && !currentwp.attr.containsKey("speed")) { 482 481 double speed = Double.parseDouble(accu); 483 speed *= 0.514444444; // to m/s482 speed *= 0.514444444 * 3.6; // to km/h 484 483 currentwp.put("speed", Double.toString(speed)); 485 484 } -
trunk/test/unit/org/openstreetmap/josm/io/nmea/NmeaReaderTest.java
r14079 r14083 160 160 } 161 161 162 private static Date readDate(String nmeaLine) throws IOException, SAXException {162 private static GpxData read(String nmeaLine) throws IOException, SAXException { 163 163 NmeaReader in = new NmeaReader(new ByteArrayInputStream(nmeaLine.getBytes(StandardCharsets.UTF_8))); 164 164 in.parse(true); 165 return in.data.tracks.iterator().next().getSegments().iterator().next().getWayPoints().iterator().next().getTime(); 165 return in.data; 166 } 167 168 private static WayPoint readWayPoint(String nmeaLine) throws IOException, SAXException { 169 return read(nmeaLine).tracks.iterator().next().getSegments().iterator().next().getWayPoints().iterator().next(); 170 } 171 172 private static Date readDate(String nmeaLine) throws IOException, SAXException { 173 return readWayPoint(nmeaLine).getTime(); 174 } 175 176 private static double readSpeed(String nmeaLine) throws IOException, SAXException { 177 return Double.parseDouble(readWayPoint(nmeaLine).getString("speed")); 166 178 } 167 179 … … 179 191 readDate("$GNRMC,162859.4,A,4543.03388,N,00058.19870,W,45.252,209.07,300518,,,D,V*13"))); 180 192 } 193 194 /** 195 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/16554">Bug #16554</a>. 196 * @throws Exception if an error occurs 197 */ 198 @Test 199 public void testTicket16554() throws Exception { 200 assertEquals(63.2420959, readSpeed( 201 "$GNRMC,141448.80,A,4659.05514,N,00130.44695,W,34.148,289.80,300718,,,D,V*26"), 1e-7); 202 assertEquals(63.2430000, readSpeed( 203 "$GNRMC,141448.80,A,4659.05514,N,00130.44695,W,34.148,289.80,300718,,,D,V*26" 204 + "$GNVTG,289.80,T,,M,34.148,N,63.243,K,D*27"), 1e-7); 205 } 181 206 }
Note:
See TracChangeset
for help on using the changeset viewer.