Search in sources :

Example 16 with Edge

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

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

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

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

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

the class RightmostEdgeFinder method findRightmostEdgeAtVertex.

private void findRightmostEdgeAtVertex() {
    /**
     * The rightmost point is an interior vertex, so it has a segment on either side of it.
     * If these segments are both above or below the rightmost point, we need to
     * determine their relative orientation to decide which is rightmost.
     */
    final Edge edge = this.minDe.getEdge();
    Assert.isTrue(this.minIndex > 0 && this.minIndex < edge.getVertexCount(), "rightmost point expected to be interior vertex of edge");
    final Point pPrev = edge.getPoint(this.minIndex - 1);
    final Point pNext = edge.getPoint(this.minIndex + 1);
    final int orientation = CGAlgorithmsDD.orientationIndex(this.minCoord, pNext, pPrev);
    boolean usePrev = false;
    // both segments are below min point
    if (pPrev.getY() < this.minCoord.getY() && pNext.getY() < this.minCoord.getY() && orientation == CGAlgorithms.COUNTERCLOCKWISE) {
        usePrev = true;
    } else if (pPrev.getY() > this.minCoord.getY() && pNext.getY() > this.minCoord.getY() && orientation == CGAlgorithms.CLOCKWISE) {
        usePrev = true;
    }
    // to select as a rightmost segment
    if (usePrev) {
        this.minIndex = this.minIndex - 1;
    }
}
Also used : Point(com.revolsys.geometry.model.Point) DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) Edge(com.revolsys.geometry.geomgraph.Edge) Point(com.revolsys.geometry.model.Point)

Aggregations

Edge (com.revolsys.geometry.geomgraph.Edge)23 DirectedEdge (com.revolsys.geometry.geomgraph.DirectedEdge)15 Point (com.revolsys.geometry.model.Point)10 Label (com.revolsys.geometry.geomgraph.Label)6 LineString (com.revolsys.geometry.model.LineString)4 Iterator (java.util.Iterator)4 Depth (com.revolsys.geometry.geomgraph.Depth)2 EdgeIntersection (com.revolsys.geometry.geomgraph.EdgeIntersection)2 EdgeIntersectionList (com.revolsys.geometry.geomgraph.EdgeIntersectionList)2 Location (com.revolsys.geometry.model.Location)2 NodedSegmentString (com.revolsys.geometry.noding.NodedSegmentString)2 ArrayList (java.util.ArrayList)2 DirectedEdgeStar (com.revolsys.geometry.geomgraph.DirectedEdgeStar)1 EdgeList (com.revolsys.geometry.geomgraph.EdgeList)1 Node (com.revolsys.geometry.geomgraph.Node)1 PlanarGraph (com.revolsys.geometry.geomgraph.PlanarGraph)1 EdgeSetIntersector (com.revolsys.geometry.geomgraph.index.EdgeSetIntersector)1 SegmentIntersector (com.revolsys.geometry.geomgraph.index.SegmentIntersector)1 SimpleMCSweepLineIntersector (com.revolsys.geometry.geomgraph.index.SimpleMCSweepLineIntersector)1 Geometry (com.revolsys.geometry.model.Geometry)1