Expand description
remove_spikes(&mut g) — drop collinear-and-reversed vertices.
Mirrors boost::geometry::remove_spikes from
boost/geometry/algorithms/remove_spikes.hpp. The predicate is
Boost’s point_is_spike_or_equal, and the or_equal half carries
its weight: a triple (a, b, c) qualifies when (b-a) × (c-b) == 0
(collinear) and (b-a) · (c-b) <= 0, which covers both a reversal
and a zero-length step — that is, a repeated vertex. The middle
vertex b is removed; the walk repeats until nothing qualifies,
because collapsing one spike can create a new one at the
now-adjacent pair, and peeling a spike off a ring routinely leaves a
repeated vertex behind.
Per-kind:
Linestring,Ring→ spike-walk the backingVec<P>Polygon→ walk outer + every inner ringMultiPolygon→ walk each member
Cartesian-only: the collinearity / reversal predicate is the 2D cross/dot product. Spherical / geographic spike detection needs angle-aware predicates; deferred until a downstream caller appears.
Functions§
- remove_
spikes - Remove spikes from
gin place.