Search in sources :

Example 1 with EdgeList

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

Aggregations

DirectedEdge (com.revolsys.geometry.geomgraph.DirectedEdge)1 Edge (com.revolsys.geometry.geomgraph.Edge)1 EdgeList (com.revolsys.geometry.geomgraph.EdgeList)1 PlanarGraph (com.revolsys.geometry.geomgraph.PlanarGraph)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 OverlayNodeFactory (com.revolsys.geometry.operation.overlay.OverlayNodeFactory)1 PolygonBuilder (com.revolsys.geometry.operation.overlay.PolygonBuilder)1