Changeset 9740 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/NmeaReader.java
r9703 r9740 20 20 import org.openstreetmap.josm.data.gpx.ImmutableGpxTrack; 21 21 import org.openstreetmap.josm.data.gpx.WayPoint; 22 import org.openstreetmap.josm.tools.date.DateUtils;23 22 24 23 /** … … 287 286 // As this sentence has no complete time only use it 288 287 // if there is no time so far 289 currentwp. put(GpxConstants.PT_TIME, DateUtils.fromDate(d));288 currentwp.setTime(d); 290 289 } 291 290 // elevation … … 398 397 } 399 398 // time: this sentence has complete time so always use it. 400 currentwp. put(GpxConstants.PT_TIME, DateUtils.fromDate(d));399 currentwp.setTime(d); 401 400 // speed 402 401 accu = e[GPRMC.SPEED.position]; -
trunk/test/unit/org/openstreetmap/josm/io/NmeaReaderTest.java
r9666 r9740 2 2 package org.openstreetmap.josm.io; 3 3 4 import org.junit.Test; 5 import org.openstreetmap.josm.io.NmeaReader.NMEA_TYPE; 4 import static junit.framework.Assert.assertEquals; 5 6 import java.io.FileInputStream; 7 import java.text.SimpleDateFormat; 8 import java.util.ArrayList; 9 import java.util.List; 6 10 7 11 import nl.jqno.equalsverifier.EqualsVerifier; 12 import org.junit.Test; 13 import org.openstreetmap.josm.data.coor.LatLon; 14 import org.openstreetmap.josm.data.gpx.GpxConstants; 15 import org.openstreetmap.josm.data.gpx.WayPoint; 16 import org.openstreetmap.josm.io.NmeaReader.NMEA_TYPE; 8 17 9 18 /** … … 19 28 EqualsVerifier.forClass(NMEA_TYPE.class).verify(); 20 29 } 30 31 /** 32 * Tests reading a nmea file. 33 * @throws Exception if any error occurs 34 */ 35 @Test 36 public void testReader() throws Exception { 37 final NmeaReader in = new NmeaReader(new FileInputStream("data_nodist/btnmeatrack_2016-01-25.nmea")); 38 assertEquals(30, in.getNumberOfCoordinates()); 39 assertEquals(0, in.getParserMalformed()); 40 41 final List<WayPoint> wayPoints = new ArrayList<>(in.data.tracks.iterator().next().getSegments().iterator().next().getWayPoints()); 42 assertEquals("2016-01-25T04:05:09.200Z", wayPoints.get(0).get(GpxConstants.PT_TIME)); 43 assertEquals("2016-01-25T04:05:09.400Z", wayPoints.get(1).get(GpxConstants.PT_TIME)); 44 assertEquals("2016-01-25T04:05:09.600Z", wayPoints.get(2).get(GpxConstants.PT_TIME)); 45 46 final SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX"); 47 assertEquals("2016-01-25T05:05:09.200+01", iso8601.format(wayPoints.get(0).getTime())); 48 assertEquals("2016-01-25T05:05:09.400+01", iso8601.format(wayPoints.get(1).getTime())); 49 assertEquals("2016-01-25T05:05:09.600+01", iso8601.format(wayPoints.get(2).getTime())); 50 51 assertEquals(new LatLon(46.98807, -1.400525), wayPoints.get(0).getCoor()); 52 assertEquals("38.9", wayPoints.get(0).get(GpxConstants.PT_ELE)); 53 assertEquals("16", wayPoints.get(0).get(GpxConstants.PT_SAT)); 54 assertEquals("3d", wayPoints.get(0).get(GpxConstants.PT_FIX)); 55 assertEquals("0.7", wayPoints.get(0).get(GpxConstants.PT_HDOP).toString().trim()); 56 assertEquals(null, wayPoints.get(0).get(GpxConstants.PT_VDOP)); 57 assertEquals(null, wayPoints.get(0).get(GpxConstants.PT_PDOP)); 58 } 21 59 }
Note:
See TracChangeset
for help on using the changeset viewer.