Class GeometrySimplifier<T extends Geometry>
- Direct Known Subclasses:
GeometrySimplifier.GeometryCollections
,GeometrySimplifier.Identity
,GeometrySimplifier.LinearRingSimplifier
,GeometrySimplifier.LineSimplifier
,GeometrySimplifier.MultiPolygonSimplifier
,GeometrySimplifier.PolygonSimplifier
k=1000
, the memory usage should be:
- Original complete geometry (in this example, one shell and several holes)
- Internal memory for simplifying the shell is
O(k)
, so an array of 1000 objects containing x, y and an estimated error. - Internal memory for simplifying each hole, which is a scaled down
k
based on the relative size of the hole. For example, if the shell is 100k points, and a hole is 1k points, we will scale the hole k to just 10 points. - The finally simplified geometry, which occupies a similar amount of memory to the simplification algorithm,
in other words
O(k)
GeometryCollection
.
Note, however, that no attempt is made to prevent invalid geometries from forming. For example, when simplifying a polygon, the removal of points can cause lines to cross, creating invalid polygons. Any usage of this algorithm needs to consider that possibility. If the simplification is only required for visualization, and the visualization code is tolerant of line crossings, this is not an issue. But if you need valid simplified geometries, do additional validation on the final results before using them.
If the incoming data is a stream of points, or x and y coordinates, it is even more memory efficient to directly use the
StreamingGeometrySimplifier
which will only maintain the single array of length k
, and produce a final
geometry of O(k)
at the end, so the total size of the original geometry is not a factor.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This class wraps a collection of other simplifiers.static class
GeometrySimplifier.Identity<G extends Geometry>
This simplifier simply returns the original geometry unsimplified.static class
This behaves the same as the Line simplifier except that it assumes the first and last point are the same point.static class
Simplifies a Line geometry to the specified maximum number of points.static class
This class wraps a collection of Polygon simplifiers.static class
This class wraps a collection of LinearRing simplifiers for polygon holes. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final SimplificationErrorCalculator
protected String
protected final StreamingGeometrySimplifier
<T> protected final int
protected final StreamingGeometrySimplifier.Monitor
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
GeometrySimplifier
(String description, int maxPoints, SimplificationErrorCalculator calculator, StreamingGeometrySimplifier.Monitor monitor, StreamingGeometrySimplifier<T> innerSimplifier) -
Method Summary
Modifier and TypeMethodDescriptionprotected List
<SimplificationErrorCalculator.PointLike> protected void
protected void
void
reset()
When re-using a simplifier instance, callreset()
to clear internal memorystatic <G extends Geometry>
GeometrySimplifier<G> simplifierFor
(G geometry, int maxPoints, SimplificationErrorCalculator calculator, StreamingGeometrySimplifier.Monitor monitor) abstract T
Simplify an entire geometry in a non-streaming fashion
-
Field Details
-
maxPoints
protected final int maxPoints -
calculator
-
monitor
-
description
-
innerSimplifier
-
-
Constructor Details
-
GeometrySimplifier
protected GeometrySimplifier(String description, int maxPoints, SimplificationErrorCalculator calculator, StreamingGeometrySimplifier.Monitor monitor, StreamingGeometrySimplifier<T> innerSimplifier)
-
-
Method Details
-
simplify
Simplify an entire geometry in a non-streaming fashion -
reset
public void reset()When re-using a simplifier instance, callreset()
to clear internal memory -
notifyMonitorSimplificationStart
protected void notifyMonitorSimplificationStart() -
notifyMonitorSimplificationEnd
protected void notifyMonitorSimplificationEnd() -
getCurrentPoints
-
simplifierFor
public static <G extends Geometry> GeometrySimplifier<G> simplifierFor(G geometry, int maxPoints, SimplificationErrorCalculator calculator, StreamingGeometrySimplifier.Monitor monitor)
-