Skip to content

Commit

Permalink
r.report: Work with any mask name (also for r.kappa) (#4633)
Browse files Browse the repository at this point in the history
Use Rast_mask_status in r.report and r.kappa to get the name and state.
  • Loading branch information
wenzeslaus authored Nov 6, 2024
1 parent aa07454 commit 9537d74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions raster/r.kappa/mask.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ char *maskinfo(void)
{
struct Reclass reclass;
char *results;
char text[100];
char text[2 * GNAME_MAX + GMAPSET_MAX];
int next;
int first;
char mask_name[GNAME_MAX];
char mask_mapset[GMAPSET_MAX];

results = NULL;
if (G_find_raster("MASK", G_mapset()) == NULL)
if (!Rast_mask_status(mask_name, mask_mapset, NULL, NULL, NULL))
return "none";
if (Rast_get_reclass("MASK", G_mapset(), &reclass) <= 0) {
sprintf(text, "MASK in %s", G_mapset());
if (Rast_get_reclass(mask_name, mask_mapset, &reclass) <= 0) {
sprintf(text, "%s in %s", mask_name, mask_mapset);
return append(results, text);
}

Expand Down
10 changes: 6 additions & 4 deletions raster/r.report/maskinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ char *maskinfo(void)
{
struct Reclass reclass;
char *results;
char text[100];
char text[2 * GNAME_MAX + GMAPSET_MAX];
int next;
int first;
char mask_name[GNAME_MAX];
char mask_mapset[GMAPSET_MAX];

results = NULL;
if (G_find_raster("MASK", G_mapset()) == NULL)
if (!Rast_mask_status(mask_name, mask_mapset, NULL, NULL, NULL))
return "none";
if (Rast_get_reclass("MASK", G_mapset(), &reclass) <= 0) {
sprintf(text, "MASK in %s", G_mapset());
if (Rast_get_reclass(mask_name, mask_mapset, &reclass) <= 0) {
sprintf(text, "%s in %s", mask_name, mask_mapset);
return append(results, text);
}

Expand Down

0 comments on commit 9537d74

Please sign in to comment.