Skip to content

Commit

Permalink
Provide all information about the possible reclass with the API and t…
Browse files Browse the repository at this point in the history
…he module
  • Loading branch information
wenzeslaus committed May 20, 2022
1 parent d88dd02 commit c92ae7f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/grass/defs/raster.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ int Rast_option_to_interp_type(const struct Option *);

/* mask_info.c */
char *Rast_mask_info(void);
bool Rast_mask_status(char *, char *, bool *);
bool Rast_mask_status(char *, char *, bool *, char *, char *);
int Rast__mask_info(char *, char *);

/* maskfd.c */
Expand Down
9 changes: 4 additions & 5 deletions lib/raster/mask_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,15 @@ char *Rast_mask_info(void)
*
* @return true if mask is present, false otherwise
*/
bool Rast_mask_status(char *name, char *mapset, bool *is_mask_reclass)
bool Rast_mask_status(char *name, char *mapset, bool *is_mask_reclass,
char *reclass_name, char *reclass_mapset)
{
int present = Rast__mask_info(name, mapset);

if (is_mask_reclass) {
if (is_mask_reclass && reclass_name && reclass_mapset) {
if (present) {
char rname[GNAME_MAX], rmapset[GMAPSET_MAX];

*is_mask_reclass =
Rast_is_reclass("MASK", G_mapset(), rname, rmapset) > 0;
Rast_is_reclass("MASK", G_mapset(), reclass_name, reclass_mapset) > 0;
}
else {
*is_mask_reclass = false;
Expand Down
1 change: 1 addition & 0 deletions raster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ SUBDIRS = \
r.lake \
r.li \
r.mapcalc \
r.mask.status \
r.mfilter \
r.mode \
r.neighbors \
Expand Down
9 changes: 5 additions & 4 deletions raster/r.mask.status/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void parse_parameters(struct Parameters *params, int argc, char **argv)

params->like_test = G_define_flag();
params->like_test->key = 't';
params->like_test->lable =
params->like_test->label =
_("Return code 0 when mask present, 1 otherwise");
params->like_test->description =
_("Behave like the test utility, 0 for true, 1 for false, no output");
Expand Down Expand Up @@ -84,12 +84,13 @@ int report_status(struct Parameters *params)

char name[GNAME_MAX];
char mapset[GMAPSET_MAX];
char reclass_name[GNAME_MAX];
char reclass_mapset[GMAPSET_MAX];

bool is_mask_reclass;
bool present =
Rast_mask_status(name, mapset, reclass_name, reclass_mapset,
&is_mask_reclass);
bool present = Rast_mask_present(name, mapset);
Rast_mask_status(name, mapset, &is_mask_reclass, reclass_name, reclass_mapset);
// bool present = Rast_mask_present(name, mapset); // This would check the map presence rather than the automasking state in the library.

//printf("%s", Rast_mask_info());

Expand Down

0 comments on commit c92ae7f

Please sign in to comment.