Search in sources :

Example 6 with IntersectionMatrix

use of com.revolsys.geometry.model.IntersectionMatrix in project com.revolsys.open by revolsys.

the class IntersectionMatrixTest method testIsTouches.

public void testIsTouches() {
    assertTrue(new IntersectionMatrix("FT*******").isTouches(P, A));
    assertTrue(new IntersectionMatrix("FT*******").isTouches(A, P));
    assertTrue(!new IntersectionMatrix("FT*******").isTouches(P, P));
}
Also used : IntersectionMatrix(com.revolsys.geometry.model.IntersectionMatrix)

Example 7 with IntersectionMatrix

use of com.revolsys.geometry.model.IntersectionMatrix in project com.revolsys.open by revolsys.

the class RelateBoundaryNodeRuleTest method runRelateTest.

void runRelateTest(final String wkt1, final String wkt2, final BoundaryNodeRule bnRule, final String expectedIM) throws ParseException {
    final Geometry g1 = this.geometryFactory.geometry(wkt1);
    final Geometry g2 = this.geometryFactory.geometry(wkt2);
    final IntersectionMatrix im = RelateOp.relate(g1, g2, bnRule);
    final String imStr = im.toString();
    // System.out.println(imStr);
    assertTrue(im.matches(expectedIM));
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) IntersectionMatrix(com.revolsys.geometry.model.IntersectionMatrix)

Example 8 with IntersectionMatrix

use of com.revolsys.geometry.model.IntersectionMatrix in project com.revolsys.open by revolsys.

the class EdgeIntersectsLinearlyEdgeVisitor method accept.

@Override
public void accept(final Edge<T> edge2) {
    if (edge2 != this.edge) {
        final LineString line1 = this.edge.getLineString();
        final LineString line2 = edge2.getLineString();
        final BoundingBox envelope1 = line1.getBoundingBox();
        final BoundingBox envelope2 = line2.getBoundingBox();
        if (envelope1.intersects(envelope2)) {
            final IntersectionMatrix relate = line1.relate(line2);
            if (relate.get(0, 0) == Dimension.L) {
                this.matchVisitor.accept(edge2);
            }
        }
    }
}
Also used : LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) IntersectionMatrix(com.revolsys.geometry.model.IntersectionMatrix)

Example 9 with IntersectionMatrix

use of com.revolsys.geometry.model.IntersectionMatrix in project com.revolsys.open by revolsys.

the class EdgeIntersectLineVisitor method accept.

@Override
public void accept(final Edge<T> edge) {
    final LineString line = edge.getLineString();
    final IntersectionMatrix relate = this.line.relate(line);
    if (relate.get(0, 0) == Dimension.L) {
        this.matchVisitor.accept(edge);
    }
}
Also used : LineString(com.revolsys.geometry.model.LineString) IntersectionMatrix(com.revolsys.geometry.model.IntersectionMatrix)

Example 10 with IntersectionMatrix

use of com.revolsys.geometry.model.IntersectionMatrix 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

IntersectionMatrix (com.revolsys.geometry.model.IntersectionMatrix)17 Geometry (com.revolsys.geometry.model.Geometry)2 LineString (com.revolsys.geometry.model.LineString)2 EdgeEnd (com.revolsys.geometry.geomgraph.EdgeEnd)1 SegmentIntersector (com.revolsys.geometry.geomgraph.index.SegmentIntersector)1 BoundingBox (com.revolsys.geometry.model.BoundingBox)1