Repository navigation
Analysis: Calculate Geometry stores full-precision area, perimeter and length - #520
Conversation
calculateGeometry rounded area_km2, perimeter_km and length_km to two decimals before storing them, so every polygon under about half a hectare got an area of 0 and short lines a length of 0. Store the computed values as they are. CSV export wrote Double values through Display, which rounds to six decimals, so a sub-square-metre area in km2 still exported as 0. Write floats as the shortest text that reads back as the same number. Fixes #513
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Code reviewI read the full diff (two files) and found nothing blocking. I did not build the code or run the tests. Bugs
Security
Performance
Quality
AGENTS.md
Change sizeCompared: the whole PR against main (merge base 67c8cb8 to PR head e706526)
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. |
Root cause
calculate_geometryincrates/analysis/src/tools.rsroundedarea_km2,perimeter_kmandlength_kmto two decimals (0.01 km², 0.01 km) before storing them, so any polygon under about half a hectare gotarea_km2 = 0and lines under 5 m gotlength_km = 0.A second, smaller loss sat in CSV export:
csv_cellwroteValue::FloatthroughDisplay, which rounds to six decimals for the attribute table, so an area below about 0.5 m² in km² still exported as0.Fix
m² / 1e6,m / 1e3).f64::to_string, the shortest text that reads back as the same number (integers still print without a decimal point). The attribute table keeps its six-decimal display.Tests
tools::tests::calculate_geometry_keeps_small_values: a ~50 m square and a ~2.2 m line get non-zero, unrounded area, perimeter and length (fails onmainwith area 0).io::tests::csv_floats_keep_full_precision:0.0000004and0.002492708survive a CSV round trip (fails onmain).Verification
Reran the issue's CLI repro (three squares in EPSG:25832,
calculateGeometry,share.exportLayerto CSV).squares_out.csvnow reads:The 50 m square matches the expected ~0.0024927 km². The wasm build of
rustgis-webpasses. Locally,cargo xtask cipasses except theletting_agents_control_rustgis_starts_the_relay_and_shows_how_to_connectUI smoke test, which fails the same way on a cleanorigin/maincheckout on this machine and passes in CI, so it is unrelated to this change.Fixes #513