Search in sources :

Example 21 with DirectedEdge

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

the class BufferSubgraph method getEnvelope.

/**
 * Computes the envelope of the edges in the subgraph.
 * The envelope is cached after being computed.
 *
 * @return the envelope of the graph.
 */
public BoundingBox getEnvelope() {
    if (this.env == null) {
        double[] bounds = null;
        for (final DirectedEdge dirEdge : this.dirEdgeList) {
            final Edge edge = dirEdge.getEdge();
            final LineString points = edge.getLineString();
            for (int i = 0; i < points.getVertexCount(); i++) {
                final Point point = points.getPoint(i);
                if (bounds == null) {
                    bounds = RectangleUtil.newBounds(2, point);
                } else {
                    RectangleUtil.expand(bounds, 2, point);
                }
            }
        }
        this.env = new BoundingBoxDoubleXY(bounds);
    }
    return this.env;
}
Also used : DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY) Edge(com.revolsys.geometry.geomgraph.Edge) DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) Point(com.revolsys.geometry.model.Point)

Example 22 with DirectedEdge

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

the class BufferSubgraph method add.

/**
 * Adds the argument node and all its out edges to the subgraph
 * @param node the node to add
 * @param nodeStack the current set of nodes being traversed
 */
private void add(final Node node, final Stack<Node> nodeStack) {
    node.setVisited(true);
    this.nodes.add(node);
    for (final Object element : (DirectedEdgeStar) node.getEdges()) {
        final DirectedEdge de = (DirectedEdge) element;
        this.dirEdgeList.add(de);
        final DirectedEdge sym = de.getSym();
        final Node symNode = sym.getNode();
        /**
         * NOTE: this is a depth-first traversal of the graph.
         * This will cause a large depth of recursion.
         * It might be better to do a breadth-first traversal.
         */
        if (!symNode.isVisited()) {
            nodeStack.push(symNode);
        }
    }
}
Also used : DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) DirectedEdgeStar(com.revolsys.geometry.geomgraph.DirectedEdgeStar) Node(com.revolsys.geometry.geomgraph.Node)

Example 23 with DirectedEdge

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

the class BufferSubgraph method computeDepth.

public void computeDepth(final int outsideDepth) {
    clearVisitedEdges();
    // find an outside edge to assign depth to
    final DirectedEdge de = this.finder.getEdge();
    // right side of line returned by finder is on the outside
    de.setEdgeDepths(Position.RIGHT, outsideDepth);
    copySymDepths(de);
    // computeNodeDepth(n, de);
    computeDepths(de);
}
Also used : DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge)

Aggregations

DirectedEdge (com.revolsys.geometry.geomgraph.DirectedEdge)23 Point (com.revolsys.geometry.model.Point)8 Edge (com.revolsys.geometry.geomgraph.Edge)7 ArrayList (java.util.ArrayList)6 DirectedEdgeStar (com.revolsys.geometry.geomgraph.DirectedEdgeStar)5 Node (com.revolsys.geometry.geomgraph.Node)5 List (java.util.List)3 Label (com.revolsys.geometry.geomgraph.Label)2 TopologyException (com.revolsys.geometry.model.TopologyException)2 MaximalEdgeRing (com.revolsys.geometry.operation.overlay.MaximalEdgeRing)2 EdgeRing (com.revolsys.geometry.geomgraph.EdgeRing)1 LineString (com.revolsys.geometry.model.LineString)1 BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)1 LineSegment (com.revolsys.geometry.model.segment.LineSegment)1 LineSegmentDouble (com.revolsys.geometry.model.segment.LineSegmentDouble)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1