You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Non-finite distances, areas and coordinates display as "NaN km", "inf km", "-inf m", "NaN° E NaN° N" #938
The measurement formatters in crates/geom/src/lib.rs print non-finite values as if they were numbers, and these strings reach the UI:
Call
Result
format_distance(f64::NAN)
"NaN km"
format_area(f64::NAN)
"NaN km²"
format_distance(f64::INFINITY)
"inf km"
format_distance(f64::NEG_INFINITY)
"-inf m"
format_lonlat(Coord::new(NaN, NaN))
"NaN° E NaN° N"
format_dms(Coord::new(NaN, 50.0))
"NaN°NaN′0NaN″ E 50°00′00.0″ N"
format_distance(NaN) prints "NaN km" because both m.round() < 1000.0 and (m / 100.0).round() < 1000.0 are false for NaN, falling into the "km branch" with {:.0}.
Callers that pass results through these formatters:
the measure tool's metric panel (ui-egui/src/measure_units.rs::distance calls geom::format_distance directly) — so any non-finite segment length (for example from a geometry with a NaN vertex, see the companion issue about haversine_m) shows as "NaN km" or "20,015,114 m";
the scale bar's label (render/src/text.rs);
route/match error strings built in analysis/src/network.rs.
The tiles router already handles this correctly and shows what I would expect here: tiles/src/routing.rs::format_distance returns "0 m" for non-finite input (its asserts at line 543 cover it).
Steps to reproduce
rustgis_geom::format_distance(f64::NAN) → "NaN km", as in the table above.
Expected behavior
Non-finite distances, areas and coordinates display as an em dash, blank, or are refused upstream so the value never reaches a formatter — consistently with routing::format_distance's existing non-finite handling. Whatever is chosen, the same behaviour should hold for format_distance, format_area, format_lonlat and format_dms, since they are shown side by side in the measure panel and status bar.
Where it may come from
The formatters assume finite input. Adding a non-finite guard at the top of each (mirroring routing::format_distance) is a small, self-contained change; the sooner fix is at the measurement level (companion issue), which stops non-finite values from being produced at all.
How are you running RustGIS?
Desktop app built from source, on Linux (WSL); verified as a library test against rustgis-geom.
I'll take this. I'll make the four shared formatters return an em dash for non-finite values, and have the measurement panel's imperial distance/area paths use the same fallback. Existing finite-value formatting stays unchanged. I'll add NaN/±infinity regressions, check metric/imperial rendering, and run the full local CI, pre-commit and WASM build.
Activity
choupeanut commentedon Oct 26, 2026
I'll take this. I'll make the four shared formatters return an em dash for non-finite values, and have the measurement panel's imperial distance/area paths use the same fallback. Existing finite-value formatting stays unchanged. I'll add NaN/±infinity regressions, check metric/imperial rendering, and run the full local CI, pre-commit and WASM build.
fix(geom): show nonfinite measurements as unavailable (#938) (#960)