Changeset 14446 in josm
- Timestamp:
- 2018-11-24T15:00:43+01:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java
r14445 r14446 179 179 time = date.getTime() / 1000.; 180 180 return date; 181 } else if (obj == null) { 182 Logging.info("Waypoint {0} value unset", PT_TIME); 181 183 } else { 182 184 Logging.warn("Unsupported waypoint {0} value: {1}", PT_TIME, obj); -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ConvertFromGpxLayerAction.java
r14153 r14446 34 34 import org.openstreetmap.josm.spi.preferences.Config; 35 35 import org.openstreetmap.josm.tools.GBC; 36 import org.openstreetmap.josm.tools.Logging;37 import org.openstreetmap.josm.tools.UncheckedParseException;38 36 import org.openstreetmap.josm.tools.date.DateUtils; 39 37 … … 81 79 n.put(key, str); 82 80 } 83 if (GpxConstants.PT_TIME.equals(key)) {84 // timestamps should always be converted85 try {86 n.setTimestamp(DateUtils.fromString(str));87 } catch (UncheckedParseException e) {88 Logging.log(Logging.LEVEL_WARN, e);89 }90 }91 81 } else if (obj instanceof Date && GpxConstants.PT_TIME.equals(key)) { 92 82 // timestamps should always be converted -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java
r14079 r14446 13 13 import java.util.ArrayList; 14 14 import java.util.Collection; 15 import java.util.Date;16 15 import java.util.HashMap; 17 16 import java.util.LinkedList; … … 260 259 public WayPoint convertToWayPoint() { 261 260 WayPoint wpt = new WayPoint(getCoor()); 262 wpt. put(GpxConstants.PT_TIME, timeFormatter.format(new Date(Math.round(time * 1000))));261 wpt.setTime((long) (time*1000)); 263 262 if (text != null) { 264 263 wpt.addExtension("text", text); -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r14434 r14446 27 27 import org.openstreetmap.josm.data.gpx.WayPoint; 28 28 import org.openstreetmap.josm.tools.Logging; 29 import org.openstreetmap.josm.tools.UncheckedParseException; 29 30 import org.openstreetmap.josm.tools.XmlUtils; 31 import org.openstreetmap.josm.tools.date.DateUtils; 30 32 import org.xml.sax.Attributes; 31 33 import org.xml.sax.InputSource; … … 441 443 } 442 444 break; 443 case "time": 445 case GpxConstants.PT_TIME: 446 try { 447 currentWayPoint.setTime(DateUtils.fromString(accumulator.toString())); 448 } catch (UncheckedParseException e) { 449 Logging.error(e); 450 } 451 break; 444 452 case "cmt": 445 453 case "desc": 446 454 currentWayPoint.put(localName, accumulator.toString()); 447 currentWayPoint.setTimeFromAttribute();448 455 break; 449 456 case "rtept": -
trunk/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java
r14349 r14446 221 221 " <tag k='time' v='2018-08-01T10:01:00Z' />\n" + 222 222 " </node>\n" + 223 " <way id='-546308'>\n" + 223 " <node id='-546308' timestamp='2018-08-01T10:02:00Z' lat='47.05' lon='9.05'>\n" + 224 " <tag k='ele' v='789' />\n" + 225 " </node>\n" + 226 " <way id='-546309'>\n" + 224 227 " <nd ref='-546306' />\n" + 225 228 " <nd ref='-546307' />\n" + 229 " <nd ref='-546308' />\n" + 226 230 " </way>\r\n" + 227 231 "</osm>").getBytes(StandardCharsets.UTF_8)), null)); … … 238 242 assertEquals(1, segments.size()); 239 243 Collection<WayPoint> trackpoints = segments.iterator().next().getWayPoints(); 240 assertEquals( 2, trackpoints.size());244 assertEquals(3, trackpoints.size()); 241 245 Iterator<WayPoint> it = trackpoints.iterator(); 242 246 DateFormat gpxFormat = DateUtils.getGpxFormat(); … … 249 253 assertEquals("456", p2.get(GpxConstants.PT_ELE)); 250 254 assertEquals("2018-08-01T10:01:00.000Z", gpxFormat.format(p2.get(GpxConstants.PT_TIME))); 255 WayPoint p3 = it.next(); 256 assertEquals(new LatLon(47.05, 9.05), p3.getCoor()); 257 assertEquals("789", p3.get(GpxConstants.PT_ELE)); 258 assertEquals("2018-08-01T10:02:00.000Z", gpxFormat.format(p3.get(GpxConstants.PT_TIME))); 251 259 } 252 260 -
trunk/test/unit/org/openstreetmap/josm/io/nmea/NmeaReaderTest.java
r14083 r14446 67 67 68 68 final List<WayPoint> wayPoints = new ArrayList<>(in.data.tracks.iterator().next().getSegments().iterator().next().getWayPoints()); 69 assertEquals( "2016-01-25T05:05:09.2Z", wayPoints.get(0).get(GpxConstants.PT_TIME));70 assertEquals( "2016-01-25T05:05:09.4Z", wayPoints.get(1).get(GpxConstants.PT_TIME));71 assertEquals( "2016-01-25T05:05:09.6Z", wayPoints.get(2).get(GpxConstants.PT_TIME));72 assertEquals(wayPoints.get(0).getTime(), DateUtils.fromString(wayPoints.get(0).get(GpxConstants.PT_TIME).toString()));69 assertEquals(DateUtils.fromString("2016-01-25T05:05:09.200Z"), wayPoints.get(0).get(GpxConstants.PT_TIME)); 70 assertEquals(DateUtils.fromString("2016-01-25T05:05:09.400Z"), wayPoints.get(1).get(GpxConstants.PT_TIME)); 71 assertEquals(DateUtils.fromString("2016-01-25T05:05:09.600Z"), wayPoints.get(2).get(GpxConstants.PT_TIME)); 72 assertEquals(wayPoints.get(0).getTime(), wayPoints.get(0).get(GpxConstants.PT_TIME)); 73 73 74 74 assertEquals("2016-01-25T05:05:09.200Z", iso8601.format(wayPoints.get(0).getTime()));
Note:
See TracChangeset
for help on using the changeset viewer.