Package org.geotools.geometry.jts
Class GeometryCollector
- Object
-
- GeometryCollector
-
public class GeometryCollector extends Object
A stateful geometry collector that will add all geometries into a single resulting geometry collection with the following properties:- the elements of the resulting geometry are simple geometries, adding a geometry collection will result in it being flattened
- the resulting geometry collection type will match its contents, a generic geometry collection will be used only in case of heterogeneous contents
- all geometries will be cloned using the provided geometry factory (one based on a
PackedCoordinateSequenceis used by default to reduce memory usage)
- Author:
- Andrea Aime - GeoSolutions
-
-
Constructor Summary
Constructors Constructor Description GeometryCollector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Geometry g)Adds a geometry to the collectorGeometryCollectioncollect()Returns a geometry collection containing all of the geometries collected in the processGeometryCollectioncollectInternal()GeometryFactorygetFactory()Returns the geometry factory used to deep clone the geometries while collecting them (if null no cloning will happen)longgetMaxCoordinates()Returns the maximum number of coordinates this collector is allowed to keep in the resulting geometryvoidsetFactory(GeometryFactory factory)Sets the geometry factory used to deep clone the geometries while collecting them.voidsetMaxCoordinates(long maxCoordinates)Sets the maximum number of coordinates to be collected.
-
-
-
Method Detail
-
getMaxCoordinates
public long getMaxCoordinates()
Returns the maximum number of coordinates this collector is allowed to keep in the resulting geometry
-
setMaxCoordinates
public void setMaxCoordinates(long maxCoordinates)
Sets the maximum number of coordinates to be collected. By default is -1, no limit
-
getFactory
public GeometryFactory getFactory()
Returns the geometry factory used to deep clone the geometries while collecting them (if null no cloning will happen)
-
setFactory
public void setFactory(GeometryFactory factory)
Sets the geometry factory used to deep clone the geometries while collecting them. May be set to null to avoid deep cloning. By default a geometry factory based onPackedCoordinateSequenceFactoryis used to minimize the memory usage
-
collect
public GeometryCollection collect()
Returns a geometry collection containing all of the geometries collected in the process
-
collectInternal
public GeometryCollection collectInternal()
-
add
public void add(Geometry g)
Adds a geometry to the collector
-
-