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.

File:
1 edited

Legend:

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

    r35975 r35976  
    8282        }
    8383
    84         private static double calcAlpha(LatLon oP1, Node n) {
    85                 LatLon oP2 = n.getCoor();
    86 
    87                 double dAlpha = Math.atan((oP2.getY() - oP1.getY()) / (oP2.getX() - oP1.getX())) * 180 / Math.PI + (oP1.getX() > oP2.getX() ? 180 : 0);
     84        private static double calcAlpha(LatLon oP1, Node oP2) {
     85
     86                double dAlpha = Math.atan((oP2.lat() - oP1.lat()) / (oP2.lon() - oP1.lon())) * 180 / Math.PI + (oP1.lon() > oP2.lon() ? 180 : 0);
    8887                return checkAlpha(dAlpha);
    8988        }
     
    333332                //List<Command> cmds = new LinkedList<Command>();
    334333
    335                 LatLon ll = node.getCoor();
     334                //LatLon ll = node.getCoor();
    336335                //BBox bbox = new BBox(
    337336                //        ll.getX() - MIN_DISTANCE_TW,
     
    358357                        for (Pair<Node, Node> np : ww.getNodePairs(false)) {
    359358                                //double dist1 = TracerGeometry.distanceFromSegment(ll, np.a.getCoor(), np.b.getCoor());
    360                                 double dist = distanceFromSegment2(ll, np.a.getCoor(), np.b.getCoor());
     359                                double dist = distanceFromSegment2(node, np.a, np.b);
    361360                                //System.out.println(" distance: " + dist1 + "  " + dist);
    362361
     
    381380        }
    382381
    383         private static double distanceFromSegment2(LatLon c, LatLon a, LatLon b) {
     382        private static double distanceFromSegment2(ILatLon c, ILatLon a, ILatLon b) {
    384383                double x;
    385384                double y;
    386385
    387386                StraightLine oStraightLine1 = new StraightLine(
    388                                 new Point2D.Double(a.getX(), a.getY()),
    389                                 new Point2D.Double(b.getX(), b.getY()));
     387                                new Point2D.Double(a.lon(), a.lat()),
     388                                new Point2D.Double(b.lon(), b.lat()));
    390389                StraightLine oStraightLine2 = new StraightLine(
    391                                 new Point2D.Double(c.getX(), c.getY()),
    392                                 new Point2D.Double(c.getX() + (a.getY()-b.getY()), c.getY() - (a.getX()-b.getX())));
     390                                new Point2D.Double(c.lon(), c.lat()),
     391                                new Point2D.Double(c.lon() + (a.lat()-b.lat()), c.lat() - (a.lon()-b.lon())));
    393392                Point2D.Double oPoint = oStraightLine1.GetIntersectionPoint(oStraightLine2);
    394393
    395                 if ((oPoint.x > a.getX() && oPoint.x > b.getX()) || (oPoint.x < a.getX() && oPoint.x < b.getX()) ||
    396                                 (oPoint.y > a.getY() && oPoint.y > b.getY()) || (oPoint.y < a.getY() && oPoint.y < b.getY())) {
     394                if ((oPoint.x > a.lon() && oPoint.x > b.lon()) || (oPoint.x < a.lon() && oPoint.x < b.lon()) ||
     395                                (oPoint.y > a.lat() && oPoint.y > b.lat()) || (oPoint.y < a.lat() && oPoint.y < b.lat())) {
    397396                        return 100000;
    398397                }
    399398
    400                 x = c.getX()-oPoint.getX();
    401                 y = c.getY()-oPoint.getY();
     399                x = c.lon()-oPoint.getX();
     400                y = c.lat()-oPoint.getY();
    402401
    403402                return Math.sqrt((x*x)+(y*y));
     
    421420                while (i < way.getNodesCount()) {
    422421                        // usecka n1, n2
    423                         LatLon n1 = way.getNodes().get(i).getCoor();
    424                         LatLon n2 = way.getNodes().get((i + 1) % way.getNodesCount()).getCoor();
     422                        ILatLon n1 = way.getNodes().get(i);
     423                        ILatLon n2 = way.getNodes().get((i + 1) % way.getNodesCount());
    425424                        System.out.println(way.getNodes().get(i) + "-----" + way.getNodes().get((i + 1) % way.getNodesCount()));
    426425                        double minDistanceSq = Double.MAX_VALUE;
     
    438437                                        continue;
    439438                                }
    440                                 LatLon nn = nod.getCoor();
    441                                 //double dist = TracerGeometry.distanceFromSegment(nn, n1, n2);
    442                                 double dist = distanceFromSegment2(nn, n1, n2);
    443                                 //                double angle = TracerGeometry.angleOfLines(n1, nn, nn, n2);
     439                                //double dist = TracerGeometry.distanceFromSegment(nod, n1, n2);
     440                                double dist = distanceFromSegment2(nod, n1, n2);
     441                                //                double angle = TracerGeometry.angleOfLines(n1, nod, nod, n2);
    444442                                //System.out.println("Angle: " + angle + " distance: " + dist + " Node: " + nod);
    445                                 if (!n1.equalsEpsilon(nn, ILatLon.MAX_SERVER_PRECISION)
    446                                  && !n2.equalsEpsilon(nn, ILatLon.MAX_SERVER_PRECISION) && dist < minDistanceSq) { // && Math.abs(angle) < maxAngle) {
     443                                if (!n1.equalsEpsilon(nod, ILatLon.MAX_SERVER_PRECISION)
     444                                 && !n2.equalsEpsilon(nod, ILatLon.MAX_SERVER_PRECISION) && dist < minDistanceSq) { // && Math.abs(angle) < maxAngle) {
    447445                                        minDistanceSq = dist;
    448446                                        //                    maxAngle = angle;
Note: See TracChangeset for help on using the changeset viewer.