Skip to main content

parse_wind_segment_str

Function parse_wind_segment_str 

Source
pub fn parse_wind_segment_str(
    s: &str,
    imperial: bool,
) -> Result<WindSegment, String>
Expand description

Parse a "SPEED:ANGLE:UNTIL_DISTANCE[:VERTICAL]" string into a WindSegment (speed_kmh, angle_deg, until_distance_m, vertical_mps).

imperial: when true, SPEED is mph and UNTIL_DISTANCE is yards; otherwise SPEED is m/s and UNTIL_DISTANCE is meters. ANGLE is always degrees in the wind-FROM convention (0 = headwind, 90 = from the right). The optional 4th field, VERTICAL, is ALWAYS m/s (positive = updraft, raises POI) regardless of imperial — it does not follow –units, matching how WindSegment::vertical_mps stores it. This speed-in-display-units-but-vertical-always-m/s asymmetry is unit-honest (it mirrors the struct field name) even though it reads oddly next to SPEED. Omitting the 4th field keeps the historical 3-field behavior (vertical wind 0.0). Shared by the CLI (--wind-segment) and the WASM front-ends so they parse identically.