RingSimplifier

Polyline/ring simplification shared by the MVT decoder (earth.worldwind.layer.mvt.MvtGeometry) and the tiled WFS feature path (earth.worldwind.layer.FeatureRenderer).

Pure global iterative Douglas–Peucker. Recursively keeps the vertex farthest from the chord between the current endpoints whenever that distance exceeds the tolerance, so it preserves the deepest cape/bay vertex at every level and never bridges across a feature. (An earlier radial-distance pre-pass was removed: radial decimation at the full tolerance over-decimates and produces spikes at continental scale.)

Coordinate-space agnostic: the caller supplies vertex access (xAt/yAt) and the SQUARED tolerance in that same space — integer tile units for MVT, degrees for WFS. Endpoints are always kept (a ring's first == last vertex stays closed). Pass a reusable stack buffer (one per tile) so the hot path allocates nothing per ring.

Functions

Link copied to clipboard
inline fun simplify(n: Int, tolSq: Double, keep: BooleanArray, stack: IntList = IntList(), xAt: (Int) -> Double, yAt: (Int) -> Double)

Mark the survivors of simplifying the n-vertex ring/line in keep (size >= n); endpoints are always kept. tolSq is the SQUARED tolerance in the coordinate space of xAt/yAt. stack (DP explicit-recursion) is a reusable buffer (cleared here).