Search in sources :

Example 1 with SegmentIntersector

use of com.revolsys.geometry.geomgraph.index.SegmentIntersector in project com.revolsys.open by revolsys.

the class GeometryGraph method computeEdgeIntersections.

public SegmentIntersector computeEdgeIntersections(final GeometryGraph g, final LineIntersector li, final boolean includeProper) {
    final SegmentIntersector si = new SegmentIntersector(li, includeProper, true);
    si.setBoundaryNodes(getBoundaryNodes(), g.getBoundaryNodes());
    final EdgeSetIntersector esi = newEdgeSetIntersector();
    esi.computeIntersections(this.edges, g.edges, si);
    /*
     * for (Iterator i = g.edges.iterator(); i.hasNext();) { Edge e = (Edge) i.next();
     * Debug.print(e.getEdgeIntersectionList()); }
     */
    return si;
}
Also used : SegmentIntersector(com.revolsys.geometry.geomgraph.index.SegmentIntersector) EdgeSetIntersector(com.revolsys.geometry.geomgraph.index.EdgeSetIntersector)

Example 2 with SegmentIntersector

use of com.revolsys.geometry.geomgraph.index.SegmentIntersector in project com.revolsys.open by revolsys.

the class ConsistentAreaTester method isNodeConsistentArea.

/**
 * Check all nodes to see if their labels are consistent with area topology.
 *
 * @return <code>true</code> if this area has a consistent node labelling
 */
public boolean isNodeConsistentArea() {
    /**
     * To fully check validity, it is necessary to
     * compute ALL intersections, including self-intersections within a single edge.
     */
    final SegmentIntersector intersector = this.geomGraph.computeSelfNodes(this.li, true);
    if (intersector.hasProperIntersection()) {
        this.invalidPoint = intersector.getProperIntersectionPoint();
        return false;
    }
    this.nodeGraph.build(this.geomGraph);
    return isNodeEdgeAreaLabelsConsistent();
}
Also used : SegmentIntersector(com.revolsys.geometry.geomgraph.index.SegmentIntersector)

Example 3 with SegmentIntersector

use of com.revolsys.geometry.geomgraph.index.SegmentIntersector in project com.revolsys.open by revolsys.

the class GeometryGraph method computeSelfNodes.

/**
 * Compute self-nodes, taking advantage of the Geometry type to
 * minimize the number of intersection tests.  (E.g. rings are
 * not tested for self-intersection, since they are assumed to be valid).
 * @param li the LineIntersector to use
 * @param computeRingSelfNodes if <false>, intersection checks are optimized to not test rings for self-intersection
 * @return the SegmentIntersector used, containing information about the intersections found
 */
public SegmentIntersector computeSelfNodes(final LineIntersector li, final boolean computeRingSelfNodes) {
    final SegmentIntersector si = new SegmentIntersector(li, true, false);
    final EdgeSetIntersector esi = newEdgeSetIntersector();
    // optimized test for Polygons and Rings
    if (!computeRingSelfNodes && (this.geometry instanceof LinearRing || this.geometry instanceof Polygonal)) {
        esi.computeIntersections(this.edges, si, false);
    } else {
        esi.computeIntersections(this.edges, si, true);
    }
    // System.out.println("SegmentIntersector # tests = " + si.numTests);
    addSelfIntersectionNodes(this.argIndex);
    return si;
}
Also used : Polygonal(com.revolsys.geometry.model.Polygonal) SegmentIntersector(com.revolsys.geometry.geomgraph.index.SegmentIntersector) EdgeSetIntersector(com.revolsys.geometry.geomgraph.index.EdgeSetIntersector) LinearRing(com.revolsys.geometry.model.LinearRing)

Example 4 with SegmentIntersector

use of com.revolsys.geometry.geomgraph.index.SegmentIntersector 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 5 with SegmentIntersector

use of com.revolsys.geometry.geomgraph.index.SegmentIntersector in project com.revolsys.open by revolsys.

