Skip to content

[Bug]: The measure tool, the attribute table's Calculate Geometry and network edge lengths are still on the sphere, and disagree with the ellipsoidal geoprocessing tools #939

Open

Description

@subarna-kandel

What happened?

After #905 (buffers, Tissot's circles, Spatial Join distances on WGS 84) and #928 (the geoprocessing Calculate Geometry on WGS 84), three user-facing measurement paths still compute on the mean sphere (R = 6,371,008.8 m), so they now disagree with the fixed paths:

Path Where Still spherical?
gp tool calculateGeometry (analysis/src/tools.rs, #928) geoprocessing no — ellipsoidal
Attribute table's edit.calculateGeometry (engine/src/geometry_calc.rs) attribute table yes — geodesic_ring_area_m2 / geodesic_length_m
Measure tool (ui-egui/src/mapview.rs) map yes — same two functions
Network tools' edge lengths (analysis/src/network.rs) routing grids yes — haversine_m

Two of these are the same feature name shown to the user: "Calculate Geometry" in the geoprocessing ribbon gives the WGS 84 area, while the same button in the attribute table gives the sphere area for the same polygon — about 0.26 % apart (0.26 km² on a 100 km² municipality at 46.6°N, per #894's measurements). PR #905's summary explicitly left lengths and areas to #894.

Steps to reproduce

  1. Add a polygon layer in geographic CRS (the [Bug]: Calculate Geometry area and perimeter are computed on a sphere, 0.26 % off on the WGS 84 ellipsoid in Italy #894 Italian municipalities work well).
  2. Attribute table → Calculate Geometry (edit.calculateGeometry), area in m².
  3. rustgis-cli run --data … --cmd 'gp.run={"tool":"calculateGeometry", …}'.
  4. The two area fields differ by ~0.26 % in mid-latitudes.

Also: the measure tool's area and length for the same polygon differ from both.

Expected behavior

One measurement, wherever it is taken from. Either shared ellipsoidal length/area helpers (geographiclib-rs is already a dependency and offers PolygonArea; the wgs84_distance_m helper from #905 could grow into full length/area wrappers), or, as a stop-gap, the properties panel and labels say which approximations each number uses.

Where it may come from

haversine_m, geodesic_length_m and geodesic_ring_area_m2 in crates/geom/src/lib.rs still use EARTH_RADIUS_M. edit.calculateGeometry, the measure tool and the network arrived at the ellipsoidal work later than the gp path, so they never switched. Note the network's spherical edge lengths also decide which path is shortest, not just the printed length, so a route may differ from the geodesically optimal one.

How are you running RustGIS?

Desktop app built from source, on Linux (WSL).

Version

main at 342b2b2 (after #928).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions