GRASS Programmer's Manual
6.4.3(2013)-r
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
Pages
auto_mask.c
Go to the documentation of this file.
1
17
#include <stdlib.h>
18
#include <grass/gis.h>
19
#include <grass/glocale.h>
20
#include "
G.h
"
21
22
34
int
G__check_for_auto_masking
(
void
)
35
{
36
struct
Cell_head cellhd;
37
38
/* if mask is switched off (-2) return -2
39
if G__.auto_mask is not set (-1) or set (>=0) recheck the MASK */
40
41
if
(
G__
.
auto_mask
< -1)
42
return
G__
.
auto_mask
;
43
44
/* if(G__.mask_fd > 0) G_free (G__.mask_buf); */
45
46
/* look for the existence of the MASK file */
47
G__
.
auto_mask
= (
G_find_cell
(
"MASK"
,
G_mapset
()) != 0);
48
49
if
(
G__
.
auto_mask
<= 0)
50
return
0;
51
52
/* check MASK projection/zone against current region */
53
if
(
G_get_cellhd
(
"MASK"
,
G_mapset
(), &cellhd) >= 0) {
54
if
(cellhd.zone !=
G_zone
() || cellhd.proj !=
G_projection
()) {
55
G__
.
auto_mask
= 0;
56
return
0;
57
}
58
}
59
60
G_unopen_cell
(
G__
.
mask_fd
);
61
G__
.
mask_fd
=
G__open_cell_old
(
"MASK"
,
G_mapset
());
62
if
(
G__
.
mask_fd
< 0) {
63
G__
.
auto_mask
= 0;
64
G_warning
(_(
"Unable to open automatic MASK file"
));
65
return
0;
66
}
67
68
/* G__.mask_buf = G_allocate_cell_buf(); */
69
70
G__
.
auto_mask
= 1;
71
72
return
1;
73
}
74
75
82
int
G_suppress_masking
(
void
)
83
{
84
if
(
G__
.
auto_mask
> 0) {
85
G_close_cell
(
G__
.
mask_fd
);
86
/* G_free (G__.mask_buf); */
87
G__
.
mask_fd
= -1;
88
}
89
G__
.
auto_mask
= -2;
90
91
return
0;
92
}
93
94
101
int
G_unsuppress_masking
(
void
)
102
{
103
if
(
G__
.
auto_mask
< -1) {
104
G__
.
mask_fd
= -1;
105
G__check_for_auto_masking
();
106
}
107
108
return
0;
109
}
lib
gis
auto_mask.c
Generated on Thu Sep 26 2013 09:47:58 for GRASS Programmer's Manual by
1.8.4