Changeset 12167 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2017-05-15T17:13:11+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 2 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();
Note:
See TracChangeset
for help on using the changeset viewer.