Ticket #22115: 22115.patch
| File 22115.patch, 30.4 KB (added by , 4 years ago) |
|---|
-
src/org/openstreetmap/josm/actions/CreateCircleAction.java
diff --git a/src/org/openstreetmap/josm/actions/CreateCircleAction.java b/src/org/openstreetmap/josm/actions/CreateCircleAction.java index a8488ae92e..6ecbefdf72 100644
a b public final class CreateCircleAction extends JosmAction { 191 191 double r = n1.distance(center); 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)); 200 199 // an odd number of nodes makes the distribution uneven -
src/org/openstreetmap/josm/actions/mapmode/DrawSnapHelper.java
diff --git a/src/org/openstreetmap/josm/actions/mapmode/DrawSnapHelper.java b/src/org/openstreetmap/josm/actions/mapmode/DrawSnapHelper.java index 59992ac1eb..f09960ebbd 100644
a b class DrawSnapHelper { 388 388 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 394 394 -
src/org/openstreetmap/josm/command/MoveCommand.java
diff --git a/src/org/openstreetmap/josm/command/MoveCommand.java b/src/org/openstreetmap/josm/command/MoveCommand.java index b2bf3a2d02..9d8a333627 100644
a b import java.util.function.Predicate; 15 15 import javax.swing.Icon; 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; 20 21 import org.openstreetmap.josm.data.osm.Node; … … public class MoveCommand extends Command { 313 314 public double getDistance(Predicate<Node> predicate) { 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 } 324 325 -
src/org/openstreetmap/josm/data/coor/ILatLon.java
diff --git a/src/org/openstreetmap/josm/data/coor/ILatLon.java b/src/org/openstreetmap/josm/data/coor/ILatLon.java index 45498b5cf6..3891ad57b7 100644
a b 1 1 // License: GPL. For details, see LICENSE file. 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 /** 7 17 * This interface represents a coordinate in LatLon space. … … public interface ILatLon { 80 90 double p = precision / 2; 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 } -
src/org/openstreetmap/josm/data/coor/LatLon.java
diff --git a/src/org/openstreetmap/josm/data/coor/LatLon.java b/src/org/openstreetmap/josm/data/coor/LatLon.java index 43d12f6336..3d7fafdf55 100644
a b 1 1 // License: GPL. For details, see LICENSE file. 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 13 4 import java.awt.geom.Area; 14 5 import java.text.DecimalFormat; 15 6 import java.text.NumberFormat; … … import java.util.Objects; 19 10 import org.openstreetmap.josm.data.Bounds; 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 25 15 /** … … public class LatLon extends Coordinate implements ILatLon { 228 218 * Uses <a href="https://en.wikipedia.org/wiki/Haversine_formula">Haversine formula</a>. 229 219 * @param other the other point. 230 220 * @return distance in metres. 221 * @deprecated since xxx (use {@link ILatLon#greatCircleDistance(ILatLon)} instead) 231 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 248 228 /** … … public class LatLon extends Coordinate implements ILatLon { 259 239 * @param other the "destination" position 260 240 * @return heading in radians in the range 0 <= hd < 2*PI 261 241 * @since 9796 242 * @deprecated since xxx (use {@link ILatLon#bearing(ILatLon)} instead) 262 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 278 249 /** -
src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java
diff --git a/src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java b/src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java index c3ede940b6..bcd175ecf0 100644
a b public final class GpxImageCorrelation { 91 91 double totalDist = 0; 92 92 List<Pair<Double, WayPoint>> nextWps = new ArrayList<>(); 93 93 for (int j = i; j < size; j++) { 94 totalDist += wps.get(j - 1).g etCoor().greatCircleDistance(wps.get(j).getCoor());94 totalDist += wps.get(j - 1).greatCircleDistance(wps.get(j)); 95 95 nextWps.add(new Pair<>(totalDist, wps.get(j))); 96 96 if (wps.get(j).hasDate()) { 97 97 // ...if yes, interpolate everything in between … … public final class GpxImageCorrelation { 120 120 firstSegment = false; 121 121 if (!trkInt || isFirst || prevWp == null || 122 122 Math.abs(curWpTime - prevWpTime) > TimeUnit.MINUTES.toMillis(trkTime) || 123 prevWp.g etCoor().greatCircleDistance(curWp.getCoor()) > trkDist) {123 prevWp.greatCircleDistance(curWp) > trkDist) { 124 124 isFirst = false; 125 125 interpolate = false; 126 126 if (trkTag) { … … public final class GpxImageCorrelation { 131 131 // Apply settings for segments 132 132 if (!segInt || prevWp == null || 133 133 Math.abs(curWpTime - prevWpTime) > TimeUnit.MINUTES.toMillis(segTime) || 134 prevWp.g etCoor().greatCircleDistance(curWp.getCoor()) > segDist) {134 prevWp.greatCircleDistance(curWp) > segDist) { 135 135 interpolate = false; 136 136 if (segTag) { 137 137 tagTime = segTagTime; … … public final class GpxImageCorrelation { 237 237 Double prevElevation = null; 238 238 239 239 if (prevWp != null && interpolate) { 240 double distance = prevWp.g etCoor().greatCircleDistance(curWp.getCoor());240 double distance = prevWp.greatCircleDistance(curWp); 241 241 // This is in km/h, 3.6 * m/s 242 242 if (curWpTime > prevWpTime) { 243 243 speed = 3600 * distance / (curWpTime - prevWpTime); … … public final class GpxImageCorrelation { 266 266 curTmp.setPos(curWp.getCoor()); 267 267 } 268 268 if (nextWp != null && dirpos.isSetImageDirection()) { 269 double direction = curWp. getCoor().bearing(nextWp.getCoor());269 double direction = curWp.bearing(nextWp); 270 270 curTmp.setExifImgDir(computeDirection(direction, dirpos.getImageDirectionAngleOffset())); 271 271 } 272 272 curTmp.setGpsTime(curImg.getExifInstant().minusMillis(offset)); -
src/org/openstreetmap/josm/data/gpx/GpxTrackSegment.java
diff --git a/src/org/openstreetmap/josm/data/gpx/GpxTrackSegment.java b/src/org/openstreetmap/josm/data/gpx/GpxTrackSegment.java index 02fa8f12c3..df0993eda5 100644
a b public class GpxTrackSegment extends WithAttributes implements IGpxTrackSegment 46 46 WayPoint last = null; 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; 52 52 } -
src/org/openstreetmap/josm/data/osm/Way.java
diff --git a/src/org/openstreetmap/josm/data/osm/Way.java b/src/org/openstreetmap/josm/data/osm/Way.java index b746a98891..ebea83125e 100644
a b import java.util.Set; 12 12 import java.util.stream.Collectors; 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; 18 18 import org.openstreetmap.josm.spi.preferences.Config; … … public final class Way extends OsmPrimitive implements IWay<Node> { 630 630 } 631 631 632 632 /** 633 * Replies the length of the way, in metres, as computed by {@link LatLon#greatCircleDistance}.633 * Replies the length of the way, in metres, as computed by {@link ILatLon#greatCircleDistance}. 634 634 * @return The length of the way, in metres 635 635 * @since 4138 636 636 */ … … public final class Way extends OsmPrimitive implements IWay<Node> { 638 638 double length = 0; 639 639 Node lastN = null; 640 640 for (Node n:nodes) { 641 if (lastN != null) { 642 LatLon lastNcoor = lastN.getCoor(); 643 LatLon coor = n.getCoor(); 644 if (lastNcoor != null && coor != null) { 645 length += coor.greatCircleDistance(lastNcoor); 646 } 641 if (lastN != null && lastN.isLatLonKnown() && n.isLatLonKnown()) { 642 length += n.greatCircleDistance(lastN); 647 643 } 648 644 lastN = n; 649 645 } … … public final class Way extends OsmPrimitive implements IWay<Node> { 651 647 } 652 648 653 649 /** 654 * Replies the length of the longest segment of the way, in metres, as computed by {@link LatLon#greatCircleDistance}.650 * Replies the length of the longest segment of the way, in metres, as computed by {@link ILatLon#greatCircleDistance}. 655 651 * @return The length of the segment, in metres 656 652 * @since 8320 657 653 */ … … public final class Way extends OsmPrimitive implements IWay<Node> { 659 655 double length = 0; 660 656 Node lastN = null; 661 657 for (Node n:nodes) { 662 if (lastN != null) { 663 LatLon lastNcoor = lastN.getCoor(); 664 LatLon coor = n.getCoor(); 665 if (lastNcoor != null && coor != null) { 666 double l = coor.greatCircleDistance(lastNcoor); 667 if (l > length) { 668 length = l; 669 } 658 if (lastN != null && lastN.isLatLonKnown() && n.isLatLonKnown()) { 659 double l = n.greatCircleDistance(lastN); 660 if (l > length) { 661 length = l; 670 662 } 671 663 } 672 664 lastN = n; -
src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java
diff --git a/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java b/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java index 0e6612d0d7..60da76e165 100644
a b import java.util.regex.PatternSyntaxException; 28 28 import java.util.stream.Collectors; 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; 34 33 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … public class SearchCompiler { 1808 1807 if (!osm.isUsable()) 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(); 1816 1814 return all ? nodes.stream().allMatch(this) : nodes.stream().anyMatch(this); -
src/org/openstreetmap/josm/data/validation/tests/Addresses.java
diff --git a/src/org/openstreetmap/josm/data/validation/tests/Addresses.java b/src/org/openstreetmap/josm/data/validation/tests/Addresses.java index 11170dee89..98a3fbc25c 100644
a b import java.util.stream.Stream; 22 22 import org.openstreetmap.josm.command.Command; 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; 27 28 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … public class Addresses extends Test { 361 362 * @return distance of center of bounding boxes in meters 362 363 */ 363 364 static double getDistance(OsmPrimitive a, OsmPrimitive b) { 365 if (a instanceof ILatLon && b instanceof ILatLon) { 366 return ((ILatLon) a).greatCircleDistance((ILatLon) b); 367 } 364 368 LatLon centerA = a.getBBox().getCenter(); 365 369 LatLon centerB = b.getBBox().getCenter(); 366 370 return centerA.greatCircleDistance(centerB); -
src/org/openstreetmap/josm/data/validation/tests/LongSegment.java
diff --git a/src/org/openstreetmap/josm/data/validation/tests/LongSegment.java b/src/org/openstreetmap/josm/data/validation/tests/LongSegment.java index cac2453184..d09f1a0f40 100644
a b import java.util.Collections; 8 8 import java.util.HashSet; 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; 14 13 import org.openstreetmap.josm.data.osm.Way; … … public class LongSegment extends Test { 91 90 } 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); 101 100 } -
src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java
diff --git a/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java b/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java index 007eba11bf..5665106a1a 100644
a b public abstract class UnconnectedWays extends Test { 468 468 Node uncon = visited.iterator().next(); 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; 474 474 // see #17914: flag also nodes which are very close … … public abstract class UnconnectedWays extends Test { 500 500 final boolean containsN = visited.contains(next); 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 } 506 506 } … … public abstract class UnconnectedWays extends Test { 515 515 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 521 521 private boolean nearby(Node n, double dist) { … … public abstract class UnconnectedWays extends Test { 526 526 } 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; 533 533 x1 = x2; 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; 540 540 y1 = y2; -
src/org/openstreetmap/josm/gui/MapStatus.java
diff --git a/src/org/openstreetmap/josm/gui/MapStatus.java b/src/org/openstreetmap/josm/gui/MapStatus.java index e7d71b7df8..83ba6364bc 100644
a b import javax.swing.event.PopupMenuListener; 61 61 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; 66 67 import org.openstreetmap.josm.data.coor.conversion.DMSCoordinateFormat; … … import org.openstreetmap.josm.data.osm.DataSelectionListener; 70 71 import org.openstreetmap.josm.data.osm.DataSet; 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; 76 76 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; … … public final class MapStatus extends JPanel implements 1220 1220 OsmPrimitive n1 = it.next(); 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 } 1232 1228 setDist(new SubclassFilteredCollection<OsmPrimitive, Way>(newSelection, Way.class::isInstance)); -
src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
diff --git a/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java b/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java index 60292441a8..c2854f9a7c 100644
a b public class GpxDrawHelper implements SoMChangeListener, MapViewPaintable.LayerP 566 566 continue; 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); 572 572 } … … public class GpxDrawHelper implements SoMChangeListener, MapViewPaintable.LayerP 623 623 oldWp = null; 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 } 631 630 // now we are sure some color will be assigned … … public class GpxDrawHelper implements SoMChangeListener, MapViewPaintable.LayerP 645 644 } 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) { 651 650 case VELOCITY: … … public class GpxDrawHelper implements SoMChangeListener, MapViewPaintable.LayerP 657 656 } 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; 663 662 case TIME: … … public class GpxDrawHelper implements SoMChangeListener, MapViewPaintable.LayerP 673 672 } 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 { 679 678 trkPnt.drawLine = false; -
src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java
diff --git a/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java b/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java index 632e9db390..e05361a7d7 100644
a b public class AddNodeHandler extends RequestHandler { 91 91 MapView mapView = MainApplication.getMap().mapView; 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 } 97 97 } -
src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java
diff --git a/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java b/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java index f2b54f02d9..dbd27e0e91 100644
a b public class AddWayHandler extends RequestHandler { 128 128 if (MainApplication.isDisplayingMapView()) { 129 129 MapView mapView = MainApplication.getMap().mapView; 130 130 nd = mapView.getNearestNode(mapView.getPoint(ll), OsmPrimitive::isUsable); 131 if (nd != null && nd.g etCoor().greatCircleDistance(ll) > Config.getPref().getDouble("remote.tolerance", 0.1)) {131 if (nd != null && nd.greatCircleDistance(ll) > Config.getPref().getDouble("remote.tolerance", 0.1)) { 132 132 nd = null; // node is too far 133 133 } 134 134 } -
src/org/openstreetmap/josm/tools/Geometry.java
diff --git a/src/org/openstreetmap/josm/tools/Geometry.java b/src/org/openstreetmap/josm/tools/Geometry.java index 6eca937e72..ad7eeb5016 100644
a b public final class Geometry { 1400 1400 double rValue = Double.MAX_VALUE; 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); 1407 1407 } else if (one instanceof Way && two instanceof Node) {
