src/main/java/de/blau/android/validation/BaseValidator.java
/**
     * Check if a Node is so near a Way that it should be connected
     * 
     * @param logic the current Logic instance
     * @param tolerance how far away the node has to be from the line in screen pixel units
     * @param way the Way
     * @param node the Node
     */
Check if a Node is so near a Way that it should be connected

@param logic the current Logic instance
@param tolerance how far away the node has to be from the line in screen pixel units
@param way the Way
@param node the Node
Check if a Node is so near a Way that it should be connected @param logic the current Logic instance @param tolerance how far away the node has to be from the line in screen pixel units @param way the Way @param node the Node
private void connectedValidation(@NonNull Logic logic, float tolerance, @NonNull Way way, @NonNull Node node) {
        if (!way.hasNode(node)) {
            float jx = logic.lonE7ToX(node.getLon());
            float jy = logic.latE7ToY(node.getLat());
            List<Node> wayNodes = way.getNodes();
            Node firstNode = wayNodes.get(0);
            float node1X = logic.lonE7ToX(firstNode.getLon());
            float node1Y = logic.latE7ToY(firstNode.getLat());
            double nodeDist = Math.hypot(jx - node1X, jy - node1Y); 
            if (nodeDist < tolerance) {
                addProblem(node, Validator.UNCONNECTED_END_NODE);
                return;
            }
            for (int i = 1, wayNodesSize = wayNodes.size(); i < wayNodesSize; ++i) {
                Node node2 = wayNodes.get(i);
                float node2X = logic.lonE7ToX(node2.getLon());
                float node2Y = logic.latE7ToY(node2.getLat());
                if (Geometry.isPositionOnLine(tolerance, jx, jy, node1X, node1Y, node2X, node2Y) >= 0) {
                    addProblem(node, Validator.UNCONNECTED_END_NODE);
                    break;
                }
                node1X = node2X;
                node1Y = node2Y;
            }
            nodeDist = Math.hypot(jx - node1X, jy - node1Y); 
            if (nodeDist < tolerance) {
                addProblem(node, Validator.UNCONNECTED_END_NODE);
            }
        }
    }
private void connectedValidation ( @ NonNull Logic logic , float tolerance , @ NonNull Way way , @ NonNull Node node ) { if ( ! way . hasNode ( node ) ) { float jx = logic . lonE7ToX ( node . getLon ( ) ) ; float jy = logic . latE7ToY ( node . getLat ( ) ) ; List < Node > wayNodes = way . getNodes ( ) ; Node firstNode = wayNodes . get ( 0 ) ; float node1X = logic . lonE7ToX ( firstNode . getLon ( ) ) ; float node1Y = logic . latE7ToY ( firstNode . getLat ( ) ) ; double nodeDist = Math . hypot ( jx - node1X , jy - node1Y ) ; if ( nodeDist < tolerance ) { addProblem ( node , Validator . UNCONNECTED_END_NODE ) ; return ; } for ( int i = 1 , wayNodesSize = wayNodes . size ( ) ; i < wayNodesSize ; ++ i ) { Node node2 = wayNodes . get ( i ) ; float node2X = logic . lonE7ToX ( node2 . getLon ( ) ) ; float node2Y = logic . latE7ToY ( node2 . getLat ( ) ) ; if ( Geometry . isPositionOnLine ( tolerance , jx , jy , node1X , node1Y , node2X , node2Y ) >= 0 ) { addProblem ( node , Validator . UNCONNECTED_END_NODE ) ; break ; } node1X = node2X ; node1Y = node2Y ; } nodeDist = Math . hypot ( jx - node1X , jy - node1Y ) ; if ( nodeDist < tolerance ) { addProblem ( node , Validator . UNCONNECTED_END_NODE ) ; } } }
Check if a Node is so near a Way that it should be connected
Check if a Node is so near a Way that it should be connected
// first node // last node