Search in sources :

Example 11 with Node

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

the class Buffer method buildSubgraphs.

/**
 * Completes the building of the input subgraphs by depth-labelling them,
 * and adds them to the PolygonBuilder.
 * The subgraph list must be sorted in rightmost-coordinate order.
 *
 * @param subgraphList the subgraphs to build
 * @param polyBuilder the PolygonBuilder which will build the final polygons
 */
private static void buildSubgraphs(final List<BufferSubgraph> subgraphList, final PolygonBuilder polyBuilder) {
    final List<BufferSubgraph> processedGraphs = new ArrayList<>();
    for (final BufferSubgraph subgraph : subgraphList) {
        final Point p = subgraph.getRightmostCoordinate();
        final int outsideDepth = getDepth(processedGraphs, p);
        subgraph.computeDepth(outsideDepth);
        subgraph.findResultEdges();
        processedGraphs.add(subgraph);
        final List<DirectedEdge> edges = subgraph.getDirectedEdges();
        final List<Node> nodes = subgraph.getNodes();
        polyBuilder.add(edges, nodes);
    }
}
Also used : DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) Node(com.revolsys.geometry.geomgraph.Node) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Example 12 with Node

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

the class RelateComputer method copyNodesAndLabels.

/**
 * Copy all nodes from an arg geometry into this graph.
 * The node label in the arg geometry overrides any previously computed
 * label for that argIndex.
 * (E.g. a node may be an intersection node with
 * a computed label of BOUNDARY,
 * but in the original arg Geometry it is actually
 * in the interior due to the Boundary Determination Rule)
 */
private void copyNodesAndLabels(final int argIndex) {
    for (final Iterator i = this.arg[argIndex].getNodeIterator(); i.hasNext(); ) {
        final Node graphNode = (Node) i.next();
        final Node newNode = this.nodes.addNode(graphNode);
        newNode.setLabel(argIndex, graphNode.getLabel().getLocation(argIndex));
    // node.print(System.out);
    }
}
Also used : Node(com.revolsys.geometry.geomgraph.Node) Iterator(java.util.Iterator)

Example 13 with Node

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

Example 14 with Node

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

the class OverlayOp method copyPoints.

/**
 * Copy all nodes from an arg geometry into this graph.
 * The node label in the arg geometry overrides any previously computed
 * label for that argIndex.
 * (E.g. a node may be an intersection node with
 * a previously computed label of BOUNDARY,
 * but in the original arg Geometry it is actually
 * in the interior due to the Boundary Determination Rule)
 */
private void copyPoints(final int argIndex) {
    for (final Iterator<Node> i = this.arg[argIndex].getNodeIterator(); i.hasNext(); ) {
        final Node graphNode = i.next();
        final Node newNode = this.graph.addNode(graphNode);
        newNode.setLabel(argIndex, graphNode.getLabel().getLocation(argIndex));
    }
}
Also used : Node(com.revolsys.geometry.geomgraph.Node)

Example 15 with Node

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

the class OverlayOp method computeLabelling.

/**
 * Compute initial labelling for all DirectedEdges at each node.
 * In this step, DirectedEdges will acquire a complete labelling
 * (i.e. one with labels for both Geometries)
 * only if they
 * are incident on a node which has edges for both Geometries
 */
private void computeLabelling() {
    for (final Node node : this.graph.getNodes()) {
        node.getEdges().computeLabelling(this.arg);
    }
    mergeSymLabels();
    updateNodeLabelling();
}
Also used : Node(com.revolsys.geometry.geomgraph.Node)

Aggregations

Node (com.revolsys.geometry.geomgraph.Node)17 DirectedEdgeStar (com.revolsys.geometry.geomgraph.DirectedEdgeStar)7 DirectedEdge (com.revolsys.geometry.geomgraph.DirectedEdge)5 Label (com.revolsys.geometry.geomgraph.Label)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 LineIntersector (com.revolsys.geometry.algorithm.LineIntersector)1 Edge (com.revolsys.geometry.geomgraph.Edge)1 Point (com.revolsys.geometry.model.Point)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Stack (java.util.Stack)1