GRASS GIS 7 Programmer's Manual  7.7.svn(2018)-r73587
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 }
const char * G_find_raster(char *name, const char *mapset)
Find a raster map.
Definition: find_rast.c:55
#define GMAPSET_MAX
Definition: gis.h:149
char * G_store(const char *s)
Copy string to allocated memory.
Definition: strings.c:86
int Rast_is_reclass(const char *name, const char *mapset, char *rname, char *rmapset)
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
#define GNAME_MAX
Definition: gis.h:148
#define _(str)
Definition: glocale.h:13
const char * G_mapset(void)
Get current mapset name.
Definition: gis/mapset.c:33
const char * name
Definition: named_colr.c:7