the class RelateComputer method computeIM.

public IntersectionMatrix computeIM() {
    final IntersectionMatrix im = new IntersectionMatrix();
    // since Geometries are finite and embedded in a 2-D space, the EE element
    // must always be 2
    im.set(Location.EXTERIOR, Location.EXTERIOR, 2);
    // if the Geometries don't overlap there is nothing to do
    if (!this.arg[0].getGeometry().getBoundingBox().intersects(this.arg[1].getGeometry().getBoundingBox())) {
        computeDisjointIM(im);
        return im;
    }
    this.arg[0].computeSelfNodes(this.li, false);
    this.arg[1].computeSelfNodes(this.li, false);
    // compute intersections between edges of the two input geometries
    final SegmentIntersector intersector = this.arg[0].computeEdgeIntersections(this.arg[1], this.li, false);
    // System.out.println("computeIM: # segment intersection tests: " +
    // intersector.numTests);
    computeIntersectionNodes(0);
    computeIntersectionNodes(1);
    /**
     * Copy the labelling for the nodes in the parent Geometries.  These override
     * any labels determined by intersections between the geometries.
     */
    copyNodesAndLabels(0);
    copyNodesAndLabels(1);
    // complete the labelling for any nodes which only have a label for a single
    // geometry
    // Debug.addWatch(nodes.find(new PointDouble((double)110, 200)));
    // Debug.printWatch();
    labelIsolatedNodes();
    // Debug.printWatch();
    // If a proper intersection was found, we can set a lower bound on the IM.
    computeProperIntersectionIM(intersector, im);
    /**
     * Now process improper intersections
     * (eg where one or other of the geometries has a vertex at the intersection point)
     * We need to compute the edge graph at all nodes to determine the IM.
     */
    // build EdgeEnds for all intersections
    final EdgeEndBuilder eeBuilder = new EdgeEndBuilder();
    final List<EdgeEnd> ee0 = eeBuilder.computeEdgeEnds(this.arg[0].edges());
    insertEdgeEnds(ee0);
    final List<EdgeEnd> ee1 = eeBuilder.computeEdgeEnds(this.arg[1].edges());
    insertEdgeEnds(ee1);
    // Debug.println("==== NodeList ===");
    // Debug.print(nodes);
    labelNodeEdges();
    /**
     * Compute the labeling for isolated components
     * <br>
     * Isolated components are components that do not touch any other components in the graph.
     * They can be identified by the fact that they will
     * contain labels containing ONLY a single element, the one for their parent geometry.
     * We only need to check components contained in the input graphs, since
     * isolated components will not have been replaced by new components formed by intersections.
     */
    // debugPrintln("Graph A isolated edges - ");
    labelIsolatedEdges(0, 1);
    // debugPrintln("Graph B isolated edges - ");
    labelIsolatedEdges(1, 0);
    // update the IM from all components
    updateIM(im);
    return im;
}
Also used : EdgeEnd(com.revolsys.geometry.geomgraph.EdgeEnd) SegmentIntersector(com.revolsys.geometry.geomgraph.index.SegmentIntersector) IntersectionMatrix(com.revolsys.geometry.model.IntersectionMatrix)

Aggregations

SegmentIntersector (com.revolsys.geometry.geomgraph.index.SegmentIntersector)5 EdgeSetIntersector (com.revolsys.geometry.geomgraph.index.EdgeSetIntersector)3 Edge (com.revolsys.geometry.geomgraph.Edge)1 EdgeEnd (com.revolsys.geometry.geomgraph.EdgeEnd)1 SimpleMCSweepLineIntersector (com.revolsys.geometry.geomgraph.index.SimpleMCSweepLineIntersector)1 IntersectionMatrix (com.revolsys.geometry.model.IntersectionMatrix)1 LinearRing (com.revolsys.geometry.model.LinearRing)1 Polygonal (com.revolsys.geometry.model.Polygonal)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1