Changeset 14460 in josm for trunk/src/org
- Timestamp:
- 2018-11-28T01:09:01+01:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/gpx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r14456 r14460 693 693 final LongSummaryStatistics statistics = trk.getSegments().stream() 694 694 .flatMap(seg -> seg.getWayPoints().stream()) 695 .mapToLong( pnt -> pnt.getTimeInMillis())695 .mapToLong(WayPoint::getTimeInMillis) 696 696 .summaryStatistics(); 697 697 return statistics.getCount() == 0 … … 712 712 .flatMap(trk -> trk.getSegments().stream()) 713 713 .flatMap(seg -> seg.getWayPoints().stream()) 714 .mapToLong( pnt -> pnt.getTimeInMillis())714 .mapToLong(WayPoint::getTimeInMillis) 715 715 .filter(t -> t > 0 && t <= now) 716 716 .summaryStatistics(); -
trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java
r14456 r14460 63 63 */ 64 64 public WayPoint(WayPoint p) { 65 init_attr();65 attr = new LegacyMap(); 66 66 attr.putAll(p.attr); 67 67 attr.put(PT_TIME, p.getDate()); … … 81 81 */ 82 82 public WayPoint(LatLon ll) { 83 init_attr();83 attr = new LegacyMap(); 84 84 lat = ll.lat(); 85 85 lon = ll.lon(); … … 91 91 * To remove mid 2019 92 92 */ 93 private void init_attr() { 94 attr = new HashMap<String, Object>(0) { 95 @Override 96 public Object put(String key, Object value) { 97 Object ret = null; 98 if (key != PT_TIME || (key == PT_TIME && value instanceof Date)) { 99 ret = super.put(key, value); 100 } else { 101 if (value instanceof String) { 102 ret = super.put(PT_TIME, DateUtils.fromString((String) value)); 103 List<String> lastErrorAndWarnings = Logging.getLastErrorAndWarnings(); 104 if (!lastErrorAndWarnings.isEmpty() && !lastErrorAndWarnings.get(0).contains("calling WayPoint.put")) { 105 StackTraceElement[] e = Thread.currentThread().getStackTrace(); 106 int n = 1; 107 while (n < e.length && "put".equals(e[n].getMethodName())) { 108 n++; 109 } 110 if (n < e.length) { 111 Logging.warn("{0}:{1} calling WayPoint.put(PT_TIME, ..) is deprecated. " + 112 "Use WayPoint.setTime(..) instead.", e[n].getClassName(), e[n].getMethodName()); 113 } 114 } 93 private static class LegacyMap extends HashMap<String, Object> { 94 95 LegacyMap() { 96 super(0); 97 } 98 99 @Override 100 public Object put(String key, Object value) { 101 Object ret = null; 102 if (!PT_TIME.equals(key) || value instanceof Date) { 103 ret = super.put(key, value); 104 } else if (value instanceof String) { 105 ret = super.put(PT_TIME, DateUtils.fromString((String) value)); 106 List<String> lastErrorAndWarnings = Logging.getLastErrorAndWarnings(); 107 if (!lastErrorAndWarnings.isEmpty() && !lastErrorAndWarnings.get(0).contains("calling WayPoint.put")) { 108 StackTraceElement[] e = Thread.currentThread().getStackTrace(); 109 int n = 1; 110 while (n < e.length && "put".equals(e[n].getMethodName())) { 111 n++; 112 } 113 if (n < e.length) { 114 Logging.warn("{0}:{1} calling WayPoint.put(PT_TIME, ..) is deprecated. " + 115 "Use WayPoint.setTime(..) instead.", e[n].getClassName(), e[n].getMethodName()); 115 116 } 116 117 } 117 return ret;118 118 } 119 }; 119 return ret; 120 } 120 121 } 121 122
Note:
See TracChangeset
for help on using the changeset viewer.