Changeset 15461 in josm


Ignore:
Timestamp:
2019-10-17T08:43:25+02:00 (5 years ago)
Author:
GerdP
Message:

sonar lint, code cleanup, no functional change

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r15458 r15461  
    3232import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper;
    3333import org.openstreetmap.josm.data.projection.Ellipsoid;
     34import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3435import org.openstreetmap.josm.data.validation.Severity;
    3536import org.openstreetmap.josm.data.validation.Test;
     
    411412
    412413    private class MyWaySegment {
     414        /** the way */
    413415        public final Way w;
    414416        private final Node n1;
     
    429431         */
    430432        boolean isConnectedTo(Node startNode) {
    431             return isConnectedTo(startNode, null, new HashSet<>(), 0);
     433            return isConnectedTo(startNode, new HashSet<>(), 0);
    432434        }
    433435
     
    435437         * Check if the given node is connected to this segment using a reasonable short way.
    436438         * @param node the given node
    437          * @param startWay previously visited way or null if first
    438439         * @param visited set of visited nodes
    439440         * @param len length of the travelled route
    440441         * @return true if a reasonable connection was found
    441442         */
    442         boolean isConnectedTo(Node node, Way startWay, Set<Node> visited, double len) {
     443        private boolean isConnectedTo(Node node, Set<Node> visited, double len) {
    443444            if (n1 == node || n2 == node) {
    444445                return true;
     
    462463                            final boolean containsN = visited.contains(next);
    463464                            visited.add(next);
    464                             if (!containsN && isConnectedTo(next, way, visited,
     465                            if (!containsN && isConnectedTo(next, visited,
    465466                                    len + node.getCoor().greatCircleDistance(next.getCoor()))) {
    466467                                return true;
     
    478479                return Double.NaN;
    479480            EastNorth closest = Geometry.closestPointToSegment(n1.getEastNorth(), n2.getEastNorth(), coord);
    480             Node x = new Node();
    481             x.setEastNorth(closest);
    482             return x.getCoor().greatCircleDistance(n.getCoor());
    483 
    484         }
    485 
    486         boolean nearby(Node n, double dist) {
     481            return n.getCoor().greatCircleDistance(ProjectionRegistry.getProjection().eastNorth2latlon(closest));
     482        }
     483
     484        private boolean nearby(Node n, double dist) {
    487485            if (w.containsNode(n))
    488486                return false;
     
    491489        }
    492490
    493         BBox getBounds(double fudge) {
     491        private BBox getBounds(double fudge) {
    494492            double x1 = n1.getCoor().lon();
    495493            double x2 = n2.getCoor().lon();
     
    539537            EastNorth en = endnode.getEastNorth();
    540538            EastNorth closest = Geometry.closestPointToSegment(n1.getEastNorth(), n2.getEastNorth(), en);
    541             Node x = new Node(closest);
    542             BBox bbox = new BBox(endnode.getCoor(), x.getCoor());
     539            BBox bbox = new BBox(endnode.getCoor(), ProjectionRegistry.getProjection().eastNorth2latlon(closest));
    543540            for (Way nearbyWay : ds.searchWays(bbox)) {
    544541                if (nearbyWay != w && nearbyWay.isUsable() && nearbyWay.hasTag("barrier")
     
    558555            return false;
    559556        }
    560 
    561557    }
    562558
Note: See TracChangeset for help on using the changeset viewer.