Package org.locationtech.jts.triangulate
Class VoronoiDiagramBuilder
- java.lang.Object
-
- org.locationtech.jts.triangulate.VoronoiDiagramBuilder
-
public class VoronoiDiagramBuilder extends java.lang.Object
A utility class which creates Voronoi Diagrams from collections of points. The diagram is returned as aGeometryCollection
ofPolygon
s representing the faces of the Voronoi diagram. The faces are clipped to the larger of:- an envelope supplied by
setClipEnvelope(Envelope)
- an envelope determined by the input sites
- an envelope supplied by
-
-
Field Summary
Fields Modifier and Type Field Description private Envelope
clipEnv
private Envelope
diagramEnv
private java.util.Collection
siteCoords
private QuadEdgeSubdivision
subdiv
private double
tolerance
-
Constructor Summary
Constructors Constructor Description VoronoiDiagramBuilder()
Creates a new Voronoi diagram builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static Geometry
clipGeometryCollection(Geometry geom, Envelope clipEnv)
private void
create()
Geometry
getDiagram(GeometryFactory geomFact)
Gets the faces of the computed diagram as aGeometryCollection
ofPolygon
s, clipped as specified.QuadEdgeSubdivision
getSubdivision()
Gets theQuadEdgeSubdivision
which models the computed diagram.void
setClipEnvelope(Envelope clipEnv)
Sets the envelope to clip the diagram to.void
setSites(java.util.Collection coords)
Sets the sites (point or vertices) which will be diagrammed from a collection ofCoordinate
s.void
setSites(Geometry geom)
Sets the sites (point or vertices) which will be diagrammed.void
setTolerance(double tolerance)
Sets the snapping tolerance which will be used to improved the robustness of the triangulation computation.
-
-
-
Field Detail
-
siteCoords
private java.util.Collection siteCoords
-
tolerance
private double tolerance
-
subdiv
private QuadEdgeSubdivision subdiv
-
clipEnv
private Envelope clipEnv
-
diagramEnv
private Envelope diagramEnv
-
-
Method Detail
-
setSites
public void setSites(Geometry geom)
Sets the sites (point or vertices) which will be diagrammed. All vertices of the given geometry will be used as sites.- Parameters:
geom
- the geometry from which the sites will be extracted.
-
setSites
public void setSites(java.util.Collection coords)
Sets the sites (point or vertices) which will be diagrammed from a collection ofCoordinate
s.- Parameters:
coords
- a collection of Coordinates.
-
setClipEnvelope
public void setClipEnvelope(Envelope clipEnv)
Sets the envelope to clip the diagram to. The diagram will be clipped to the larger of this envelope or an envelope surrounding the sites.- Parameters:
clipEnv
- the clip envelope.
-
setTolerance
public void setTolerance(double tolerance)
Sets the snapping tolerance which will be used to improved the robustness of the triangulation computation. A tolerance of 0.0 specifies that no snapping will take place.- Parameters:
tolerance
- the tolerance distance to use
-
create
private void create()
-
getSubdivision
public QuadEdgeSubdivision getSubdivision()
Gets theQuadEdgeSubdivision
which models the computed diagram.- Returns:
- the subdivision containing the triangulation
-
getDiagram
public Geometry getDiagram(GeometryFactory geomFact)
Gets the faces of the computed diagram as aGeometryCollection
ofPolygon
s, clipped as specified.The userData attribute of each face Polygon is set to the Coordinate of the corresponding input site. This allows using a Map to link faces to data associated with sites.
- Parameters:
geomFact
- the geometry factory to use to create the output- Returns:
- a GeometryCollection containing the face Polygons of the diagram
-
-