Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raster: Add library function to ask for mask presence #4402

Merged
merged 6 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/grass/defs/raster.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ int Rast_option_to_interp_type(const struct Option *);
/* mask_info.c */
char *Rast_mask_info(void);
int Rast__mask_info(char *, char *);
bool Rast_mask_is_present(void);

/* maskfd.c */
int Rast_maskfd(void);
Expand Down
10 changes: 10 additions & 0 deletions lib/raster/mask_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,13 @@ int Rast__mask_info(char *name, char *mapset)

return 1;
}

/**
* @brief Check presence of 2D raster mask
*
* @return true if mask is present, false otherwise
*/
bool Rast_mask_is_present(void)
{
return G_find_raster("MASK", G_mapset()) != NULL;
}
4 changes: 2 additions & 2 deletions raster/r.mfilter/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ int main(int argc, char **argv)
"threads setting."));
nprocs = 1;
#endif
if (nprocs > 1 && G_find_raster("MASK", G_mapset()) != NULL) {
G_warning(_("Parallel processing disabled due to active MASK."));
if (nprocs > 1 && Rast_mask_is_present()) != NULL) {
G_warning(_("Parallel processing disabled due to active mask."));
nprocs = 1;
}
wenzeslaus marked this conversation as resolved.
Show resolved Hide resolved
out_name = opt2->answer;
Expand Down
4 changes: 2 additions & 2 deletions raster/r.neighbors/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ int main(int argc, char *argv[])
"threads setting."));
ncb.threads = 1;
#endif
if (ncb.threads > 1 && G_find_raster("MASK", G_mapset()) != NULL) {
G_warning(_("Parallel processing disabled due to active MASK."));
if (ncb.threads > 1 && Rast_mask_is_present()) != NULL) {
G_warning(_("Parallel processing disabled due to active mask."));
ncb.threads = 1;
}
wenzeslaus marked this conversation as resolved.
Show resolved Hide resolved
if (strcmp(parm.weighting_function->answer, "none") && flag.circle->answer)
Expand Down
4 changes: 2 additions & 2 deletions raster/r.patch/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ int main(int argc, char *argv[])
"threads setting."));
nprocs = 1;
#endif
if (nprocs > 1 && G_find_raster("MASK", G_mapset()) != NULL) {
G_warning(_("Parallel processing disabled due to active MASK."));
if (nprocs > 1 && Rast_mask_is_present()) != NULL) {
G_warning(_("Parallel processing disabled due to active mask."));
nprocs = 1;
}
wenzeslaus marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
4 changes: 2 additions & 2 deletions raster/r.resamp.filter/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ int main(int argc, char *argv[])
"threads setting."));
nprocs = 1;
#endif
if (nprocs > 1 && G_find_raster("MASK", G_mapset()) != NULL) {
G_warning(_("Parallel processing disabled due to active MASK."));
if (nprocs > 1 && Rast_mask_is_present()) != NULL) {
G_warning(_("Parallel processing disabled due to active make."));
nprocs = 1;
}
wenzeslaus marked this conversation as resolved.
Show resolved Hide resolved
if (parm.radius->answer) {
Expand Down
4 changes: 2 additions & 2 deletions raster/r.resamp.interp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ int main(int argc, char *argv[])
"threads setting."));
threads = 1;
#endif
if (threads > 1 && G_find_raster("MASK", G_mapset()) != NULL) {
G_warning(_("Parallel processing disabled due to active MASK."));
if (threads > 1 && Rast_mask_is_present()) != NULL) {
G_warning(_("Parallel processing disabled due to active mask."));
threads = 1;
}
wenzeslaus marked this conversation as resolved.
Show resolved Hide resolved
bufrows = atoi(memory->answer) * (((1 << 20) / sizeof(DCELL)) / dst_w.cols);
Expand Down
4 changes: 2 additions & 2 deletions raster/r.series/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ int main(int argc, char *argv[])
"threads setting."));
nprocs = 1;
#endif
if (nprocs > 1 && G_find_raster("MASK", G_mapset()) != NULL) {
G_warning(_("Parallel processing disabled due to active MASK."));
if (nprocs > 1 && Rast_mask_is_present()) != NULL) {
G_warning(_("Parallel processing disabled due to active mask."));
nprocs = 1;
}
wenzeslaus marked this conversation as resolved.
Show resolved Hide resolved
lo = -INFINITY;
Expand Down
4 changes: 2 additions & 2 deletions raster/r.sim/r.sim.sediment/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ int main(int argc, char *argv[])
#else
threads = 1;
#endif
if (threads > 1 && G_find_raster("MASK", G_mapset()) != NULL) {
G_warning(_("Parallel processing disabled due to active MASK."));
if (threads > 1 && Rast_mask_is_present()) != NULL) {
G_warning(_("Parallel processing disabled due to active mask."));
threads = 1;
}
wenzeslaus marked this conversation as resolved.
Show resolved Hide resolved
G_message(_("Number of threads: %d"), threads);
Expand Down
4 changes: 2 additions & 2 deletions raster/r.sim/r.sim.water/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ int main(int argc, char *argv[])
#else
threads = 1;
#endif
if (threads > 1 && G_find_raster("MASK", G_mapset()) != NULL) {
G_warning(_("Parallel processing disabled due to active MASK."));
if (threads > 1 && Rast_mask_is_present()) != NULL) {
G_warning(_("Parallel processing disabled due to active mask."));
threads = 1;
}
wenzeslaus marked this conversation as resolved.
Show resolved Hide resolved
G_message(_("Number of threads: %d"), threads);
Expand Down
4 changes: 2 additions & 2 deletions raster/r.slope.aspect/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ int main(int argc, char *argv[])
"threads setting."));
nprocs = 1;
#endif
if (nprocs > 1 && G_find_raster("MASK", G_mapset()) != NULL) {
G_warning(_("Parallel processing disabled due to active MASK."));
if (nprocs > 1 && Rast_mask_is_present()) != NULL) {
G_warning(_("Parallel processing disabled due to active mask."));
nprocs = 1;
}
wenzeslaus marked this conversation as resolved.
Show resolved Hide resolved
radians_to_degrees = 180.0 / M_PI;
Expand Down
4 changes: 2 additions & 2 deletions raster/r.sun/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,8 @@ int main(int argc, char *argv[])
#else
threads = 1;
#endif
if (threads > 1 && G_find_raster("MASK", G_mapset()) != NULL) {
G_warning(_("Parallel processing disabled due to active MASK."));
if (threads > 1 && Rast_mask_is_present()) != NULL) {
G_warning(_("Parallel processing disabled due to active mask."));
threads = 1;
}
wenzeslaus marked this conversation as resolved.
Show resolved Hide resolved
G_message(_("Number of threads <%d>"), threads);
Expand Down
4 changes: 2 additions & 2 deletions raster/r.univar/r.univar_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ int main(int argc, char *argv[])
sscanf(param.nprocs->answer, "%d", &nprocs);
if (nprocs < 1)
G_fatal_error(_("<%d> is not valid number of nprocs."), nprocs);
if (nprocs > 1 && G_find_raster("MASK", G_mapset()) != NULL) {
G_warning(_("Parallel processing disabled due to active MASK."));
if (nprocs > 1 && Rast_mask_is_present()) != NULL) {
G_warning(_("Parallel processing disabled due to active mask."));
nprocs = 1;
}
wenzeslaus marked this conversation as resolved.
Show resolved Hide resolved
#if defined(_OPENMP)
Expand Down
4 changes: 2 additions & 2 deletions vector/v.surf.rst/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ int main(int argc, char *argv[])
G_warning(_("GRASS GIS is not compiled with OpenMP support, parallel "
"computation is disabled."));
#endif
if (threads > 1 && G_find_raster("MASK", G_mapset()) != NULL) {
G_warning(_("Parallel processing disabled due to active MASK."));
if (threads > 1 && Rast_mask_is_present()) != NULL) {
G_warning(_("Parallel processing disabled due to active mask."));
threads = 1;
}
wenzeslaus marked this conversation as resolved.
Show resolved Hide resolved
if (devi) {
Expand Down
Loading