Repository navigation
fix(geom): show nonfinite measurements as unavailable - #960
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Handle non-finite geometry values crates/geom/src/lib.rs |
The distance, area, longitude/latitude, and DMS formatters return an em dash for non-finite inputs. Tests cover these cases and representative finite values. |
Apply unavailable formatting across unit systems crates/ui-egui/src/measure_units.rs |
Distance and area use metric formatters for non-finite values in both unit systems. Tests also check imperial zero and one-unit formatting. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Possibly related issues
- opengeos/RustGIS#937 — This change hides non-finite measurement output but does not address
haversine_mproducing a finite distance from a NaN coordinate.
Suggested reviewers: mavrick-f
Merge Risk: 
Minimal · up to e1d20
-
The non-finite measurement display behavior is covered across metric and imperial paths, with no material merge-blocking risk identified.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
Issue
#938requires non-finite distances, areas, and coordinates to avoid numeric-looking output.crates/geom/src/lib.rsreturns—for NaN and both infinities informat_distanceandformat_area. It also returns—when either coordinate is non-finite informat_lonlatandformat_dms. Tests cover all three non-finite values, each invalid coordinate position, and representative finite values.crates/ui-egui/src/measure_units.rsapplies the metric fallback in imperial mode and tests both unit systems.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within issue
#938. The formatter guards, imperial measurement fallback, documentation updates, and regression tests directly support consistent handling of non-finite measurements and coordinates. No unrelated production behavior or dependency changes are shown.
-
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the numbers on the trail,
An em dash greets each value gone astray.
The miles and acres join the metric line,
While finite measures keep their proper sign.
The rabbit hops along beneath the moon.
Comment @coderabbitai help to get the list of available commands.
| @@ -376,6 +387,9 @@ pub fn format_dms(c: Coord) -> String { | |||
| let s = (tenths % 600.0) / 10.0; | |||
| format!("{d:.0}°{m:02.0}′{s:04.1}″") | |||
| } | |||
| if !c.is_finite() { | |||
| return "—".to_string(); | |||
| } | |||
There was a problem hiding this comment.
Nit: the non-finite guard sits after the nested dms helper here, while format_distance, format_area and format_lonlat check first. Moving it to the top of the function reads more consistently and keeps the early return next to the signature.
| pub fn format_dms(c: Coord) -> String { | |
| if !c.is_finite() { | |
| return "—".to_string(); | |
| } | |
| fn dms(v: f64) -> String { | |
| let tenths = (v.abs() * 36_000.0).round(); | |
| let d = (tenths / 36_000.0).floor(); | |
| let m = ((tenths % 36_000.0) / 600.0).floor(); | |
| let s = (tenths % 600.0) / 10.0; | |
| format!("{d:.0}°{m:02.0}′{s:04.1}″") | |
| } |
Code reviewBugs
Security
Performance
Quality
AGENTS.md
Confidence: high that the change is correct as written. The only actionable item is the nit above. Change sizeCompared with the base branch: the whole PR against main (merge base a5f50ce to PR head e1d201d).
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. |
Summary
Non-finite measurements and coordinates were displayed as numeric values such as
NaN km,inf km²orNaN° E. The shared distance, area, decimal-degree and DMS formatters now return—for NaN or either infinity. If either coordinate is invalid, the whole coordinate pair is unavailable.The measurement panel's imperial distance/area paths use the same fallback, so changing units cannot bring the invalid numeric text back. Finite-value formatting remains unchanged; there are no new dependencies or API changes.
Testing
NaN kmbefore the fix.cargo test -p rustgis-geom: 17 passed.cargo xtask ci: 2,404 passed, 0 failed, 16 ignored; layers passed.uvx pre-commit run --all-filescargo build --locked --target wasm32-unknown-unknown -p rustgis-webRelated issue
Closes #938.
Summary by CodeRabbit