- Timestamp:
- 2022-06-15T19:27:05+02:00 (2 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AddNodeAction.java
r17188 r18494 75 75 ds.setSelected(nnew); 76 76 MapView mapView = MainApplication.getMap().mapView; 77 if (mapView != null && !mapView.getRealBounds().contains(nnew .getCoor())) {77 if (mapView != null && !mapView.getRealBounds().contains(nnew)) { 78 78 AutoScaleAction.zoomTo(Collections.<OsmPrimitive>singleton(nnew)); 79 79 } -
trunk/src/org/openstreetmap/josm/actions/CopyCoordinatesAction.java
r17036 r18494 40 40 ICoordinateFormat coordinateFormat = CoordinateFormatManager.getDefaultFormat(); 41 41 String string = getSelectedNodes().stream() 42 .map(Node::getCoor)43 42 .filter(Objects::nonNull) 44 43 .map(c -> coordinateFormat.toString(c, ", ")) -
trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
r18217 r18494 192 192 193 193 // see #10777 194 LatLon ll1 = ProjectionRegistry.getProjection().eastNorth2latlon(n1);195 194 LatLon ll2 = ProjectionRegistry.getProjection().eastNorth2latlon(center); 196 195 197 double radiusInMeters = ll1.greatCircleDistance(ll2);196 double radiusInMeters = nodes.get(0).greatCircleDistance(ll2); 198 197 199 198 int numberOfNodesInCircle = (int) Math.ceil(6.0 * Math.pow(radiusInMeters, 0.5)); -
trunk/src/org/openstreetmap/josm/actions/DownloadAlongAction.java
r17419 r18494 23 23 24 24 import org.openstreetmap.josm.actions.downloadtasks.DownloadTaskList; 25 import org.openstreetmap.josm.data.coor.ILatLon; 25 26 import org.openstreetmap.josm.data.coor.LatLon; 26 27 import org.openstreetmap.josm.data.osm.DataSet; … … 161 162 ArrayList<LatLon> intermediateNodes = new ArrayList<>(); 162 163 intermediateNodes.add(p2); 163 if (p1 != null && p2.greatCircleDistance( p1) > bufferDist) {164 double d = p2.greatCircleDistance( p1) / bufferDist;164 if (p1 != null && p2.greatCircleDistance((ILatLon) p1) > bufferDist) { 165 double d = p2.greatCircleDistance((ILatLon) p1) / bufferDist; 165 166 int nbNodes = (int) d; 166 167 if (Logging.isDebugEnabled()) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawSnapHelper.java
r17632 r18494 389 389 // find out the distance, in metres, between the base point and projected point 390 390 LatLon mouseLatLon = mapView.getProjection().eastNorth2latlon(snapPoint); 391 double distance = this.drawAction.getCurrentBaseNode().g etCoor().greatCircleDistance(mouseLatLon);391 double distance = this.drawAction.getCurrentBaseNode().greatCircleDistance(mouseLatLon); 392 392 double hdg = Utils.toDegrees(p0.heading(snapPoint)); 393 393 // heading of segment from current to calculated point, not to mouse position -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r18332 r18494 38 38 import org.openstreetmap.josm.data.UndoRedoHandler; 39 39 import org.openstreetmap.josm.data.coor.EastNorth; 40 import org.openstreetmap.josm.data.coor.ILatLon; 40 41 import org.openstreetmap.josm.data.osm.DataIntegrityProblemException; 41 42 import org.openstreetmap.josm.data.osm.DataSet; … … 938 939 // find out the movement distance, in metres 939 940 double distance = ProjectionRegistry.getProjection().eastNorth2latlon(initialN1en).greatCircleDistance( 940 ProjectionRegistry.getProjection().eastNorth2latlon(n1movedEn));941 (ILatLon) ProjectionRegistry.getProjection().eastNorth2latlon(n1movedEn)); 941 942 MainApplication.getMap().statusLine.setDist(distance); 942 943 updateStatusLine(); -
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
r18129 r18494 28 28 import org.openstreetmap.josm.data.SystemOfMeasurement; 29 29 import org.openstreetmap.josm.data.coor.EastNorth; 30 import org.openstreetmap.josm.data.coor.ILatLon; 30 31 import org.openstreetmap.josm.data.osm.Node; 31 32 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 392 393 // Note: d is the distance in _projected units_ 393 394 double d = enp.distance(nearestPointOnRefLine); 394 double realD = mv.getProjection().eastNorth2latlon(enp).greatCircleDistance(mv.getProjection().eastNorth2latlon(nearestPointOnRefLine)); 395 double realD = mv.getProjection().eastNorth2latlon(enp).greatCircleDistance( 396 (ILatLon) mv.getProjection().eastNorth2latlon(nearestPointOnRefLine)); 395 397 double snappedRealD = realD; 396 398 -
trunk/src/org/openstreetmap/josm/command/MoveCommand.java
r17093 r18494 16 16 17 17 import org.openstreetmap.josm.data.coor.EastNorth; 18 import org.openstreetmap.josm.data.coor.ILatLon; 18 19 import org.openstreetmap.josm.data.coor.LatLon; 19 20 import org.openstreetmap.josm.data.osm.DataSet; … … 314 315 return nodes.stream() 315 316 .filter(predicate) 316 .filter( node -> node.getCoor() != null && node.getEastNorth() != null)317 .filter(ILatLon::isLatLonKnown /* If the node latlon is known, then the eastnorth cannot be null */) 317 318 .findFirst() 318 319 .map(node -> { 319 320 final Node old = new Node(node); 320 321 old.setEastNorth(old.getEastNorth().add(-x, -y)); 321 return node.g etCoor().greatCircleDistance(old.getCoor());322 return node.greatCircleDistance(old); 322 323 }).orElse(Double.NaN); 323 324 } -
trunk/src/org/openstreetmap/josm/data/coor/ILatLon.java
r18464 r18494 2 2 package org.openstreetmap.josm.data.coor; 3 3 4 import static java.lang.Math.PI; 5 import static java.lang.Math.asin; 6 import static java.lang.Math.atan2; 7 import static java.lang.Math.cos; 8 import static java.lang.Math.sin; 9 import static java.lang.Math.sqrt; 10 import static org.openstreetmap.josm.data.projection.Ellipsoid.WGS84; 11 import static org.openstreetmap.josm.tools.Utils.toRadians; 12 4 13 import org.openstreetmap.josm.data.projection.Projecting; 14 import org.openstreetmap.josm.tools.Logging; 5 15 6 16 /** … … 81 91 return Math.abs(lat() - other.lat()) <= p && Math.abs(lon() - other.lon()) <= p; 82 92 } 93 94 /** 95 * Computes the distance between this lat/lon and another point on the earth. 96 * Uses <a href="https://en.wikipedia.org/wiki/Haversine_formula">Haversine formula</a>. 97 * @param other the other point. 98 * @return distance in metres. 99 * @since xxx (extracted from {@link LatLon}) 100 */ 101 default double greatCircleDistance(ILatLon other) { 102 double sinHalfLat = sin(toRadians(other.lat() - this.lat()) / 2); 103 double sinHalfLon = sin(toRadians(other.lon() - this.lon()) / 2); 104 double d = 2 * WGS84.a * asin( 105 sqrt(sinHalfLat*sinHalfLat + 106 cos(toRadians(this.lat()))*cos(toRadians(other.lat()))*sinHalfLon*sinHalfLon)); 107 // For points opposite to each other on the sphere, 108 // rounding errors could make the argument of asin greater than 1 109 // (This should almost never happen.) 110 if (Double.isNaN(d)) { 111 Logging.error("NaN in greatCircleDistance: {0} {1}", this, other); 112 d = PI * WGS84.a; 113 } 114 return d; 115 } 116 117 /** 118 * Returns bearing from this point to another. 119 * 120 * Angle starts from north and increases clockwise, PI/2 means east. 121 * 122 * Please note that reverse bearing (from other point to this point) should NOT be 123 * calculated from return value of this method, because great circle path 124 * between the two points have different bearings at each position. 125 * 126 * To get bearing from another point to this point call other.bearing(this) 127 * 128 * @param other the "destination" position 129 * @return heading in radians in the range 0 <= hd < 2*PI 130 * @since xxx (extracted from {@link LatLon}, added in 9796) 131 */ 132 default double bearing(ILatLon other) { 133 double lat1 = toRadians(this.lat()); 134 double lat2 = toRadians(other.lat()); 135 double dlon = toRadians(other.lon() - this.lon()); 136 double bearing = atan2( 137 sin(dlon) * cos(lat2), 138 cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dlon) 139 ); 140 bearing %= 2 * PI; 141 if (bearing < 0) { 142 bearing += 2 * PI; 143 } 144 return bearing; 145 } 83 146 } -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r18464 r18494 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.coor; 3 4 import static java.lang.Math.PI;5 import static java.lang.Math.asin;6 import static java.lang.Math.atan2;7 import static java.lang.Math.cos;8 import static java.lang.Math.sin;9 import static java.lang.Math.sqrt;10 import static org.openstreetmap.josm.data.projection.Ellipsoid.WGS84;11 import static org.openstreetmap.josm.tools.Utils.toRadians;12 3 13 4 import java.awt.geom.Area; … … 20 11 import org.openstreetmap.josm.data.osm.Node; 21 12 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 22 import org.openstreetmap.josm.tools.Logging;23 13 import org.openstreetmap.josm.tools.Utils; 24 14 … … 229 219 * @param other the other point. 230 220 * @return distance in metres. 231 */ 221 * @deprecated since xxx (use {@link ILatLon#greatCircleDistance(ILatLon)} instead) 222 */ 223 @Deprecated 232 224 public double greatCircleDistance(LatLon other) { 233 double sinHalfLat = sin(toRadians(other.lat() - this.lat()) / 2); 234 double sinHalfLon = sin(toRadians(other.lon() - this.lon()) / 2); 235 double d = 2 * WGS84.a * asin( 236 sqrt(sinHalfLat*sinHalfLat + 237 cos(toRadians(this.lat()))*cos(toRadians(other.lat()))*sinHalfLon*sinHalfLon)); 238 // For points opposite to each other on the sphere, 239 // rounding errors could make the argument of asin greater than 1 240 // (This should almost never happen.) 241 if (Double.isNaN(d)) { 242 Logging.error("NaN in greatCircleDistance: {0} {1}", this, other); 243 d = PI * WGS84.a; 244 } 245 return d; 225 return ILatLon.super.greatCircleDistance(other); 246 226 } 247 227 … … 260 240 * @return heading in radians in the range 0 <= hd < 2*PI 261 241 * @since 9796 262 */ 242 * @deprecated since xxx (use {@link ILatLon#bearing(ILatLon)} instead) 243 */ 244 @Deprecated 263 245 public double bearing(LatLon other) { 264 double lat1 = toRadians(this.lat()); 265 double lat2 = toRadians(other.lat()); 266 double dlon = toRadians(other.lon() - this.lon()); 267 double bearing = atan2( 268 sin(dlon) * cos(lat2), 269 cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dlon) 270 ); 271 bearing %= 2 * PI; 272 if (bearing < 0) { 273 bearing += 2 * PI; 274 } 275 return bearing; 246 return ILatLon.super.bearing(other); 276 247 } 277 248 -
trunk/src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java
r18243 r18494 7 7 import java.util.concurrent.TimeUnit; 8 8 9 import org.openstreetmap.josm.data.coor.ILatLon; 9 10 import org.openstreetmap.josm.data.coor.LatLon; 10 11 import org.openstreetmap.josm.data.projection.Projection; … … 92 93 List<Pair<Double, WayPoint>> nextWps = new ArrayList<>(); 93 94 for (int j = i; j < size; j++) { 94 totalDist += wps.get(j - 1).g etCoor().greatCircleDistance(wps.get(j).getCoor());95 totalDist += wps.get(j - 1).greatCircleDistance(wps.get(j)); 95 96 nextWps.add(new Pair<>(totalDist, wps.get(j))); 96 97 if (wps.get(j).hasDate()) { … … 121 122 if (!trkInt || isFirst || prevWp == null || 122 123 Math.abs(curWpTime - prevWpTime) > TimeUnit.MINUTES.toMillis(trkTime) || 123 prevWp.g etCoor().greatCircleDistance(curWp.getCoor()) > trkDist) {124 prevWp.greatCircleDistance(curWp) > trkDist) { 124 125 isFirst = false; 125 126 interpolate = false; … … 132 133 if (!segInt || prevWp == null || 133 134 Math.abs(curWpTime - prevWpTime) > TimeUnit.MINUTES.toMillis(segTime) || 134 prevWp.g etCoor().greatCircleDistance(curWp.getCoor()) > segDist) {135 prevWp.greatCircleDistance(curWp) > segDist) { 135 136 interpolate = false; 136 137 if (segTag) { … … 238 239 239 240 if (prevWp != null && interpolate) { 240 double distance = prevWp.g etCoor().greatCircleDistance(curWp.getCoor());241 double distance = prevWp.greatCircleDistance(curWp); 241 242 // This is in km/h, 3.6 * m/s 242 243 if (curWpTime > prevWpTime) { … … 267 268 } 268 269 if (nextWp != null && dirpos.isSetImageDirection()) { 269 double direction = curWp. getCoor().bearing(nextWp.getCoor());270 double direction = curWp.bearing(nextWp); 270 271 curTmp.setExifImgDir(computeDirection(direction, dirpos.getImageDirectionAngleOffset())); 271 272 } … … 298 299 LatLon position = prevCoor.interpolate(curCoor, timeDiff); 299 300 if (nextCoorForDirection != null && (shiftXY || dirpos.isSetImageDirection())) { 300 double direction = position.bearing( nextCoorForDirection);301 double direction = position.bearing((ILatLon) nextCoorForDirection); 301 302 if (dirpos.isSetImageDirection()) { 302 303 curTmp.setExifImgDir(computeDirection(direction, dirpos.getImageDirectionAngleOffset())); … … 307 308 final double offsetY = dirpos.getShiftImageY(); 308 309 final double r = Math.sqrt(offsetX * offsetX + offsetY * offsetY); 309 final double orientation = (direction + LatLon.ZERO.bearing( new LatLon(offsetX, offsetY))) % (2 * Math.PI);310 final double orientation = (direction + LatLon.ZERO.bearing((ILatLon) new LatLon(offsetX, offsetY))) % (2 * Math.PI); 310 311 position = proj.eastNorth2latlon(proj.latlon2eastNorth(position) 311 312 .add(r * Math.sin(orientation), r * Math.cos(orientation))); -
trunk/src/org/openstreetmap/josm/data/gpx/GpxTrackSegment.java
r16488 r18494 47 47 for (WayPoint tpt : wayPoints) { 48 48 if (last != null) { 49 Double d = last.g etCoor().greatCircleDistance(tpt.getCoor());49 Double d = last.greatCircleDistance(tpt); 50 50 if (!d.isNaN() && !d.isInfinite()) { 51 51 result += d; -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r18464 r18494 373 373 */ 374 374 public boolean isOutSideWorld() { 375 LatLon ll = getCoor(); 376 if (ll != null) { 375 if (this.isLatLonKnown()) { 377 376 Bounds b = ProjectionRegistry.getProjection().getWorldBoundsLatLon(); 378 377 if (lat() < b.getMinLat() || lat() > b.getMaxLat() || lon() < b.getMinLon() || lon() > b.getMaxLon()) { 379 378 return true; 380 379 } 381 if (!ProjectionRegistry.getProjection().latlon2eastNorth( ll).equalsEpsilon(getEastNorth(), 1.0)) {380 if (!ProjectionRegistry.getProjection().latlon2eastNorth(this).equalsEpsilon(getEastNorth(), 1.0)) { 382 381 // we get here if a node was moved or created left from -180 or right from +180 383 382 return true; -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r18470 r18494 13 13 import java.util.stream.IntStream; 14 14 15 import org.openstreetmap.josm.data.coor. LatLon;15 import org.openstreetmap.josm.data.coor.ILatLon; 16 16 import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor; 17 17 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; … … 632 632 633 633 /** 634 * Replies the length of the way, in metres, as computed by {@link LatLon#greatCircleDistance}.634 * Replies the length of the way, in metres, as computed by {@link ILatLon#greatCircleDistance}. 635 635 * @return The length of the way, in metres 636 636 * @since 4138 … … 640 640 Node lastN = null; 641 641 for (Node n:nodes) { 642 if (lastN != null) { 643 LatLon lastNcoor = lastN.getCoor(); 644 LatLon coor = n.getCoor(); 645 if (lastNcoor != null && coor != null) { 646 length += coor.greatCircleDistance(lastNcoor); 647 } 642 if (lastN != null && lastN.isLatLonKnown() && n.isLatLonKnown()) { 643 length += n.greatCircleDistance(lastN); 648 644 } 649 645 lastN = n; … … 653 649 654 650 /** 655 * Replies the length of the longest segment of the way, in metres, as computed by {@link LatLon#greatCircleDistance}.651 * Replies the length of the longest segment of the way, in metres, as computed by {@link ILatLon#greatCircleDistance}. 656 652 * @return The length of the segment, in metres 657 653 * @since 8320 … … 661 657 Node lastN = null; 662 658 for (Node n:nodes) { 663 if (lastN != null) { 664 LatLon lastNcoor = lastN.getCoor(); 665 LatLon coor = n.getCoor(); 666 if (lastNcoor != null && coor != null) { 667 double l = coor.greatCircleDistance(lastNcoor); 668 if (l > length) { 669 length = l; 670 } 659 if (lastN != null && lastN.isLatLonKnown() && n.isLatLonKnown()) { 660 double l = n.greatCircleDistance(lastN); 661 if (l > length) { 662 length = l; 671 663 } 672 664 } -
trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java
r18291 r18494 29 29 30 30 import org.openstreetmap.josm.data.Bounds; 31 import org.openstreetmap.josm.data.coor.LatLon;32 31 import org.openstreetmap.josm.data.osm.Node; 33 32 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 1809 1808 return false; 1810 1809 else if (osm instanceof Node) { 1811 LatLon coordinate = ((Node) osm).getCoor();1812 1810 Collection<Bounds> allBounds = getBounds(osm); 1813 return coordinate != null && allBounds != null && allBounds.stream().anyMatch(bounds -> bounds.contains(coordinate));1811 return ((Node) osm).isLatLonKnown() && allBounds != null && allBounds.stream().anyMatch(bounds -> bounds.contains((Node) osm)); 1814 1812 } else if (osm instanceof Way) { 1815 1813 Collection<Node> nodes = ((Way) osm).getNodes(); -
trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
r16643 r18494 19 19 import org.openstreetmap.josm.data.ProjectionBounds; 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.coor.conversion.LatLonParser; … … 808 809 // project back and check if the result is somewhat reasonable 809 810 LatLon llBack = eastNorth2latlon(enPole); 810 if (llBack.isValid() && ll.greatCircleDistance( llBack) < 1000) {811 if (llBack.isValid() && ll.greatCircleDistance((ILatLon) llBack) < 1000) { 811 812 polesEN.put(p, enPole); 812 813 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java
r18332 r18494 23 23 import org.openstreetmap.josm.command.DeleteCommand; 24 24 import org.openstreetmap.josm.data.coor.EastNorth; 25 import org.openstreetmap.josm.data.coor.ILatLon; 25 26 import org.openstreetmap.josm.data.coor.LatLon; 26 27 import org.openstreetmap.josm.data.osm.Node; … … 362 363 */ 363 364 static double getDistance(OsmPrimitive a, OsmPrimitive b) { 364 LatLon centerA = a.getBBox().getCenter(); 365 LatLon centerB = b.getBBox().getCenter(); 365 if (a instanceof ILatLon && b instanceof ILatLon) { 366 return ((ILatLon) a).greatCircleDistance((ILatLon) b); 367 } 368 ILatLon centerA = a.getBBox().getCenter(); 369 ILatLon centerB = b.getBBox().getCenter(); 366 370 return centerA.greatCircleDistance(centerB); 367 371 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/LongSegment.java
r17896 r18494 9 9 import java.util.Set; 10 10 11 import org.openstreetmap.josm.data.coor.LatLon;12 11 import org.openstreetmap.josm.data.osm.Node; 13 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 92 91 93 92 private void visitWaySegment(Way w, int i) { 94 LatLon coor1 = w.getNode(i).getCoor();95 LatLon coor2 = w.getNode(i + 1).getCoor();93 Node oneI = w.getNode(i); 94 Node twoI = w.getNode(i + 1); 96 95 97 if ( coor1 != null && coor2 != null) {98 Double length = coor1.greatCircleDistance(coor2);96 if (oneI.isLatLonKnown() && twoI.isLatLonKnown()) { 97 double length = oneI.greatCircleDistance(twoI); 99 98 if (length > maxlength) { 100 99 addErrorForSegment(new WaySegment(w, i), length / 1000.0); -
trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java
r18272 r18494 469 469 LatLon cl = ProjectionRegistry.getProjection().eastNorth2latlon(calcClosest(uncon)); 470 470 // calculate real detour length, closest point might be somewhere between n1 and n2 471 double detourLen = len + node.g etCoor().greatCircleDistance(cl);471 double detourLen = len + node.greatCircleDistance(cl); 472 472 if (detourLen > maxLen) 473 473 return false; … … 501 501 visited.add(next); 502 502 if (!containsN && isConnectedTo(next, visited, 503 len + node.g etCoor().greatCircleDistance(next.getCoor()), way)) {503 len + node.greatCircleDistance(next), way)) { 504 504 return true; 505 505 } … … 516 516 double getDist(Node n) { 517 517 EastNorth closest = calcClosest(n); 518 return n.g etCoor().greatCircleDistance(ProjectionRegistry.getProjection().eastNorth2latlon(closest));518 return n.greatCircleDistance(ProjectionRegistry.getProjection().eastNorth2latlon(closest)); 519 519 } 520 520 … … 527 527 528 528 private BBox getBounds(double fudge) { 529 double x1 = n1. getCoor().lon();530 double x2 = n2. getCoor().lon();529 double x1 = n1.lon(); 530 double x2 = n2.lon(); 531 531 if (x1 > x2) { 532 532 double tmpx = x1; … … 534 534 x2 = tmpx; 535 535 } 536 double y1 = n1. getCoor().lat();537 double y2 = n2. getCoor().lat();536 double y1 = n1.lat(); 537 double y2 = n2.lat(); 538 538 if (y1 > y2) { 539 539 double tmpy = y1; -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r18211 r18494 62 62 import org.openstreetmap.josm.data.SystemOfMeasurement; 63 63 import org.openstreetmap.josm.data.SystemOfMeasurement.SoMChangeListener; 64 import org.openstreetmap.josm.data.coor.ILatLon; 64 65 import org.openstreetmap.josm.data.coor.LatLon; 65 66 import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager; … … 71 72 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 72 73 import org.openstreetmap.josm.data.osm.IPrimitive; 73 import org.openstreetmap.josm.data.osm.Node;74 74 import org.openstreetmap.josm.data.osm.OsmPrimitive; 75 75 import org.openstreetmap.josm.data.osm.Way; … … 1221 1221 OsmPrimitive n2 = it.next(); 1222 1222 // show distance between two selected nodes with coordinates 1223 if (n1 instanceof Node && n2 instanceof Node) { 1224 LatLon c1 = ((Node) n1).getCoor(); 1225 LatLon c2 = ((Node) n2).getCoor(); 1226 if (c1 != null && c2 != null) { 1227 setDist(c1.greatCircleDistance(c2)); 1228 return; 1229 } 1223 if (n1 instanceof ILatLon && n2 instanceof ILatLon && ((ILatLon) n1).isLatLonKnown() && ((ILatLon) n2).isLatLonKnown()) { 1224 setDist(((ILatLon) n1).greatCircleDistance((ILatLon) n2)); 1225 return; 1230 1226 } 1231 1227 } -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r18211 r18494 399 399 int w = getWidth()/2; 400 400 int h = getHeight()/2; 401 LatLon ll1 = getLatLon(w-50, h);402 LatLon ll2 = getLatLon(w+50, h);401 ILatLon ll1 = getLatLon(w-50, h); 402 ILatLon ll2 = getLatLon(w+50, h); 403 403 double gcd = ll1.greatCircleDistance(ll2); 404 404 if (alwaysPositive && gcd <= 0) … … 649 649 LatLon ll2 = getLatLon(width / 2 + 50, height / 2); 650 650 if (ll1.isValid() && ll2.isValid() && b.contains(ll1) && b.contains(ll2)) { 651 double dm = ll1.greatCircleDistance( ll2);651 double dm = ll1.greatCircleDistance((ILatLon) ll2); 652 652 double den = 100 * getScale(); 653 653 double scaleMin = 0.01 * den / dm / 100; -
trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java
r17333 r18494 29 29 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 30 30 import org.openstreetmap.josm.data.Bounds; 31 import org.openstreetmap.josm.data.coor.ILatLon; 31 32 import org.openstreetmap.josm.data.coor.LatLon; 32 33 import org.openstreetmap.josm.data.osm.BBox; … … 168 169 ICoordinate c1 = getPosition(w - 50, h); 169 170 ICoordinate c2 = getPosition(w + 50, h); 170 final LatLon ll1 = new LatLon(c1.getLat(), c1.getLon());171 final LatLon ll2 = new LatLon(c2.getLat(), c2.getLon());171 final ILatLon ll1 = new LatLon(c1.getLat(), c1.getLon()); 172 final ILatLon ll2 = new LatLon(c2.getLat(), c2.getLon()); 172 173 double gcd = ll1.greatCircleDistance(ll2); 173 174 return gcd <= 0 ? 0.1 : gcd; -
trunk/src/org/openstreetmap/josm/gui/history/CoordinateInfoViewer.java
r17684 r18494 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.history; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 … … 24 25 import org.openstreetmap.josm.command.MoveCommand; 25 26 import org.openstreetmap.josm.data.UndoRedoHandler; 27 import org.openstreetmap.josm.data.coor.ILatLon; 26 28 import org.openstreetmap.josm.data.coor.LatLon; 27 29 import org.openstreetmap.josm.data.coor.conversion.DecimalDegreesCoordinateFormat; … … 408 410 final Pair<LatLon, LatLon> coordinates = updater.getCoordinates(); 409 411 if (coordinates == null) return; 410 final LatLon coord = coordinates.a;411 final LatLon oppositeCoord = coordinates.b;412 final ILatLon coord = coordinates.a; 413 final ILatLon oppositeCoord = coordinates.b; 412 414 413 415 // update distance -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
r18396 r18494 567 567 } 568 568 if (oldWp != null && trkPnt.getTimeInMillis() > oldWp.getTimeInMillis()) { 569 double vel = trkPnt.g etCoor().greatCircleDistance(oldWp.getCoor())569 double vel = trkPnt.greatCircleDistance(oldWp) 570 570 / (trkPnt.getTime() - oldWp.getTime()); 571 571 velocities.add(vel); … … 624 624 } 625 625 for (WayPoint trkPnt : segment) { 626 LatLon c = trkPnt.getCoor();627 626 trkPnt.customColoring = segment.getColor(); 628 if (Double.isNaN( c.lat()) || Double.isNaN(c.lon())) {627 if (Double.isNaN(trkPnt.lat()) || Double.isNaN(trkPnt.lon())) { 629 628 continue; 630 629 } … … 646 645 } 647 646 if (oldWp != null) { // other coloring modes need segment for calcuation 648 double dist = c.greatCircleDistance(oldWp.getCoor());647 double dist = trkPnt.greatCircleDistance(oldWp); 649 648 boolean noDraw = false; 650 649 switch (colored) { … … 658 657 break; 659 658 case DIRECTION: 660 double dirColor = oldWp. getCoor().bearing(trkPnt.getCoor());659 double dirColor = oldWp.bearing(trkPnt); 661 660 color = directionScale.getColor(dirColor); 662 661 break; … … 674 673 if (!noDraw && (!segment.isUnordered() || !data.fromServer) && (maxLineLength == -1 || dist <= maxLineLength)) { 675 674 trkPnt.drawLine = true; 676 double bearing = oldWp. getCoor().bearing(trkPnt.getCoor());675 double bearing = oldWp.bearing(trkPnt); 677 676 trkPnt.dir = ((int) (bearing / Math.PI * 4 + 1.5)) % 8; 678 677 } else { -
trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingCLI.java
r18366 r18494 27 27 import org.openstreetmap.josm.data.ProjectionBounds; 28 28 import org.openstreetmap.josm.data.coor.EastNorth; 29 import org.openstreetmap.josm.data.coor.ILatLon; 29 30 import org.openstreetmap.josm.data.coor.LatLon; 30 31 import org.openstreetmap.josm.data.coor.conversion.LatLonParser; … … 491 492 EastNorth projAnchorShifted = projAnchor.add(shiftMeter / proj.getMetersPerUnit(), 492 493 shiftMeter / proj.getMetersPerUnit()); 493 LatLon anchorShifted = proj.eastNorth2latlon(projAnchorShifted);494 ILatLon anchorShifted = proj.eastNorth2latlon(projAnchorShifted); 494 495 return projAnchor.distance(projAnchorShifted) / argAnchor.greatCircleDistance(anchorShifted); 495 496 }; … … 559 560 if (argScale != null) { 560 561 double enPerMeter = pb.getMin().distance(pb.getMax()) 561 / bounds.getMin().greatCircleDistance( bounds.getMax());562 / bounds.getMin().greatCircleDistance((ILatLon) bounds.getMax()); 562 563 scale = argScale * enPerMeter / PIXEL_PER_METER; 563 564 } else if (argWidthPx != null) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r18275 r18494 546 546 } else if (ChildOrParentSelectorType.SUPERSET_OR_EQUAL == type || ChildOrParentSelectorType.NOT_SUPERSET_OR_EQUAL == type) { 547 547 548 if (e.osm.getDataSet() == null || (e.osm instanceof INode && ((INode) e.osm).getCoor() == null)548 if (e.osm.getDataSet() == null || (e.osm instanceof INode && !((INode) e.osm).isLatLonKnown()) 549 549 || (!(e.osm instanceof INode) && !isArea(e.osm))) { 550 550 return ChildOrParentSelectorType.NOT_SUPERSET_OR_EQUAL == type; -
trunk/src/org/openstreetmap/josm/io/GeoJSONWriter.java
r18365 r18494 33 33 import org.openstreetmap.josm.data.Bounds; 34 34 import org.openstreetmap.josm.data.coor.EastNorth; 35 import org.openstreetmap.josm.data.coor.ILatLon; 35 36 import org.openstreetmap.josm.data.coor.LatLon; 36 37 import org.openstreetmap.josm.data.osm.DataSet; … … 240 241 final JsonArrayBuilder multiPoint = Json.createArrayBuilder(); 241 242 r.getMembers().stream().map(RelationMember::getMember).filter(Node.class::isInstance).map(Node.class::cast) 242 .map( Node::getCoor).map(latLon -> getCoorArray(null, latLon))243 .map(latLon -> getCoorArray(null, latLon)) 243 244 .forEach(multiPoint::add); 244 245 geomObj.add("type", "MultiPoint"); … … 255 256 .map(Way::getNodes).map(p -> { 256 257 JsonArrayBuilder array = getCoorsArray(p); 257 LatLon ll = p.get(0).getCoor();258 ILatLon ll = p.get(0); 258 259 // since first node is not duplicated as last node 259 return ll != null? array.add(getCoorArray(null, ll)) : array;260 return ll.isLatLonKnown() ? array.add(getCoorArray(null, ll)) : array; 260 261 }).forEach(multiLine::add); 261 262 geomObj.add("type", "MultiLineString"); … … 297 298 .map(p -> { 298 299 JsonArrayBuilder array = getCoorsArray(p); 299 LatLon ll = p.get(0).getCoor();300 ILatLon ll = p.get(0); 300 301 // since first node is not duplicated as last node 301 return ll != null? array.add(getCoorArray(null, ll)) : array;302 return ll.isLatLonKnown() ? array.add(getCoorArray(null, ll)) : array; 302 303 }) 303 304 .forEach(polygon::add); … … 311 312 final JsonArrayBuilder builder = Json.createArrayBuilder(); 312 313 for (Node n : nodes) { 313 LatLon ll = n.getCoor(); 314 if (ll != null) { 315 builder.add(getCoorArray(null, ll)); 314 if (n.isLatLonKnown()) { 315 builder.add(getCoorArray(null, n)); 316 316 } 317 317 } … … 320 320 } 321 321 322 private JsonArrayBuilder getCoorArray(JsonArrayBuilder builder, LatLon c) {322 private JsonArrayBuilder getCoorArray(JsonArrayBuilder builder, ILatLon c) { 323 323 return getCoorArray(builder, projection.latlon2eastNorth(c)); 324 324 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java
r18134 r18494 92 92 Point p = mapView.getPoint(ll); 93 93 node = mapView.getNearestNode(p, OsmPrimitive::isUsable); 94 if (node != null && node.g etCoor().greatCircleDistance(ll) > Config.getPref().getDouble("remotecontrol.tolerance", 0.1)) {94 if (node != null && node.greatCircleDistance(ll) > Config.getPref().getDouble("remotecontrol.tolerance", 0.1)) { 95 95 node = null; // node is too far 96 96 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java
r18134 r18494 19 19 import org.openstreetmap.josm.command.SequenceCommand; 20 20 import org.openstreetmap.josm.data.UndoRedoHandler; 21 import org.openstreetmap.josm.data.coor.ILatLon; 21 22 import org.openstreetmap.josm.data.coor.LatLon; 22 23 import org.openstreetmap.josm.data.osm.DataSet; … … 129 130 MapView mapView = MainApplication.getMap().mapView; 130 131 nd = mapView.getNearestNode(mapView.getPoint(ll), OsmPrimitive::isUsable); 131 if (nd != null && nd.g etCoor().greatCircleDistance(ll) > Config.getPref().getDouble("remote.tolerance", 0.1)) {132 if (nd != null && nd.greatCircleDistance(ll) > Config.getPref().getDouble("remote.tolerance", 0.1)) { 132 133 nd = null; // node is too far 133 134 } … … 136 137 Node prev = null; 137 138 for (Entry<LatLon, Node> entry : addedNodes.entrySet()) { 138 LatLon lOld = entry.getKey();139 ILatLon lOld = entry.getKey(); 139 140 if (lOld.greatCircleDistance(ll) < Config.getPref().getDouble("remotecontrol.tolerance", 0.1)) { 140 141 prev = entry.getValue(); -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r18466 r18494 37 37 import org.openstreetmap.josm.data.ViewportData; 38 38 import org.openstreetmap.josm.data.coor.EastNorth; 39 import org.openstreetmap.josm.data.coor.ILatLon; 39 40 import org.openstreetmap.josm.data.coor.LatLon; 40 41 import org.openstreetmap.josm.data.projection.Projection; … … 144 145 // not too small to avoid rounding errors. 145 146 double dist = 0.01 * proj.getDefaultZoomInPPD(); 146 LatLon ll1 = proj.eastNorth2latlon(new EastNorth(centerEN.east() - dist, centerEN.north()));147 LatLon ll2 = proj.eastNorth2latlon(new EastNorth(centerEN.east() + dist, centerEN.north()));147 ILatLon ll1 = proj.eastNorth2latlon(new EastNorth(centerEN.east() - dist, centerEN.north())); 148 ILatLon ll2 = proj.eastNorth2latlon(new EastNorth(centerEN.east() + dist, centerEN.north())); 148 149 double meterPerEasting = ll1.greatCircleDistance(ll2) / dist / 2; 149 150 double scale = meterPerPixel / meterPerEasting; // unit: easting per pixel -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r18109 r18494 1401 1401 if (one == null || two == null || one.isIncomplete() 1402 1402 || two.isIncomplete()) return Double.NaN; 1403 if (one instanceof Node && two instanceof Node) {1404 rValue = (( Node) one).getCoor().greatCircleDistance(((Node) two).getCoor());1403 if (one instanceof ILatLon && two instanceof ILatLon) { 1404 rValue = ((ILatLon) one).greatCircleDistance(((ILatLon) two)); 1405 1405 } else if (one instanceof Node && two instanceof Way) { 1406 1406 rValue = getDistanceWayNode((Way) two, (Node) one);
Note:
See TracChangeset
for help on using the changeset viewer.