public class UnaryUnionOp extends Object
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:
Polygon
s has the effect of
merging the areas (i.e. the same effect as
iteratively unioning all individual polygons together).
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 the
Geometry.union(Geometry)
operation.
If merged linework is required, the LineMerger
class can be used.
Point
s has the effect of merging
all identical points (producing a set with no duplicates).
Constructor and Description |
---|
UnaryUnionOp(Collection geoms)
Constructs a unary union operation for a
Collection
of Geometry s, using the GeometryFactory
of the input geometries. |
UnaryUnionOp(Collection geoms,
GeometryFactory geomFact)
Constructs a unary union operation for a
Collection
of Geometry s. |
UnaryUnionOp(Geometry geom)
Constructs a unary union operation for a
Geometry
(which may be a GeometryCollection ). |
Modifier and Type | Method and Description |
---|---|
void |
setUnionFunction(UnionStrategy unionFun) |
Geometry |
union()
Gets the union of the input geometries.
|
static Geometry |
union(Collection geoms)
Computes the geometric union of a
Collection
of Geometry s. |
static Geometry |
union(Collection geoms,
GeometryFactory geomFact)
Computes the geometric union of a
Collection
of Geometry s. |
static Geometry |
union(Geometry geom)
Constructs a unary union operation for a
Geometry
(which may be a GeometryCollection ). |
public UnaryUnionOp(Collection geoms, GeometryFactory geomFact)
Collection
of Geometry
s.geoms
- a collection of geometriesgeomFact
- the geometry factory to use if the collection is emptypublic UnaryUnionOp(Collection geoms)
Collection
of Geometry
s, using the GeometryFactory
of the input geometries.geoms
- a collection of geometriespublic UnaryUnionOp(Geometry geom)
Geometry
(which may be a GeometryCollection
).geom
- public static Geometry union(Collection geoms)
Collection
of Geometry
s.geoms
- a collection of geometriesnull
if the input is emptypublic static Geometry union(Collection geoms, GeometryFactory geomFact)
Collection
of Geometry
s.
If no input geometries were provided but a GeometryFactory
was provided,
an empty GeometryCollection
is returned.geoms
- a collection of geometriesgeomFact
- the geometry factory to use if the collection is emptypublic static Geometry union(Geometry geom)
Geometry
(which may be a GeometryCollection
).geom
- a geometry to unionpublic void setUnionFunction(UnionStrategy unionFun)
public Geometry union()
The result of empty input is determined as follows:
GeometryFactory
was provided,
an empty GeometryCollection
is returned.
null
.
null
if no GeometryFactory was providedCopyright © 2022. All rights reserved.