Changeset 12167 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-05-15T17:13:11+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java
r11893 r12167 6 6 import java.util.Date; 7 7 import java.util.List; 8 import java.util.Objects; 8 9 9 10 import org.openstreetmap.josm.Main; 10 11 import org.openstreetmap.josm.actions.search.SearchCompiler.Match; 11 12 import org.openstreetmap.josm.data.coor.EastNorth; 13 import org.openstreetmap.josm.data.coor.ILatLon; 12 14 import org.openstreetmap.josm.data.coor.LatLon; 13 import org.openstreetmap.josm.data.projection.Projecti ons;15 import org.openstreetmap.josm.data.projection.Projecting; 14 16 import org.openstreetmap.josm.tools.UncheckedParseException; 15 17 import org.openstreetmap.josm.tools.date.DateUtils; 16 18 import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider; 17 19 18 public class WayPoint extends WithAttributes implements Comparable<WayPoint>, TemplateEngineDataProvider { 20 /** 21 * A point in the GPX data 22 * @since 12167 implements ILatLon 23 */ 24 public class WayPoint extends WithAttributes implements Comparable<WayPoint>, TemplateEngineDataProvider, ILatLon { 19 25 20 26 /** … … 36 42 east = p.east; 37 43 north = p.north; 44 eastNorthCacheKey = p.eastNorthCacheKey; 38 45 time = p.time; 39 46 customColoring = p.customColoring; … … 63 70 private double east = Double.NaN; 64 71 private double north = Double.NaN; 72 private Object eastNorthCacheKey = null; 65 73 66 74 /** … … 80 88 } 81 89 82 /**83 * <p>Replies the projected east/north coordinates.</p>84 *85 * <p>Uses the {@link Main#getProjection() global projection} to project the lan/lon-coordinates.86 * Internally caches the projected coordinates.</p> 87 *88 * <p><strong>Caveat:</strong> doesn't listen to projection changes. Clients must89 * {@link #invalidateEastNorthCache() invalidate the internal cache}.</p>90 *91 * @return the east north coordinates or {@code null} 92 * @see #invalidateEastNorthCache()93 */94 public final EastNorth getEastNorth() {95 if (Double.isNaN(east) || Double.isNaN(north) ) {90 @Override 91 public double lon() { 92 return lat; 93 } 94 95 @Override 96 public double lat() { 97 return lon; 98 } 99 100 @Override 101 public final EastNorth getEastNorth(Projecting projecting) { 102 Object newCacheKey = projecting.getCacheKey(); 103 if (Double.isNaN(east) || Double.isNaN(north) || !Objects.equals(newCacheKey, this.eastNorthCacheKey)) { 96 104 // projected coordinates haven't been calculated yet, 97 105 // so fill the cache of the projected waypoint coordinates 98 EastNorth en = Projections.project(new LatLon(lat, lon));106 EastNorth en = projecting.latlon2eastNorth(this); 99 107 this.east = en.east(); 100 108 this.north = en.north(); 109 this.eastNorthCacheKey = newCacheKey; 101 110 } 102 111 return new EastNorth(east, north); -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r12161 r12167 107 107 // projected coordinates haven't been calculated yet, 108 108 // so fill the cache of the projected node coordinates 109 EastNorth en = Projections.project(new LatLon(lat, lon));109 EastNorth en = projection.latlon2eastNorth(this); 110 110 this.east = en.east(); 111 111 this.north = en.north(); -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackAction.java
r12131 r12167 71 71 for (GpxTrackSegment segment : trk.getSegments()) { 72 72 for (WayPoint p : segment.getWayPoints()) { 73 latsum += p. getCoor().lat();73 latsum += p.lat(); 74 74 latcnt++; 75 75 } -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
r12157 r12167 478 478 } 479 479 for (WayPoint trkPnt : segment) { 480 LatLon c = trkPnt.getCoor(); 481 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 480 if (!trkPnt.isLatLonKnown()) { 482 481 continue; 483 482 } 484 483 if (oldWp != null && trkPnt.time > oldWp.time) { 485 double vel = c.greatCircleDistance(oldWp.getCoor())484 double vel = trkPnt.getCoor().greatCircleDistance(oldWp.getCoor()) 486 485 / (trkPnt.time - oldWp.time); 487 486 velocities.add(vel); … … 624 623 Point old = null; 625 624 for (WayPoint trkPnt : visibleSegments) { 626 LatLon c = trkPnt.getCoor(); 627 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 625 if (!trkPnt.isLatLonKnown()) { 628 626 continue; 629 627 } … … 653 651 Point oldA = null; // last arrow painted 654 652 for (WayPoint trkPnt : visibleSegments) { 655 LatLon c = trkPnt.getCoor(); 656 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 653 if (!trkPnt.isLatLonKnown()) { 657 654 continue; 658 655 }
Note:
See TracChangeset
for help on using the changeset viewer.