[GRASS-git] [OSGeo/grass-addons] e312a3: r.cell.area: fix silent exit on unsupported projec...
Andy Wickert
noreply at github.com
Mon Jun 8 10:46:10 PDT 2026
Branch: refs/heads/grass8
Home: https://github.com/OSGeo/grass-addons
Commit: e312a31523c7f9a7cc5aa54afdf1c8d2a30eb9c1
https://github.com/OSGeo/grass-addons/commit/e312a31523c7f9a7cc5aa54afdf1c8d2a30eb9c1
Author: Andy Wickert <andy at northernwidget.com>
Date: 2026-06-08 (Mon, 08 Jun 2026)
Changed paths:
M src/raster/r.cell.area/r.cell.area.py
A src/raster/r.cell.area/testsuite/test_r_cell_area.py
Log Message:
-----------
r.cell.area: fix silent exit on unsupported projection units; support all linear CRS; add testsuite (#1727)
* r.cell.area: use gs.fatal() for unsupported projection units
Replaces a bare print() + silent exit-0 with gs.fatal() so pipelines
and wrapper scripts can detect the failure via a non-zero exit code.
Also switches projinfo["units"] to .get("units", "") to avoid a
KeyError on unusual CRSes that don't report a units key.
Fixes #1716.
Co-Authored-By: Claude Sonnet 4.6 <noreply at anthropic.com>
* r.cell.area: remove unused imports
os, glob, garray, and VectorTopo were imported but never used.
Co-Authored-By: Claude Sonnet 4.6 <noreply at anthropic.com>
* r.cell.area: generalize to all projected CRS using meters conversion factor
Instead of matching against "meters"/"Meters" as a special case, use the
numeric meters-per-map-unit conversion factor that g.proj -g always
provides in its "meters" key. This makes the projected-CRS branch work
correctly for any linear unit (feet, US survey feet, nautical miles, etc.)
without enumerating unit names. The degrees branch is unchanged.
Also tightens the case-insensitive check for geographic CRS to catch
both "degrees" and "degree" regardless of capitalisation, and gives an
explicit fatal error for XY (unprojected) locations.
Co-Authored-By: Claude Sonnet 4.6 <noreply at anthropic.com>
* r.cell.area: add testsuite
Four test classes covering:
- Projected CRS (UTM, metres): m² and km² values with known cell sizes,
overwrite protection, overwrite flag (runs in the NC sample dataset)
- Geographic CRS (EPSG:4326): m² matches the spherical approximation,
km²/m² ratio is 1 000 000 (spawns a temporary GRASS project)
- US survey feet CRS (EPSG:2249): m² and km² via the meters conversion
factor (spawns a temporary GRASS project)
- XY (unprojected) location: module must exit non-zero
Subprocess helper auto-detects --tmp-project (GRASS 8.4+) vs the older
--tmp-location flag.
Co-Authored-By: Claude Sonnet 4.6 <noreply at anthropic.com>
* r.cell.area: fix INT002 translation-before-format and ruff formatting
INT002: _("string {}".format(x)) evaluates the format before gettext can
act on the template; use _("string %s") % x instead so the untranslated
template string is what gettext sees.
Also collapse three multi-line calls that ruff format requires on one line.
Co-Authored-By: Claude Sonnet 4.6 <noreply at anthropic.com>
* r.cell.area testsuite: fix E226 whitespace and ruff formatting
E226: add spaces around * in three f-string expressions
(self._rel_tol*100 → self._rel_tol * 100).
Also collapse two multi-line calls (subprocess.run, assertModule) that
ruff format requires on a single line.
Co-Authored-By: Claude Sonnet 4.6 <noreply at anthropic.com>
* r.cell.area testsuite: collapse two more multi-line runModule calls
Ruff format requires cls.runModule(g.region ...) and
self.runModule(g.remove ...) on single lines.
Co-Authored-By: Claude Sonnet 4.6 <noreply at anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply at anthropic.com>
To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass-addons/settings/notifications
More information about the grass-commit
mailing list