Ignore:
Timestamp:
2022-06-14T20:11:21+02:00 (3 years ago)
Author:
taylor.smock
Message:

see #22104: Remove usages of Node#getCoor where possible

This also accounts for cases where Node has the methods used later,
so a new LatLon is unnecessary.

Location:
applications/editors/josm/plugins/tracer/src/org/openstreetmap/josm/plugins/tracer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/tracer/src/org/openstreetmap/josm/plugins/tracer/ConnectWays.java

    r35975 r35976  
    4949            LatLon ll = n.getCoor();
    5050            BBox bbox = new BBox(
    51                     ll.getX() - MIN_DISTANCE,
    52                     ll.getY() - MIN_DISTANCE,
    53                     ll.getX() + MIN_DISTANCE,
    54                     ll.getY() + MIN_DISTANCE);
     51                    n.lon() - MIN_DISTANCE,
     52                    n.lat() - MIN_DISTANCE,
     53                    n.lon() + MIN_DISTANCE,
     54                    n.lat() + MIN_DISTANCE);
    5555
    5656            // bude se node slucovat s jinym?
     
    129129        LatLon ll = node.getCoor();
    130130        BBox bbox = new BBox(
    131                 ll.getX() - MIN_DISTANCE_TW,
    132                 ll.getY() - MIN_DISTANCE_TW,
    133                 ll.getX() + MIN_DISTANCE_TW,
    134                 ll.getY() + MIN_DISTANCE_TW);
     131                node.lon() - MIN_DISTANCE_TW,
     132                node.lat() - MIN_DISTANCE_TW,
     133                node.lon() + MIN_DISTANCE_TW,
     134                node.lat() + MIN_DISTANCE_TW);
    135135
    136136        // node nebyl slouceny s jinym
     
    188188        while (i < way.getNodesCount()) {
    189189            // usecka n1, n2
    190             LatLon n1 = way.getNodes().get(i).getCoor();
    191             LatLon n2 = way.getNodes().get((i + 1) % way.getNodesCount()).getCoor();
     190            Node n1 = way.getNodes().get(i);
     191            Node n2 = way.getNodes().get((i + 1) % way.getNodesCount());
    192192            System.out.println(way.getNodes().get(i) + "-----" + way.getNodes().get((i + 1) % way.getNodesCount()));
    193193            double minDistanceSq = MIN_DISTANCE_SQ;
    194194            //double maxAngle = MAX_ANGLE;
    195195            List<Node> nodes = MainApplication.getLayerManager().getEditDataSet().searchNodes(new BBox(
    196                 Math.min(n1.getX(), n2.getX()) - minDistanceSq,
    197                 Math.min(n1.getY(), n2.getY()) - minDistanceSq,
    198                 Math.max(n1.getX(), n2.getX()) + minDistanceSq,
    199                 Math.max(n1.getY(), n2.getY()) + minDistanceSq
     196                Math.min(n1.lon(), n2.lon()) - minDistanceSq,
     197                Math.min(n1.lat(), n2.lat()) - minDistanceSq,
     198                Math.max(n1.lon(), n2.lon()) + minDistanceSq,
     199                Math.max(n1.lat(), n2.lat()) + minDistanceSq
    200200            ));
    201201            Node nearestNode = null;
     
    204204                    continue;
    205205                }
    206                 LatLon nn = nod.getCoor();
    207                 double dist = TracerGeometry.distanceFromSegment(nn, n1, n2);
    208                 double angle = TracerGeometry.angleOfLines(n1, nn, nn, n2);
     206                double dist = TracerGeometry.distanceFromSegment(nod, n1, n2);
     207                double angle = TracerGeometry.angleOfLines(n1, nod, nod, n2);
    209208                System.out.println("Angle: " + angle + " distance: " + dist + " Node: " + nod);
    210                 if (!n1.equalsEpsilon(nn, ILatLon.MAX_SERVER_PRECISION)
    211                  && !n2.equalsEpsilon(nn, ILatLon.MAX_SERVER_PRECISION) && dist < minDistanceSq) { // && Math.abs(angle) < maxAngle) {
     209                if (!n1.equalsEpsilon(nod, ILatLon.MAX_SERVER_PRECISION)
     210                 && !n2.equalsEpsilon(nod, ILatLon.MAX_SERVER_PRECISION) && dist < minDistanceSq) { // && Math.abs(angle) < maxAngle) {
    212211                    //maxAngle = angle;
    213212                    nearestNode = nod;
  • applications/editors/josm/plugins/tracer/src/org/openstreetmap/josm/plugins/tracer/TracerGeometry.java

    r19881 r35976  
    77package org.openstreetmap.josm.plugins.tracer;
    88
    9 import org.openstreetmap.josm.data.coor.LatLon;
     9import org.openstreetmap.josm.data.coor.ILatLon;
    1010
    11 public class TracerGeometry {
     11public final class TracerGeometry {
     12    private TracerGeometry() {
     13        // Hide constructor
     14    }
    1215
    1316    /**
     
    1922     * @return Angle in degrees.
    2023     */
    21     static public double angleOfLines(LatLon a, LatLon b, LatLon c, LatLon d) {
     24    public static double angleOfLines(ILatLon a, ILatLon b, ILatLon c, ILatLon d) {
    2225        return (Math.abs(
    2326                    Math.atan2(a.lat() - b.lat(), a.lon() - b.lon()) -
     
    3336     * @return Distance.
    3437     */
    35     static public double distanceFromSegment(LatLon c, LatLon a, LatLon b) {
     38    public static double distanceFromSegment(ILatLon c, ILatLon a, ILatLon b) {
    3639        return distanceFromSegment(
    37                 c.getX(), c.getY(),
    38                 a.getX(), a.getY(),
    39                 b.getX(), b.getY()
     40                c.lon(), c.lat(),
     41                a.lon(), a.lat(),
     42                b.lon(), b.lat()
    4043        );
    4144    }
    4245
    43     static private double distanceFromSegment(double cx, double cy, double ax, double ay, double bx, double by) {
     46    private static double distanceFromSegment(double cx, double cy, double ax, double ay, double bx, double by) {
    4447        double r_numerator = (cx - ax) * (bx - ax) + (cy - ay) * (by - ay);
    4548        double r_denomenator = (bx - ax) * (bx - ax) + (by - ay) * (by - ay);
Note: See TracChangeset for help on using the changeset viewer.