Skip to main content

estimate_headings_from_neighbors

Function estimate_headings_from_neighbors 

Source
pub fn estimate_headings_from_neighbors(
    positions: &[&GnssPosition],
) -> Vec<Option<f64>>
Expand description

Estimate headings from neighboring GNSS positions.

For each interior position x, computes the haversine bearing from position x-1 to x+1. The estimate is discarded when:

  • x is the first or last position (no symmetric neighbors),
  • the distances x-1 → x and x → x+1 differ by ≥ 20% of the larger,
  • the backward bearing (x-1x) and forward bearing (xx+1) diverge by ≥ 5° (lateral-jump / junction guard),
  • consecutive estimated headings change by ≥ 5° (continuity check).

Returns a Vec with the same length as positions; entries that fail any guard are None.