//! Geographic wrap/normalization helpers.
/// Wrap longitude into the canonical `[-180, 180)` degree range.
#[inline]
pub fn wrap_lon_180(lon: f64) -> f64 {
((lon + 180.0).rem_euclid(360.0)) - 180.0
}
/// Compute a `to_lon` value (equivalent modulo 360) that is closest to `from_lon`.
///
/// This matches the "shortest path" longitude behavior used by Mapbox/MapLibre
/// camera animations when crossing the antimeridian.
#[inline]
pub fn shortest_lon_target(from_lon: f64, to_lon: f64) -> f64 {
let from = wrap_lon_180(from_lon);
let to = wrap_lon_180(to_lon);
// delta in [-180, 180]
let mut d = (to - from).rem_euclid(360.0);
if d > 180.0 {
d -= 360.0;
}
from + d
}