Changeset 17715 in josm for trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
- Timestamp:
- 2021-04-08T22:56:06+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r17439 r17715 4 4 import java.io.File; 5 5 import java.text.MessageFormat; 6 import java.time.Instant; 6 7 import java.util.ArrayList; 7 8 import java.util.Arrays; … … 9 10 import java.util.Collections; 10 11 import java.util.Comparator; 11 import java.util.Date;12 12 import java.util.HashMap; 13 13 import java.util.HashSet; … … 200 200 boolean split = false; 201 201 WayPoint prevLastOwnWp = null; 202 DateprevWpTime = null;202 Instant prevWpTime = null; 203 203 for (WayPoint wp : wpsOld) { 204 Date wpTime = wp.getDate();204 Instant wpTime = wp.getInstant(); 205 205 boolean overlap = false; 206 206 if (wpTime != null) { 207 207 for (GpxTrackSegmentSpan ownspan : getSegmentSpans()) { 208 if (wpTime. after(ownspan.firstTime) && wpTime.before(ownspan.lastTime)) {208 if (wpTime.isAfter(ownspan.firstTime) && wpTime.isBefore(ownspan.lastTime)) { 209 209 overlap = true; 210 210 if (connect) { … … 219 219 break; 220 220 } else if (connect && prevWpTime != null 221 && prevWpTime. before(ownspan.firstTime)222 && wpTime. after(ownspan.lastTime)) {221 && prevWpTime.isBefore(ownspan.firstTime) 222 && wpTime.isAfter(ownspan.lastTime)) { 223 223 // the overlapping high priority track is shorter than the distance 224 224 // between two waypoints of the low priority track … … 287 287 static class GpxTrackSegmentSpan { 288 288 289 final DatefirstTime;290 final DatelastTime;289 final Instant firstTime; 290 final Instant lastTime; 291 291 private final boolean inv; 292 292 private final WayPoint firstWp; … … 294 294 295 295 GpxTrackSegmentSpan(WayPoint a, WayPoint b) { 296 Date at = a.getDate();297 Date bt = b.getDate();298 inv = bt. before(at);296 Instant at = a.getInstant(); 297 Instant bt = b.getInstant(); 298 inv = bt.isBefore(at); 299 299 if (inv) { 300 300 firstWp = b; … … 333 333 334 334 boolean overlapsWith(GpxTrackSegmentSpan other) { 335 return (firstTime. before(other.lastTime) && other.firstTime.before(lastTime))336 || (other.firstTime. before(lastTime) && firstTime.before(other.lastTime));335 return (firstTime.isBefore(other.lastTime) && other.firstTime.isBefore(lastTime)) 336 || (other.firstTime.isBefore(lastTime) && firstTime.isBefore(other.lastTime)); 337 337 } 338 338 … … 720 720 * @return minimum and maximum dates in array of 2 elements 721 721 */ 722 public static Date[] getMinMaxTimeForTrack(IGpxTrack trk) {722 public static Instant[] getMinMaxTimeForTrack(IGpxTrack trk) { 723 723 final LongSummaryStatistics statistics = trk.getSegments().stream() 724 724 .flatMap(seg -> seg.getWayPoints().stream()) … … 727 727 return statistics.getCount() == 0 || (statistics.getMin() == 0 && statistics.getMax() == 0) 728 728 ? null 729 : new Date[]{new Date(statistics.getMin()), new Date(statistics.getMax())};729 : new Instant[]{Instant.ofEpochMilli(statistics.getMin()), Instant.ofEpochMilli(statistics.getMax())}; 730 730 } 731 731 … … 737 737 * @since 7319 738 738 */ 739 public synchronized Date[] getMinMaxTimeForAllTracks() {739 public synchronized Instant[] getMinMaxTimeForAllTracks() { 740 740 long now = System.currentTimeMillis(); 741 741 final LongSummaryStatistics statistics = tracks.stream() … … 746 746 .summaryStatistics(); 747 747 return statistics.getCount() == 0 748 ? new Date[0]749 : new Date[]{new Date(statistics.getMin()), new Date(statistics.getMax())};748 ? new Instant[0] 749 : new Instant[]{Instant.ofEpochMilli(statistics.getMin()), Instant.ofEpochMilli(statistics.getMax())}; 750 750 } 751 751
Note:
See TracChangeset
for help on using the changeset viewer.