Search in sources :

Example 1 with EdgeEnd

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

the class EdgeEndBundle method print.

@Override
public void print(final PrintStream out) {
    out.println("EdgeEndBundle--> Label: " + getLabel());
    for (final EdgeEnd e : this) {
        e.print(out);
        out.println();
    }
}
Also used : EdgeEnd(com.revolsys.geometry.geomgraph.EdgeEnd)

Example 2 with EdgeEnd

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

the class RelateComputer method insertEdgeEnds.

private void insertEdgeEnds(final List ee) {
    for (final Iterator i = ee.iterator(); i.hasNext(); ) {
        final EdgeEnd e = (EdgeEnd) i.next();
        this.nodes.add(e);
    }
}
Also used : EdgeEnd(com.revolsys.geometry.geomgraph.EdgeEnd) Iterator(java.util.Iterator)

Example 3 with EdgeEnd

use of com.revolsys.geometry.geomgraph.EdgeEnd 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)

Example 4 with EdgeEnd

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

the class EdgeEndBuilder method newEdgeEndForPrev.

/**
 * Construct a new EdgeStub for the edge before the intersection eiCurr.
 * The previous intersection is provided
 * in case it is the endpoint for the stub edge.
 * Otherwise, the previous point from the parent edge will be the endpoint.
 * <br>
 * eiCurr will always be an EdgeIntersection, but eiPrev may be null.
 */
void newEdgeEndForPrev(final Edge edge, final List<EdgeEnd> l, final EdgeIntersection eiCurr, final EdgeIntersection eiPrev) {
    int iPrev = eiCurr.segmentIndex;
    if (eiCurr.dist == 0.0) {
        // if at the start of the edge there is no previous edge
        if (iPrev == 0) {
            return;
        }
        iPrev--;
    }
    Point pPrev = edge.getPoint(iPrev);
    // if prev intersection is past the previous vertex, use it instead
    if (eiPrev != null && eiPrev.segmentIndex >= iPrev) {
        pPrev = eiPrev.newPoint2D();
    }
    final Label label = new Label(edge.getLabel());
    // since edgeStub is oriented opposite to it's parent edge, have to flip
    // sides for edge label
    label.flip();
    final EdgeEnd e = new EdgeEnd(edge, eiCurr.getX(), eiCurr.getY(), pPrev.getX(), pPrev.getY(), label);
    // e.print(System.out); System.out.println();
    l.add(e);
}
Also used : EdgeEnd(com.revolsys.geometry.geomgraph.EdgeEnd) Label(com.revolsys.geometry.geomgraph.Label) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Example 5 with EdgeEnd

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

the class EdgeEndBuilder method newEdgeEndForNext.

/**
 * Construct a new StubEdge for the edge after the intersection eiCurr.
 * The next intersection is provided
 * in case it is the endpoint for the stub edge.
 * Otherwise, the next point from the parent edge will be the endpoint.
 * <br>
 * eiCurr will always be an EdgeIntersection, but eiNext may be null.
 */
void newEdgeEndForNext(final Edge edge, final List<EdgeEnd> l, final EdgeIntersection eiCurr, final EdgeIntersection eiNext) {
    final int iNext = eiCurr.segmentIndex + 1;
    // if there is no next edge there is nothing to do
    if (iNext >= edge.getVertexCount() && eiNext == null) {
        return;
    }
    Point pNext = edge.getPoint(iNext);
    // the endpoint
    if (eiNext != null && eiNext.segmentIndex == eiCurr.segmentIndex) {
        pNext = eiNext.newPoint2D();
    }
    final EdgeEnd e = new EdgeEnd(edge, eiCurr.getX(), eiCurr.getY(), pNext.getX(), pNext.getY(), new Label(edge.getLabel()));
    // Debug.println(e);
    l.add(e);
}
Also used : EdgeEnd(com.revolsys.geometry.geomgraph.EdgeEnd) Label(com.revolsys.geometry.geomgraph.Label) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Aggregations

EdgeEnd (com.revolsys.geometry.geomgraph.EdgeEnd)6 Label (com.revolsys.geometry.geomgraph.Label)2 Point (com.revolsys.geometry.model.Point)2 SegmentIntersector (com.revolsys.geometry.geomgraph.index.SegmentIntersector)1 IntersectionMatrix (com.revolsys.geometry.model.IntersectionMatrix)1 Location (com.revolsys.geometry.model.Location)1 Iterator (java.util.Iterator)1