Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
main ▾

Modern-Apps.git / scripts / maps / mamaps_build / src / schema / buildings_extra.rs

buildings_extra.rs7 lines · 280 BRaw
1/// Metres to decimetres, rounded and clamped to `u16`; negative or non-finite yields `None`.
2pub(crate) fn dm_of(metres: f64) -> Option<u16> {
3 if !metres.is_finite() || metres < 0.0 {
4 return None;
5 }
6 Some((metres * 10.0).round().min(u16::MAX as f64) as u16)
7}