GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
mask_info.c
Go to the documentation of this file.
1 /*
2  *************************************************************
3  * char * Rast_mask_info ()
4  *
5  * returns a printable text of mask information
6  *
7  ************************************************************
8  * Rast__mask_info (name, mapset)
9  *
10  * char name[GNAME_MAX], mapset[GMAPSET_MAX];
11  *
12  * function:
13  * determine the status off the automatic masking
14  * and the name of the cell file which forms the mask
15  *
16  * (the mask file is actually MASK in the current mapset,
17  * but is usually a reclassed cell file, and the reclass
18  * name and mapset are returned)
19  *
20  * returns:
21  * -1 no masking (name, mapset undefined)
22  * name, mapset are undefined
23  *
24  * 1 mask file present, masking on
25  * name, mapset hold mask file name, mapset
26  *
27  ***************************************************************/
28 
29 #include <string.h>
30 
31 #include <grass/gis.h>
32 #include <grass/raster.h>
33 #include <grass/glocale.h>
34 
35 char *Rast_mask_info(void)
36 {
37  char text[GNAME_MAX + GMAPSET_MAX + 16];
38  char name[GNAME_MAX];
39  char mapset[GMAPSET_MAX];
40 
41  switch (Rast__mask_info(name, mapset)) {
42  case 1:
43  sprintf(text, _("<%s> in mapset <%s>"), name, mapset);
44  break;
45  case -1:
46  strcpy(text, _("none"));
47  break;
48  default:
49  strcpy(text, _("not known"));
50  break;
51  }
52 
53  return G_store(text);
54 }
55 
56 int Rast__mask_info(char *name, char *mapset)
57 {
58  char rname[GNAME_MAX], rmapset[GMAPSET_MAX];
59 
60  strcpy(name, "MASK");
61  strcpy(mapset, G_mapset());
62 
63  if (!G_find_raster(name, mapset))
64  return -1;
65 
66  if (Rast_is_reclass(name, mapset, rname, rmapset) > 0) {
67  strcpy(name, rname);
68  strcpy(mapset, rmapset);
69  }
70 
71  return 1;
72 }
#define GMAPSET_MAX
Definition: gis.h:178
int Rast_is_reclass(const char *, const char *, char *, char *)
Check if raster map is reclassified.
Definition: reclass.c:43
char * Rast_mask_info(void)
Definition: mask_info.c:35
int Rast__mask_info(char *name, char *mapset)
Definition: mask_info.c:56
const char * G_find_raster(char *, const char *)
Find a raster map.
Definition: find_rast.c:55
const char * G_mapset(void)
Get current mapset name.
Definition: gis/mapset.c:33
#define GNAME_MAX
Definition: gis.h:177
#define _(str)
Definition: glocale.h:10
char * G_store(const char *)
Copy string to allocated memory.
Definition: strings.c:87
const char * name
Definition: named_colr.c:7