Ticket #15229: deprecate_ILatLon#getEastNorth().patch
File deprecate_ILatLon#getEastNorth().patch, 25.2 KB (added by , 18 months ago) |
---|
-
src/org/openstreetmap/josm/data/coor/ILatLon.java
43 43 * <p>Uses the {@link Main#getProjection() global projection} to project the lan/lon-coordinates.</p> 44 44 * 45 45 * @return the east north coordinates or {@code null} if #is 46 * @deprecated use {@link #getEastNorth(org.openstreetmap.josm.data.projection.Projecting)} 46 47 */ 48 @Deprecated 47 49 default EastNorth getEastNorth() { 48 50 return getEastNorth(Main.getProjection()); 49 51 } -
src/org/openstreetmap/josm/data/coor/LatLon.java
307 307 case DECIMAL_DEGREES: return cDdFormatter.format(y); 308 308 case DEGREES_MINUTES_SECONDS: return degreesMinutesSeconds(y) + ((y < 0) ? SOUTH : NORTH); 309 309 case NAUTICAL: return degreesMinutes(y) + ((y < 0) ? SOUTH : NORTH); 310 case EAST_NORTH: return cDdFormatter.format(this.getEastNorth( ).north());310 case EAST_NORTH: return cDdFormatter.format(this.getEastNorth(Main.getProjection()).north()); 311 311 default: return "ERR"; 312 312 } 313 313 } … … 327 327 case DECIMAL_DEGREES: return cDdFormatter.format(x); 328 328 case DEGREES_MINUTES_SECONDS: return degreesMinutesSeconds(x) + ((x < 0) ? WEST : EAST); 329 329 case NAUTICAL: return degreesMinutes(x) + ((x < 0) ? WEST : EAST); 330 case EAST_NORTH: return cDdFormatter.format(this.getEastNorth( ).east());330 case EAST_NORTH: return cDdFormatter.format(this.getEastNorth(Main.getProjection()).east()); 331 331 default: return "ERR"; 332 332 } 333 333 } -
src/org/openstreetmap/josm/data/gpx/GpxData.java
416 416 for (GpxTrack track : getTracks()) { 417 417 for (GpxTrackSegment seg : track.getSegments()) { 418 418 WayPoint r = null; 419 for (WayPoint S: seg.getWayPoints()) {420 EastNorth en = S.getEastNorth();419 for (WayPoint wpSeg : seg.getWayPoints()) { 420 EastNorth en = wpSeg.getEastNorth(Main.getProjection()); 421 421 if (r == null) { 422 r = S;422 r = wpSeg; 423 423 rx = en.east(); 424 424 ry = en.north(); 425 425 x = px - rx; … … 454 454 double nx = rx - rnoverRS * b; 455 455 double ny = ry + rnoverRS * a; 456 456 bestEN = new EastNorth(nx, ny); 457 bestTime = r.time + rnoverRS * ( S.time - r.time);457 bestTime = r.time + rnoverRS * (wpSeg.time - r.time); 458 458 pnminsq = pnsq; 459 459 } 460 460 } 461 r = S;461 r = wpSeg; 462 462 rx = sx; 463 463 ry = sy; 464 464 } 465 465 } 466 466 if (r != null) { 467 EastNorth c = r.getEastNorth( );467 EastNorth c = r.getEastNorth(Main.getProjection()); 468 468 /* if there is only one point in the seg, it will do this twice, but no matter */ 469 469 rx = c.east(); 470 470 ry = c.north(); -
src/org/openstreetmap/josm/data/osm/Node.java
99 99 return lon; 100 100 } 101 101 102 /** 103 * Replies the projected east/north coordinates. 104 * <p> 105 * Uses the {@link Main#getProjection() global projection} to project the lan/lon-coordinates. 106 * @return the east north coordinates or {@code null} if #is 107 */ 108 public EastNorth getEastNorth() { 109 return getEastNorth(Main.getProjection()); 110 } 111 102 112 @Override 103 113 public EastNorth getEastNorth(Projecting projection) { 104 114 if (!isLatLonKnown()) return null; -
src/org/openstreetmap/josm/data/osm/NodeData.java
75 75 } 76 76 77 77 @Override 78 @Deprecated 78 79 public EastNorth getEastNorth() { 79 80 // No internal caching of projected coordinates needed. In contrast to getEastNorth() 80 81 // on Node, this method is rarely used. Caching would be overkill. -
src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
73 73 /** 74 74 * Visiting call for lat/lon. 75 75 * @param latlon lat/lon 76 * @since xxx (public for ILatLon parameter) 76 77 */ 77 public void visit( LatLon latlon) {78 public void visit(ILatLon latlon) { 78 79 if (latlon != null) { 79 visit( (ILatLon) latlon);80 visit(latlon.getEastNorth(Main.getProjection())); 80 81 } 81 82 } 82 83 83 private void visit(ILatLon latlon) { 84 visit(latlon.getEastNorth()); 84 /** 85 * Visiting call for lat/lon. 86 * @param latlon lat/lon 87 */ 88 public void visit(LatLon latlon) { 89 visit((ILatLon) latlon); 85 90 } 86 91 87 92 /** … … 137 142 LatLon maxLatlon = Main.getProjection().eastNorth2latlon(bounds.getMax()); 138 143 bounds = new ProjectionBounds(new LatLon( 139 144 Math.max(-90, minLatlon.lat() - enlargeDegree), 140 Math.max(-180, minLatlon.lon() - enlargeDegree)).getEastNorth( ),145 Math.max(-180, minLatlon.lon() - enlargeDegree)).getEastNorth(Main.getProjection()), 141 146 new LatLon( 142 147 Math.min(90, maxLatlon.lat() + enlargeDegree), 143 Math.min(180, maxLatlon.lon() + enlargeDegree)).getEastNorth( ));148 Math.min(180, maxLatlon.lon() + enlargeDegree)).getEastNorth(Main.getProjection())); 144 149 } 145 150 146 151 /** -
src/org/openstreetmap/josm/data/projection/Projections.java
18 18 19 19 import org.openstreetmap.josm.Main; 20 20 import org.openstreetmap.josm.data.coor.EastNorth; 21 import org.openstreetmap.josm.data.coor.ILatLon; 21 22 import org.openstreetmap.josm.data.coor.LatLon; 22 23 import org.openstreetmap.josm.data.projection.datum.Datum; 23 24 import org.openstreetmap.josm.data.projection.datum.GRS80Datum; … … 191 192 * 192 193 * @param ll the geographical point to convert (in WGS84 lat/lon) 193 194 * @return the corresponding east/north coordinates 195 * @since xxx 194 196 */ 195 public static EastNorth project( LatLon ll) {197 public static EastNorth project(ILatLon ll) { 196 198 if (ll == null) return null; 197 199 return Main.getProjection().latlon2eastNorth(ll); 198 200 } 199 201 200 202 /** 203 * Convert from lat/lon to easting/northing using the current projection. 204 * 205 * @param ll the geographical point to convert (in WGS84 lat/lon) 206 * @return the corresponding east/north coordinates 207 */ 208 public static EastNorth project(LatLon ll) { 209 return project((ILatLon) ll); 210 } 211 212 /** 201 213 * Convert from easting/norting to lat/lon using the current projection. 202 214 * 203 215 * @param en the geographical point to convert (in projected coordinates) -
src/org/openstreetmap/josm/gui/MapViewState.java
394 394 private static EastNorth calculateDefaultCenter() { 395 395 Bounds b = Optional.ofNullable(DownloadDialog.getSavedDownloadBounds()).orElseGet( 396 396 () -> Main.getProjection().getWorldBoundsLatLon()); 397 return b.getCenter().getEastNorth( );397 return b.getCenter().getEastNorth(Main.getProjection()); 398 398 } 399 399 400 400 /** -
src/org/openstreetmap/josm/gui/NavigatableComponent.java
515 515 * @param latlon The point, where this geopoint would be drawn. 516 516 * @return The point on screen where "point" would be drawn, relative to the own top/left. 517 517 */ 518 public Point2D getPoint2D( LatLon latlon) {518 public Point2D getPoint2D(ILatLon latlon) { 519 519 if (latlon == null) { 520 520 return new Point(); 521 521 } else { 522 return getPoint2D(latlon.getEastNorth( ));522 return getPoint2D(latlon.getEastNorth(Main.getProjection())); 523 523 } 524 524 } 525 525 526 526 /** 527 * Return the point on the screen where this Coordinate would be. 528 * 529 * Alternative: {@link #getState()}, then {@link MapViewState#getPointFor(ILatLon)} 530 * @param latlon The point, where this geopoint would be drawn. 531 * @return The point on screen where "point" would be drawn, relative to the own top/left. 532 */ 533 public Point2D getPoint2D(LatLon latlon) { 534 return getPoint2D((ILatLon) latlon); 535 } 536 537 /** 527 538 * Return the point on the screen where this Node would be. 528 539 * 529 540 * Alternative: {@link #getState()}, then {@link MapViewState#getPointFor(ILatLon)} … … 550 561 * @param latlon lat/lon 551 562 * @return point 552 563 * @see #getPoint2D(LatLon) 564 * @since xxx 553 565 */ 554 public Point getPoint( LatLon latlon) {566 public Point getPoint(ILatLon latlon) { 555 567 Point2D d = getPoint2D(latlon); 556 568 return new Point((int) d.getX(), (int) d.getY()); 557 569 } … … 558 570 559 571 /** 560 572 * looses precision, may overflow (depends on p and current scale) 573 * @param latlon lat/lon 574 * @return point 575 * @see #getPoint2D(LatLon) 576 */ 577 public Point getPoint(LatLon latlon) { 578 return getPoint((ILatLon) latlon); 579 } 580 581 /** 582 * looses precision, may overflow (depends on p and current scale) 561 583 * @param n node 562 584 * @return point 563 585 * @see #getPoint2D(Node) … … 689 711 /** 690 712 * Zoom to given lat/lon. 691 713 * @param newCenter new center coordinates 714 * @since xxx 692 715 */ 693 public void zoomTo( LatLon newCenter) {716 public void zoomTo(ILatLon newCenter) { 694 717 zoomTo(Projections.project(newCenter)); 695 718 } 696 719 697 720 /** 721 * Zoom to given lat/lon. 722 * @param newCenter new center coordinates 723 */ 724 public void zoomTo(LatLon newCenter) { 725 zoomTo((ILatLon) newCenter); 726 } 727 728 /** 698 729 * Create a thread that moves the viewport to the given center in an animated fashion. 699 730 * @param newCenter new east/north center 700 731 */ -
src/org/openstreetmap/josm/gui/datatransfer/data/PrimitiveTransferData.java
131 131 BoundingXYVisitor visitor = new BoundingXYVisitor(); 132 132 for (PrimitiveData pd : getAll()) { 133 133 if (pd instanceof NodeData && !pd.isIncomplete()) { 134 visitor.visit(((NodeData) pd) .getEastNorth());134 visitor.visit(((NodeData) pd)); 135 135 } 136 136 } 137 137 ProjectionBounds bounds = visitor.getBounds(); -
src/org/openstreetmap/josm/gui/datatransfer/importers/PrimitiveDataPaster.java
72 72 try { 73 73 if (data instanceof NodeData) { 74 74 NodeData nodeData = (NodeData) data; 75 nodeData.setEastNorth(nodeData.getEastNorth( ).add(offset));75 nodeData.setEastNorth(nodeData.getEastNorth(Main.getProjection()).add(offset)); 76 76 } else if (data instanceof WayData) { 77 77 updateNodes(newIds.get(OsmPrimitiveType.NODE), data); 78 78 } else if (data instanceof RelationData) { -
src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java
190 190 BBox bbox = o.getBBox(); 191 191 if (bbox != null) { 192 192 add(tr("Bounding box: "), bbox.toStringCSV(", ")); 193 EastNorth bottomRigth = bbox.getBottomRight().getEastNorth( );194 EastNorth topLeft = bbox.getTopLeft().getEastNorth( );193 EastNorth bottomRigth = bbox.getBottomRight().getEastNorth(Main.getProjection()); 194 EastNorth topLeft = bbox.getTopLeft().getEastNorth(Main.getProjection()); 195 195 add(tr("Bounding box (projected): "), 196 196 Double.toString(topLeft.east()), ", ", 197 197 Double.toString(bottomRigth.north()), ", ", -
src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
650 650 old = null; 651 651 continue; 652 652 } 653 Point screen = mv.getPoint(trkPnt .getEastNorth());653 Point screen = mv.getPoint(trkPnt); 654 654 // skip points that are on the same screenposition 655 655 if (trkPnt.drawLine && old != null && ((old.x != screen.x) || (old.y != screen.y))) { 656 656 g.setColor(trkPnt.customColoring); … … 680 680 continue; 681 681 } 682 682 if (trkPnt.drawLine) { 683 Point screen = mv.getPoint(trkPnt .getEastNorth());683 Point screen = mv.getPoint(trkPnt); 684 684 // skip points that are on the same screenposition 685 685 if (old != null 686 686 && (oldA == null || screen.x < oldA.x - delta || screen.x > oldA.x + delta … … 710 710 continue; 711 711 } 712 712 if (trkPnt.drawLine) { 713 Point screen = mv.getPoint(trkPnt .getEastNorth());713 Point screen = mv.getPoint(trkPnt); 714 714 // skip points that are on the same screenposition 715 715 if (old != null 716 716 && (oldA == null || screen.x < oldA.x - delta || screen.x > oldA.x + delta … … 745 745 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 746 746 continue; 747 747 } 748 Point screen = mv.getPoint(trkPnt .getEastNorth());748 Point screen = mv.getPoint(trkPnt); 749 749 750 750 if (hdopCircle && trkPnt.get(GpxConstants.PT_HDOP) != null) { 751 751 // hdop value … … 786 786 continue; 787 787 } 788 788 if (!trkPnt.drawLine) { 789 Point screen = mv.getPoint(trkPnt .getEastNorth());789 Point screen = mv.getPoint(trkPnt); 790 790 g.drawRect(screen.x, screen.y, 0, 0); 791 791 } 792 792 } // end for trkpnt … … 802 802 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 803 803 continue; 804 804 } 805 Point screen = mv.getPoint(trkPnt .getEastNorth());805 Point screen = mv.getPoint(trkPnt); 806 806 g.setColor(trkPnt.customColoring); 807 807 g.drawRect(screen.x, screen.y, 0, 0); 808 808 } // end for trkpnt … … 852 852 for (WayPoint trkPnt : visibleSegments) { 853 853 854 854 // transform coordinates 855 final Point paintPnt = mv.getPoint(trkPnt .getEastNorth());855 final Point paintPnt = mv.getPoint(trkPnt); 856 856 857 857 // skip single points 858 858 if (lastPaintPnt != null && trkPnt.drawLine && !lastPaintPnt.equals(paintPnt)) { … … 1111 1111 for (WayPoint trkPnt : listSegm) { 1112 1112 1113 1113 // get transformed coordinates 1114 final Point paintPnt = mv.getPoint(trkPnt .getEastNorth());1114 final Point paintPnt = mv.getPoint(trkPnt); 1115 1115 1116 1116 // end of line segment or end of list reached 1117 1117 if (!trkPnt.drawLine || (lastPnt == trkPnt)) { … … 1361 1361 for (WayPoint trkPnt : listSegm) { 1362 1362 1363 1363 // get transformed coordinates 1364 final Point paintPnt = mv.getPoint(trkPnt .getEastNorth());1364 final Point paintPnt = mv.getPoint(trkPnt); 1365 1365 1366 1366 // end of line segment or end of list reached 1367 1367 if (trkPnt.drawLine && null != lastPnt) { -
src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java
186 186 if (waypoints.contains(w)) { 187 187 continue; 188 188 } 189 WayPoint wNear = layer.data.nearestPointOnTrack(w.getEastNorth( ), snapDistance);189 WayPoint wNear = layer.data.nearestPointOnTrack(w.getEastNorth(Main.getProjection()), snapDistance); 190 190 if (wNear != null) { 191 191 WayPoint wc = new WayPoint(w.getCoor()); 192 192 wc.time = wNear.time; -
src/org/openstreetmap/josm/gui/layer/markerlayer/ButtonMarker.java
38 38 } 39 39 40 40 @Override public boolean containsPoint(Point p) { 41 Point screen = MainApplication.getMap().mapView.getPoint( getEastNorth());41 Point screen = MainApplication.getMap().mapView.getPoint(this); 42 42 buttonRectangle.setLocation(screen.x+4, screen.y+2); 43 43 return buttonRectangle.contains(p); 44 44 } … … 48 48 super.paint(g, mv, mousePressed, showTextOrIcon); 49 49 return; 50 50 } 51 Point screen = mv.getPoint( getEastNorth());51 Point screen = mv.getPoint(this); 52 52 buttonRectangle.setLocation(screen.x+4, screen.y+2); 53 53 paintIcon(mv, g, screen.x+4, screen.y+2); 54 54 Border b; -
src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java
22 22 23 23 import javax.swing.ImageIcon; 24 24 25 import org.openstreetmap.josm.Main; 25 26 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent; 26 27 import org.openstreetmap.josm.data.coor.CachedLatLon; 27 28 import org.openstreetmap.josm.data.coor.EastNorth; 29 import org.openstreetmap.josm.data.coor.ILatLon; 28 30 import org.openstreetmap.josm.data.coor.LatLon; 29 31 import org.openstreetmap.josm.data.gpx.GpxConstants; 30 32 import org.openstreetmap.josm.data.gpx.WayPoint; … … 74 76 * 75 77 * @author Frederik Ramm 76 78 */ 77 public class Marker implements TemplateEngineDataProvider {79 public class Marker implements TemplateEngineDataProvider, ILatLon { 78 80 79 81 public static final class TemplateEntryProperty extends CachedProperty<TemplateEntry> { 80 82 // This class is a bit complicated because it supports both global and per layer settings. I've added per layer settings because … … 317 319 } 318 320 319 321 /** 322 * @since xxx 323 */ 324 @Override 325 public double lon() { 326 return coor == null ? Double.NaN : coor.lon(); 327 } 328 329 /** 330 * @since xxx 331 */ 332 @Override 333 public double lat() { 334 return coor == null ? Double.NaN : coor.lat(); 335 } 336 337 /** 320 338 * Returns the marker's projected coordinates. 321 339 * @return The marker's projected coordinates (easting/northing) 340 * @deprecated use {@link #getEastNorth(org.openstreetmap.josm.data.projection.Projecting)} 322 341 */ 342 @Deprecated 323 343 public final EastNorth getEastNorth() { 324 return coor.getEastNorth( );344 return coor.getEastNorth(Main.getProjection()); 325 345 } 326 346 327 347 /** … … 353 373 * @param showTextOrIcon true if text and icon shall be drawn 354 374 */ 355 375 public void paint(Graphics g, MapView mv, boolean mousePressed, boolean showTextOrIcon) { 356 Point screen = mv.getPoint( getEastNorth());376 Point screen = mv.getPoint(this); 357 377 if (symbol != null && showTextOrIcon) { 358 378 paintIcon(mv, g, screen.x-symbol.getIconWidth()/2, screen.y-symbol.getIconHeight()/2); 359 379 } else { -
src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
210 210 211 211 @Override public void visitBoundingBox(BoundingXYVisitor v) { 212 212 for (Marker mkr : data) { 213 v.visit(mkr .getEastNorth());213 v.visit(mkr); 214 214 } 215 215 } 216 216 … … 351 351 } 352 352 } 353 353 } 354 MainApplication.getMap().mapView.zoomTo(currentMarker .getEastNorth());354 MainApplication.getMap().mapView.zoomTo(currentMarker); 355 355 } 356 356 357 357 @Override … … 370 370 } 371 371 } 372 372 } 373 MainApplication.getMap().mapView.zoomTo(currentMarker .getEastNorth());373 MainApplication.getMap().mapView.zoomTo(currentMarker); 374 374 } 375 375 376 376 public static void playAudio() { -
src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
84 84 85 85 @Override 86 86 public boolean containsPoint(Point p) { 87 Point screen = MainApplication.getMap().mapView.getPoint( getEastNorth());87 Point screen = MainApplication.getMap().mapView.getPoint(this); 88 88 Rectangle r = new Rectangle(screen.x, screen.y, symbol.getIconWidth(), 89 89 symbol.getIconHeight()); 90 90 return r.contains(p); … … 213 213 double closestAudioMarkerDistanceSquared = 1.0E100; 214 214 for (Marker m : recent.parentLayer.data) { 215 215 if (m instanceof AudioMarker) { 216 double distanceSquared = m.getEastNorth( ).distanceSq(en);216 double distanceSquared = m.getEastNorth(Main.getProjection()).distanceSq(en); 217 217 if (distanceSquared < closestAudioMarkerDistanceSquared) { 218 218 ca = (AudioMarker) m; 219 219 closestAudioMarkerDistanceSquared = distanceSquared; … … 282 282 */ 283 283 public void paint(Graphics g, MapView mv) { 284 284 if (time < 0.0) return; 285 Point screen = mv.getPoint( getEastNorth());285 Point screen = mv.getPoint(this); 286 286 paintIcon(mv, g, screen.x, screen.y); 287 287 } 288 288 … … 346 346 if (w1 == null) 347 347 return; 348 348 setEastNorth(w2 == null ? 349 w1.getEastNorth( ) :350 w1.getEastNorth( ).interpolate(w2.getEastNorth(),349 w1.getEastNorth(Main.getProjection()) : 350 w1.getEastNorth(Main.getProjection()).interpolate(w2.getEastNorth(Main.getProjection()), 351 351 (audioTime - w1.time)/(w2.time - w1.time))); 352 352 time = audioTime; 353 353 MapView mapView = MainApplication.getMap().mapView; 354 354 if (jumpToMarker) { 355 355 jumpToMarker = false; 356 mapView.zoomTo(w1 .getEastNorth());356 mapView.zoomTo(w1); 357 357 } 358 358 mapView.repaint(); 359 359 }