Search in sources :

Example 1 with OverlayNodeFactory

use of com.revolsys.geometry.operation.overlay.OverlayNodeFactory in project com.revolsys.open by revolsys.

the class Buffer method buffer.

private static Geometry buffer(final Noder noder, final GeometryFactory precisionModel, final Geometry geometry, final double distance, final BufferParameters parameters) {
    final GeometryFactory geometryFactory = geometry.getGeometryFactory();
    final OffsetCurveSetBuilder curveSetBuilder = new OffsetCurveSetBuilder(geometry, distance, precisionModel, parameters);
    final List<NodedSegmentString> curves = curveSetBuilder.getCurves();
    if (curves.size() == 0) {
        return geometryFactory.polygon();
    } else {
        final EdgeList edgeList = new EdgeList();
        computeNodedEdges(noder, edgeList, curves);
        final PlanarGraph graph = new PlanarGraph(new OverlayNodeFactory());
        final List<Edge> edges = edgeList.getEdges();
        graph.addEdges(edges);
        final List<BufferSubgraph> subgraphList = newSubgraphs(graph);
        final PolygonBuilder polyBuilder = new PolygonBuilder(geometryFactory);
        buildSubgraphs(subgraphList, polyBuilder);
        final List<Polygon> polygons = polyBuilder.getPolygons();
        if (polygons.size() == 0) {
            return geometryFactory.polygon();
        } else {
            final Geometry resultGeom = geometryFactory.buildGeometry(polygons);
            return resultGeom;
        }
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) OverlayNodeFactory(com.revolsys.geometry.operation.overlay.OverlayNodeFactory) EdgeList(com.revolsys.geometry.geomgraph.EdgeList) Geometry(com.revolsys.geometry.model.Geometry) PlanarGraph(com.revolsys.geometry.geomgraph.PlanarGraph) NodedSegmentString(com.revolsys.geometry.noding.NodedSegmentString) Polygon(com.revolsys.geometry.model.Polygon) Edge(com.revolsys.geometry.geomgraph.Edge) DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) PolygonBuilder(com.revolsys.geometry.operation.overlay.PolygonBuilder)

Example 2 with OverlayNodeFactory

use of com.revolsys.geometry.operation.overlay.OverlayNodeFactory in project com.revolsys.open by revolsys.

the class ConnectedInteriorTester method isInteriorsConnected.

public boolean isInteriorsConnected() {
    // node the edges, in case holes touch the shell
    final List splitEdges = new ArrayList();
    this.geomGraph.computeSplitEdges(splitEdges);
    // form the edges into rings
    final PlanarGraph graph = new PlanarGraph(new OverlayNodeFactory());
    graph.addEdges(splitEdges);
    setInteriorEdgesInResult(graph);
    graph.linkResultDirectedEdges();
    final List edgeRings = buildEdgeRings(graph.getEdgeEnds());
    /**
     * Mark all the edges for the edgeRings corresponding to the shells
     * of the input polygons.  Note only ONE ring gets marked for each shell.
     */
    visitShellInteriors(this.geomGraph.getGeometry(), graph);
    /**
     * If there are any unvisited shell edges
     * (i.e. a ring which is not a hole and which has the interior
     * of the parent area on the RHS)
     * this means that one or more holes must have split the interior of the
     * polygon into at least two pieces.  The polygon is thus invalid.
     */
    return !hasUnvisitedShellEdge(edgeRings);
}
Also used : PlanarGraph(com.revolsys.geometry.geomgraph.PlanarGraph) OverlayNodeFactory(com.revolsys.geometry.operation.overlay.OverlayNodeFactory) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

PlanarGraph (com.revolsys.geometry.geomgraph.PlanarGraph)2 OverlayNodeFactory (com.revolsys.geometry.operation.overlay.OverlayNodeFactory)2 DirectedEdge (com.revolsys.geometry.geomgraph.DirectedEdge)1 Edge (com.revolsys.geometry.geomgraph.Edge)1 EdgeList (com.revolsys.geometry.geomgraph.EdgeList)1 Geometry (com.revolsys.geometry.model.Geometry)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 Polygon (com.revolsys.geometry.model.Polygon)1 NodedSegmentString (com.revolsys.geometry.noding.NodedSegmentString)1 PolygonBuilder (com.revolsys.geometry.operation.overlay.PolygonBuilder)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1