public class CascadedPolygonUnion
extends java.lang.Object
Polygonal
geometries.
The geometries are indexed using a spatial index,
and unioned recursively in index order.
For geometries with a high degree of overlap,
this has the effect of reducing the number of vertices
early in the process, which increases speed
and robustness.
This algorithm is faster and more robust than the simple iterated approach of repeatedly unioning each polygon to a result geometry.
The buffer(0) trick is sometimes faster, but can be less robust and can sometimes take a long time to complete. This is particularly the case where there is a high degree of overlap between the polygons. In this case, buffer(0) is forced to compute with all line segments from the outset, whereas cascading can eliminate many segments at each stage of processing. The best situation for using buffer(0) is the trivial case where there is no overlap between the input geometries. However, this case is likely rare in practice.
Constructor | Description |
---|---|
CascadedPolygonUnion(java.util.Collection polys) |
Creates a new instance to union
the given collection of
Geometry s. |
Modifier and Type | Method | Description |
---|---|---|
Geometry |
union() |
Computes the union of the input geometries.
|
static Geometry |
union(java.util.Collection polys) |
public static Geometry union(java.util.Collection polys)
public Geometry union()
This method discards the input geometries as they are processed. In many input cases this reduces the memory retained as the operation proceeds. Optimal memory usage is achieved by disposing of the original input collection before calling this method.
java.lang.IllegalStateException
- if this method is called more than onceCopyright © 2018. All rights reserved.