Class UnaryUnionOp
java.lang.Object
org.locationtech.jts.operation.union.UnaryUnionOp
Unions a
Collection
of Geometry
s or a single Geometry
(which may be a GeometryCollection
) together.
By using this special-purpose operation over a collection of geometries
it is possible to take advantage of various optimizations to improve performance.
Heterogeneous GeometryCollection
s are fully supported.
The result obeys the following contract:
- Unioning a set of
Polygon
s has the effect of merging the areas (i.e. the same effect as iteratively unioning all individual polygons together). - Unioning a set of
LineString
s has the effect of noding and dissolving the input linework. In this context "fully noded" means that there will be an endpoint or node in the result for every endpoint or line segment crossing in the input. "Dissolved" means that any duplicate (i.e. coincident) line segments or portions of line segments will be reduced to a single line segment in the result. This is consistent with the semantics of theGeometry.union(Geometry)
operation. If merged linework is required, theLineMerger
class can be used. - Unioning a set of
Point
s has the effect of merging all identical points (producing a set with no duplicates).
- Author:
- mbdavis
-
Constructor Summary
ConstructorsConstructorDescriptionUnaryUnionOp
(Collection geoms) Constructs a unary union operation for aCollection
ofGeometry
s, using theGeometryFactory
of the input geometries.UnaryUnionOp
(Collection geoms, GeometryFactory geomFact) Constructs a unary union operation for aCollection
ofGeometry
s.UnaryUnionOp
(Geometry geom) Constructs a unary union operation for aGeometry
(which may be aGeometryCollection
). -
Method Summary
Modifier and TypeMethodDescriptionvoid
setUnionFunction
(UnionStrategy unionFun) union()
Gets the union of the input geometries.static Geometry
union
(Collection geoms) Computes the geometric union of aCollection
ofGeometry
s.static Geometry
union
(Collection geoms, GeometryFactory geomFact) Computes the geometric union of aCollection
ofGeometry
s.static Geometry
Constructs a unary union operation for aGeometry
(which may be aGeometryCollection
).
-
Constructor Details
-
UnaryUnionOp
Constructs a unary union operation for aCollection
ofGeometry
s.- Parameters:
geoms
- a collection of geometriesgeomFact
- the geometry factory to use if the collection is empty
-
UnaryUnionOp
Constructs a unary union operation for aCollection
ofGeometry
s, using theGeometryFactory
of the input geometries.- Parameters:
geoms
- a collection of geometries
-
UnaryUnionOp
Constructs a unary union operation for aGeometry
(which may be aGeometryCollection
).- Parameters:
geom
-
-
-
Method Details
-
union
Computes the geometric union of aCollection
ofGeometry
s.- Parameters:
geoms
- a collection of geometries- Returns:
- the union of the geometries,
or
null
if the input is empty
-
union
Computes the geometric union of aCollection
ofGeometry
s. If no input geometries were provided but aGeometryFactory
was provided, an emptyGeometryCollection
is returned.- Parameters:
geoms
- a collection of geometriesgeomFact
- the geometry factory to use if the collection is empty- Returns:
- the union of the geometries, or an empty GEOMETRYCOLLECTION
-
union
Constructs a unary union operation for aGeometry
(which may be aGeometryCollection
).- Parameters:
geom
- a geometry to union- Returns:
- the union of the elements of the geometry or an empty GEOMETRYCOLLECTION
-
setUnionFunction
-
union
Gets the union of the input geometries.The result of empty input is determined as follows:
- If the input is empty and a dimension can be determined (i.e. an empty geometry is present), an empty atomic geometry of that dimension is returned.
- If no input geometries were provided but a
GeometryFactory
was provided, an emptyGeometryCollection
is returned. - Otherwise, the return value is
null
.
- Returns:
- a Geometry containing the union,
or an empty atomic geometry, or an empty GEOMETRYCOLLECTION,
or
null
if no GeometryFactory was provided
-