Skip to main content

Module remove_spikes

Module remove_spikes 

Source
Expand description

remove_spikes(&mut g) — drop collinear-and-reversed vertices.

Mirrors boost::geometry::remove_spikes from boost/geometry/algorithms/remove_spikes.hpp. A spike is a triple (a, b, c) where (b-a) × (c-b) == 0 (collinear) AND (b-a) · (c-b) < 0 (reversed). The middle vertex b is removed; the walk repeats until no spike remains, because collapsing one spike can create a new one at the now-adjacent pair.

Per-kind:

  • Linestring, Ring → spike-walk the backing Vec<P>
  • Polygon → walk outer + every inner ring
  • MultiPolygon → 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 g in place.