Search in sources :

Example 1 with EdgeIntersection

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

the class RelateComputer method computeIntersectionNodes.

/**
 * Insert nodes for all intersections on the edges of a Geometry.
 * Label the created nodes the same as the edge label if they do not already have a label.
 * This allows nodes created by either self-intersections or
 * mutual intersections to be labelled.
 * Endpoint nodes will already be labelled from when they were inserted.
 */
private void computeIntersectionNodes(final int argIndex) {
    for (final Iterator i = this.arg[argIndex].getEdgeIterator(); i.hasNext(); ) {
        final Edge e = (Edge) i.next();
        final Location eLoc = e.getLabel().getLocation(argIndex);
        for (final Object element : e.getEdgeIntersectionList()) {
            final EdgeIntersection ei = (EdgeIntersection) element;
            final RelateNode n = (RelateNode) this.nodes.addNode(ei.newPoint2D());
            if (eLoc == Location.BOUNDARY) {
                n.setLabelBoundary(argIndex);
            } else {
                if (n.getLabel().isNull(argIndex)) {
                    n.setLabel(argIndex, Location.INTERIOR);
                }
            }
        // Debug.println(n);
        }
    }
}
Also used : Iterator(java.util.Iterator) EdgeIntersection(com.revolsys.geometry.geomgraph.EdgeIntersection) Edge(com.revolsys.geometry.geomgraph.Edge) Location(com.revolsys.geometry.model.Location)

Example 2 with EdgeIntersection

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

the class RelateNodeGraph method computeIntersectionNodes.

/**
 * Insert nodes for all intersections on the edges of a Geometry.
 * Label the created nodes the same as the edge label if they do not already have a label.
 * This allows nodes created by either self-intersections or
 * mutual intersections to be labelled.
 * Endpoint nodes will already be labelled from when they were inserted.
 * <p>
 * Precondition: edge intersections have been computed.
 */
public void computeIntersectionNodes(final GeometryGraph geomGraph, final int argIndex) {
    for (final Edge edge : geomGraph.edges()) {
        final Location eLoc = edge.getLabel().getLocation(argIndex);
        for (final Object element : edge.getEdgeIntersectionList()) {
            final EdgeIntersection ei = (EdgeIntersection) element;
            final RelateNode n = (RelateNode) this.nodes.addNode(ei.newPoint2D());
            if (eLoc == Location.BOUNDARY) {
                n.setLabelBoundary(argIndex);
            } else {
                if (n.getLabel().isNull(argIndex)) {
                    n.setLabel(argIndex, Location.INTERIOR);
                }
            }
        }
    }
}
Also used : EdgeIntersection(com.revolsys.geometry.geomgraph.EdgeIntersection) Edge(com.revolsys.geometry.geomgraph.Edge) Location(com.revolsys.geometry.model.Location)

Example 3 with EdgeIntersection

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

the class IsValidOp method checkNoSelfIntersectingRing.

/**
 * Check that a ring does not self-intersect, except at its endpoints.
 * Algorithm is to count the number of times each node along edge occurs.
 * If any occur more than once, that must be a self-intersection.
 */
private boolean checkNoSelfIntersectingRing(final EdgeIntersectionList eiList) {
    boolean valid = true;
    final Set<Point> nodeSet = new TreeSet<>();
    boolean isFirst = true;
    for (final EdgeIntersection ei : eiList) {
        if (isFirst) {
            isFirst = false;
        } else if (nodeSet.contains(ei)) {
            valid = false;
            addError(new TopologyValidationError(TopologyValidationError.RING_SELF_INTERSECTION, ei.newPoint2D()));
            if (isErrorReturn()) {
                return false;
            }
        } else {
            nodeSet.add(ei.newPoint2D());
        }
    }
    return valid;
}
Also used : TreeSet(java.util.TreeSet) Point(com.revolsys.geometry.model.Point) EdgeIntersection(com.revolsys.geometry.geomgraph.EdgeIntersection)

Example 4 with EdgeIntersection

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

the class EdgeEndBuilder method computeEdgeEnds.

/**
 * Creates stub edges for all the intersections in this
 * Edge (if any) and inserts them into the graph.
 */
public void computeEdgeEnds(final Edge edge, final List<EdgeEnd> l) {
    final EdgeIntersectionList eiList = edge.getEdgeIntersectionList();
    // Debug.print(eiList);
    // ensure that the list has entries for the first and last point of the edge
    eiList.addEndpoints();
    final Iterator<EdgeIntersection> it = eiList.iterator();
    EdgeIntersection eiPrev = null;
    EdgeIntersection eiCurr = null;
    // no intersections, so there is nothing to do
    if (!it.hasNext()) {
        return;
    }
    EdgeIntersection eiNext = it.next();
    do {
        eiPrev = eiCurr;
        eiCurr = eiNext;
        eiNext = null;
        if (it.hasNext()) {
            eiNext = it.next();
        }
        if (eiCurr != null) {
            newEdgeEndForPrev(edge, l, eiCurr, eiPrev);
            newEdgeEndForNext(edge, l, eiCurr, eiNext);
        }
    } while (eiCurr != null);
}
Also used : EdgeIntersectionList(com.revolsys.geometry.geomgraph.EdgeIntersectionList) EdgeIntersection(com.revolsys.geometry.geomgraph.EdgeIntersection)

Aggregations

EdgeIntersection (com.revolsys.geometry.geomgraph.EdgeIntersection)4 Edge (com.revolsys.geometry.geomgraph.Edge)2 Location (com.revolsys.geometry.model.Location)2 EdgeIntersectionList (com.revolsys.geometry.geomgraph.EdgeIntersectionList)1 Point (com.revolsys.geometry.model.Point)1 Iterator (java.util.Iterator)1 TreeSet (java.util.TreeSet)1