Search in sources :

Example 6 with Label

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

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

the class LineBuilder method collectBoundaryTouchEdge.

/**
 * Collect edges from Area inputs which should be in the result but
 * which have not been included in a result area.
 * This happens ONLY:
 * <ul>
 * <li>during an intersection when the boundaries of two
 * areas touch in a line segment
 * <li> OR as a result of a dimensional collapse.
 * </ul>
 */
private void collectBoundaryTouchEdge(final DirectedEdge de, final int opCode, final List<Edge> edges) {
    final Label label = de.getLabel();
    if (de.isLineEdge()) {
        // only interested in area edges
        return;
    }
    if (de.isVisited()) {
        // already processed
        return;
    }
    if (de.isInteriorAreaEdge()) {
        // added to handle dimensional collapses
        return;
    }
    if (de.getEdge().isInResult()) {
        // if the edge linework is already included, don't include it
        return;
    // again
    }
    // sanity check for labelling of result edgerings
    if (!(!(de.isInResult() || de.getSym().isInResult()) || !de.getEdge().isInResult())) {
        throw new IllegalStateException();
    }
    // include the linework if it's in the result of the operation
    if (OverlayOp.isResultOfOp(label, opCode) && opCode == OverlayOp.INTERSECTION) {
        edges.add(de.getEdge());
        de.setVisitedEdge(true);
    }
}
Also used : Label(com.revolsys.geometry.geomgraph.Label)

Example 8 with Label

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

the class Buffer method insertUniqueEdge.

/**
 * Inserted edges are checked to see if an identical edge already exists.
 * If so, the edge is not inserted, but its label is merged
 * with the existing edge.
 */
private static void insertUniqueEdge(final EdgeList edgeList, final Edge edge) {
    // <FIX> MD 8 Oct 03 speed up identical edge lookup
    // fast lookup
    final Edge existingEdge = edgeList.findEqualEdge(edge);
    // If an identical edge already exists, simply update its label
    if (existingEdge != null) {
        final Label existingLabel = existingEdge.getLabel();
        Label labelToMerge = edge.getLabel();
        // if so, must flip the label before merging it
        if (!existingEdge.isPointwiseEqual(edge)) {
            labelToMerge = new Label(edge.getLabel());
            labelToMerge.flip();
        }
        existingLabel.merge(labelToMerge);
        // compute new depth delta of sum of edges
        final int mergeDelta = depthDelta(labelToMerge);
        final int existingDelta = existingEdge.getDepthDelta();
        final int newDelta = existingDelta + mergeDelta;
        existingEdge.setDepthDelta(newDelta);
    } else {
        // no matching existing edge was found
        // add this new edge to the list of edges in this graph
        // e.setName(name + edges.size());
        edgeList.add(edge);
        edge.setDepthDelta(depthDelta(edge.getLabel()));
    }
}
Also used : Label(com.revolsys.geometry.geomgraph.Label) Edge(com.revolsys.geometry.geomgraph.Edge) DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) Point(com.revolsys.geometry.model.Point)

Example 9 with Label

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

the class Buffer method computeNodedEdges.

private static void computeNodedEdges(final Noder noder, final EdgeList edges, final List<NodedSegmentString> segments) {
    noder.computeNodes(segments);
    final Collection<NodedSegmentString> nodedSegments = noder.getNodedSubstrings();
    for (final SegmentString segment : nodedSegments) {
        final int vertexCount = segment.size();
        if (vertexCount > 2 || vertexCount == 2 && !segment.equalsVertex2d(0, 1)) {
            final Label oldLabel = (Label) segment.getData();
            final Label label = new Label(oldLabel);
            final LineString points = segment.getLineString();
            final Edge edge = new Edge(points, label);
            insertUniqueEdge(edges, edge);
        }
    }
}
Also used : NodedSegmentString(com.revolsys.geometry.noding.NodedSegmentString) LineString(com.revolsys.geometry.model.LineString) Label(com.revolsys.geometry.geomgraph.Label) SegmentString(com.revolsys.geometry.noding.SegmentString) NodedSegmentString(com.revolsys.geometry.noding.NodedSegmentString) Edge(com.revolsys.geometry.geomgraph.Edge) DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) Point(com.revolsys.geometry.model.Point)

Example 10 with Label

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

the class RelateComputer method labelIsolatedNodes.

/**
 * Isolated nodes are nodes whose labels are incomplete
 * (e.g. the location for one Geometry is null).
 * This is the case because nodes in one graph which don't intersect
 * nodes in the other are not completely labelled by the initial process
 * of adding nodes to the nodeList.
 * To complete the labelling we need to check for nodes that lie in the
 * interior of edges, and in the interior of areas.
 */
private void labelIsolatedNodes() {
    for (final Object element : this.nodes) {
        final Node n = (Node) element;
        final Label label = n.getLabel();
        // isolated nodes should always have at least one geometry in their label
        Assert.isTrue(label.getGeometryCount() > 0, "node with empty label found");
        if (n.isIsolated()) {
            if (label.isNull(0)) {
                labelIsolatedNode(n, 0);
            } else {
                labelIsolatedNode(n, 1);
            }
        }
    }
}
Also used : Node(com.revolsys.geometry.geomgraph.Node) Label(com.revolsys.geometry.geomgraph.Label)

Aggregations

Label (com.revolsys.geometry.geomgraph.Label)14 DirectedEdge (com.revolsys.geometry.geomgraph.DirectedEdge)6 Edge (com.revolsys.geometry.geomgraph.Edge)6 Point (com.revolsys.geometry.model.Point)6 Node (com.revolsys.geometry.geomgraph.Node)3 Depth (com.revolsys.geometry.geomgraph.Depth)2 DirectedEdgeStar (com.revolsys.geometry.geomgraph.DirectedEdgeStar)2 EdgeEnd (com.revolsys.geometry.geomgraph.EdgeEnd)2 NodedSegmentString (com.revolsys.geometry.noding.NodedSegmentString)2 Geometry (com.revolsys.geometry.model.Geometry)1 LineString (com.revolsys.geometry.model.LineString)1 Location (com.revolsys.geometry.model.Location)1 SegmentString (com.revolsys.geometry.noding.SegmentString)1