Search in sources :

Example 11 with Edge

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

the class IsValidOp method checkNoSelfIntersectingRings.

/**
 * Check that there is no ring which self-intersects (except of course at its endpoints).
 * This is required by OGC topology rules (but not by other models
 * such as ESRI SDE, which allow inverted shells and exverted holes).
 *
 * @param graph the topology graph of the geometry
 */
private boolean checkNoSelfIntersectingRings(final GeometryGraph graph) {
    boolean valid = true;
    for (final Edge edge : graph.edges()) {
        final EdgeIntersectionList edgeIntersectionList = edge.getEdgeIntersectionList();
        valid &= checkNoSelfIntersectingRing(edgeIntersectionList);
        if (isErrorReturn()) {
            return false;
        }
    }
    return valid;
}
Also used : EdgeIntersectionList(com.revolsys.geometry.geomgraph.EdgeIntersectionList) Edge(com.revolsys.geometry.geomgraph.Edge)

Example 12 with Edge

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

the class IsValidOp method findPtNotNode.

/**
 * Find a point from the list of testCoords
 * that is NOT a node in the edge for the list of searchCoords
 *
 * @return the point found, or <code>null</code> if none found
 */
public static Point findPtNotNode(final LineString testLine, final LinearRing searchRing, final GeometryGraph graph) {
    // find edge corresponding to searchRing.
    final Edge searchEdge = graph.findEdge(searchRing);
    // find a point in the testCoords which is not a node of the searchRing
    final EdgeIntersectionList eiList = searchEdge.getEdgeIntersectionList();
    // somewhat inefficient - is there a better way? (Use a node map, for
    // instance?)
    final int vertexCount = testLine.getVertexCount();
    for (int vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++) {
        final double x = testLine.getX(vertexIndex);
        final double y = testLine.getY(vertexIndex);
        if (!eiList.isIntersection(x, y)) {
            return new PointDoubleXY(x, y);
        }
    }
    return null;
}
Also used : EdgeIntersectionList(com.revolsys.geometry.geomgraph.EdgeIntersectionList) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Edge(com.revolsys.geometry.geomgraph.Edge) Point(com.revolsys.geometry.model.Point)

Example 13 with Edge

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

the class ConnectedInteriorTester method visitInteriorRing.

private void visitInteriorRing(final LineString ring, final PlanarGraph graph) {
    final Point pt0 = ring.getVertex(0).newPoint2D();
    /**
     * Find first point in coord list different to initial point.
     * Need special check since the first point may be repeated.
     */
    final Point pt1 = findDifferentPoint(ring, pt0);
    final Edge e = graph.findEdgeInSameDirection(pt0, pt1);
    final DirectedEdge de = (DirectedEdge) graph.findEdgeEnd(e);
    if (de != null) {
        DirectedEdge intDe = null;
        final Label label = de.getLabel();
        if (label.getLocation(0, Position.RIGHT) == Location.INTERIOR) {
            intDe = de;
        } else if (de.getSym().getLabel().getLocation(0, Position.RIGHT) == Location.INTERIOR) {
            intDe = de.getSym();
        }
        Assert.isTrue(intDe != null, "unable to find dirEdge with Interior on RHS");
        visitLinkedDirectedEdges(intDe);
    }
}
Also used : DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) Label(com.revolsys.geometry.geomgraph.Label) Point(com.revolsys.geometry.model.Point) Edge(com.revolsys.geometry.geomgraph.Edge) DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge)

Example 14 with Edge

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

the class EdgeSetNoder method getNodedEdges.

public List getNodedEdges() {
    final EdgeSetIntersector esi = new SimpleMCSweepLineIntersector();
    final SegmentIntersector si = new SegmentIntersector(this.li, true, false);
    esi.computeIntersections(this.inputEdges, si, true);
    // Debug.println("has proper int = " + si.hasProperIntersection());
    final List splitEdges = new ArrayList();
    for (final Iterator i = this.inputEdges.iterator(); i.hasNext(); ) {
        final Edge e = (Edge) i.next();
        e.getEdgeIntersectionList().addSplitEdges(splitEdges);
    }
    return splitEdges;
}
Also used : SimpleMCSweepLineIntersector(com.revolsys.geometry.geomgraph.index.SimpleMCSweepLineIntersector) SegmentIntersector(com.revolsys.geometry.geomgraph.index.SegmentIntersector) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) EdgeSetIntersector(com.revolsys.geometry.geomgraph.index.EdgeSetIntersector) List(java.util.List) ArrayList(java.util.ArrayList) Edge(com.revolsys.geometry.geomgraph.Edge)

Example 15 with Edge

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

the class LineBuilder method findCoveredLineEdges.

/**
 * Find and mark L edges which are "covered" by the result area (if any).
 * L edges at nodes which also have A edges can be checked by checking
 * their depth at that node.
 * L edges at nodes which do not have A edges can be checked by doing a
 * point-in-polygon test with the previously computed result areas.
 */
private void findCoveredLineEdges() {
    // first set covered for all L edges at nodes which have A edges too
    for (final Object element : this.op.getGraph().getNodes()) {
        final Node node = (Node) element;
        // node.print(System.out);
        ((DirectedEdgeStar) node.getEdges()).findCoveredLineEdges();
    }
    /**
     * For all L edges which weren't handled by the above,
     * use a point-in-poly test to determine whether they are covered
     */
    for (final Object element : this.op.getGraph().getEdgeEnds()) {
        final DirectedEdge de = (DirectedEdge) element;
        final Edge e = de.getEdge();
        if (de.isLineEdge() && !e.isCoveredSet()) {
            final boolean isCovered = this.op.isCoveredByA(de.getX1(), de.getY1());
            e.setCovered(isCovered);
        }
    }
}
Also used : DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) DirectedEdgeStar(com.revolsys.geometry.geomgraph.DirectedEdgeStar) Node(com.revolsys.geometry.geomgraph.Node) DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) Edge(com.revolsys.geometry.geomgraph.Edge)

Aggregations

Edge (com.revolsys.geometry.geomgraph.Edge)23 DirectedEdge (com.revolsys.geometry.geomgraph.DirectedEdge)15 Point (com.revolsys.geometry.model.Point)10 Label (com.revolsys.geometry.geomgraph.Label)6 LineString (com.revolsys.geometry.model.LineString)4 Iterator (java.util.Iterator)4 Depth (com.revolsys.geometry.geomgraph.Depth)2 EdgeIntersection (com.revolsys.geometry.geomgraph.EdgeIntersection)2 EdgeIntersectionList (com.revolsys.geometry.geomgraph.EdgeIntersectionList)2 Location (com.revolsys.geometry.model.Location)2 NodedSegmentString (com.revolsys.geometry.noding.NodedSegmentString)2 ArrayList (java.util.ArrayList)2 DirectedEdgeStar (com.revolsys.geometry.geomgraph.DirectedEdgeStar)1 EdgeList (com.revolsys.geometry.geomgraph.EdgeList)1 Node (com.revolsys.geometry.geomgraph.Node)1 PlanarGraph (com.revolsys.geometry.geomgraph.PlanarGraph)1 EdgeSetIntersector (com.revolsys.geometry.geomgraph.index.EdgeSetIntersector)1 SegmentIntersector (com.revolsys.geometry.geomgraph.index.SegmentIntersector)1 SimpleMCSweepLineIntersector (com.revolsys.geometry.geomgraph.index.SimpleMCSweepLineIntersector)1 Geometry (com.revolsys.geometry.model.Geometry)1