Search in sources :

Example 1 with GeometryGraph

use of com.revolsys.geometry.geomgraph.GeometryGraph in project com.revolsys.open by revolsys.

the class IsValidOp method checkValidPolygon.

/**
 * Checks the validity of a polygon.
 * Sets the validErr flag.
 */
private boolean checkValidPolygon(final Polygon g) {
    boolean valid = true;
    valid &= checkClosedRings(g);
    if (isErrorReturn()) {
        return false;
    }
    try {
        final GeometryGraph graph = new GeometryGraph(0, g);
        valid &= checkTooFewPoints(graph);
        if (isErrorReturn()) {
            return false;
        }
        valid &= checkConsistentArea(graph);
        if (isErrorReturn()) {
            return false;
        }
        if (!this.isSelfTouchingRingFormingHoleValid) {
            valid &= checkNoSelfIntersectingRings(graph);
            if (isErrorReturn()) {
                return false;
            }
        }
        valid &= checkHolesInShell(g, graph);
        if (isErrorReturn()) {
            return false;
        }
        // SLOWcheckHolesNotNested(g);
        valid &= checkHolesNotNested(g, graph);
        if (isErrorReturn()) {
            return false;
        }
        valid &= checkConnectedInteriors(graph);
        return valid;
    } catch (final IllegalArgumentException e) {
        return false;
    }
}
Also used : GeometryGraph(com.revolsys.geometry.geomgraph.GeometryGraph)

Example 2 with GeometryGraph

use of com.revolsys.geometry.geomgraph.GeometryGraph in project com.revolsys.open by revolsys.

the class IsValidOp method checkValidLinearRing.

/**
 * Checks validity of a LinearRing.
 */
private boolean checkValidLinearRing(final LinearRing ring) {
    boolean valid = true;
    if (checkTooFewVertices(ring, 4)) {
        valid &= checkClosedRing(ring);
        if (isErrorReturn()) {
            return false;
        }
        final GeometryGraph graph = new GeometryGraph(0, ring);
        final LineIntersector li = new RobustLineIntersector();
        graph.computeSelfNodes(li, true);
        valid &= checkNoSelfIntersectingRings(graph);
        return valid;
    }
    return false;
}
Also used : LineIntersector(com.revolsys.geometry.algorithm.LineIntersector) RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector) RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector) GeometryGraph(com.revolsys.geometry.geomgraph.GeometryGraph)

Example 3 with GeometryGraph

use of com.revolsys.geometry.geomgraph.GeometryGraph in project com.revolsys.open by revolsys.

the class IsValidOp method checkValidMultiPolygon.

private boolean checkValidMultiPolygon(final Polygonal polygonal) {
    boolean valid = true;
    for (final Polygon polygon : polygonal.polygons()) {
        valid &= checkClosedRings(polygon);
        if (isErrorReturn()) {
            return false;
        }
    }
    final GeometryGraph graph = new GeometryGraph(0, polygonal);
    valid &= checkTooFewPoints(graph);
    if (isErrorReturn()) {
        return false;
    }
    valid &= checkConsistentArea(graph);
    if (isErrorReturn()) {
        return false;
    }
    if (!this.isSelfTouchingRingFormingHoleValid) {
        valid &= checkNoSelfIntersectingRings(graph);
        if (isErrorReturn()) {
            return false;
        }
    }
    for (final Polygon polygon : polygonal.getPolygons()) {
        valid &= checkHolesInShell(polygon, graph);
        if (isErrorReturn()) {
            return false;
        }
    }
    for (final Polygon polygon : polygonal.getPolygons()) {
        valid &= checkHolesNotNested(polygon, graph);
        if (isErrorReturn()) {
            return false;
        }
    }
    valid &= checkShellsNotNested(polygonal, graph);
    if (isErrorReturn()) {
        return false;
    }
    valid &= checkConnectedInteriors(graph);
    return valid;
}
Also used : Polygon(com.revolsys.geometry.model.Polygon) GeometryGraph(com.revolsys.geometry.geomgraph.GeometryGraph)

Aggregations

GeometryGraph (com.revolsys.geometry.geomgraph.GeometryGraph)3 LineIntersector (com.revolsys.geometry.algorithm.LineIntersector)1 RobustLineIntersector (com.revolsys.geometry.algorithm.RobustLineIntersector)1 Polygon (com.revolsys.geometry.model.Polygon)1