Skip to content

Commit

Permalink
Use Rast_mask_status instead of hardcoded name for r.surf.contour, r.…
Browse files Browse the repository at this point in the history
…random.cells, r.random.surface
  • Loading branch information
wenzeslaus committed Nov 1, 2024
1 parent 4964f45 commit 68534ea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 4 additions & 2 deletions raster/r.random.cells/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ void Init(void)

Cells = FlagCreate(Rs, Cs);
CellCount = 0;
if (G_find_raster2("MASK", G_mapset())) {
FD = Rast_open_old("MASK", G_mapset());
char mask_name[GNAME_MAX];
char mask_mapset[GMAPSET_MAX];
if (Rast_mask_status(mask_name, mask_mapset, NULL, NULL, NULL)) {
FD = Rast_open_old(mask_name, mask_mapset);
{
for (row = 0; row < Rs; row++) {
Rast_get_c_row_nomask(FD, CellBuffer, row);
Expand Down
14 changes: 8 additions & 6 deletions raster/r.random.surface/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ void Init(void)
else
MinRes = NS;

if (NULL == G_find_file("cell", "MASK", G_mapset())) {
MapCount = Rs * Cs;
FDM = -1;
}
else {
FDM = Rast_open_old("MASK", G_mapset());
char mask_name[GNAME_MAX];
char mask_mapset[GMAPSET_MAX];
if (Rast_mask_status(mask_name, mask_mapset, NULL, NULL, NULL)) {
FDM = Rast_open_old(mask_name, mask_mapset);
{
MapCount = 0;
CellBuffer = Rast_allocate_c_buf();
Expand All @@ -53,6 +51,10 @@ void Init(void)
}
}
}
else {
MapCount = Rs * Cs;
FDM = -1;
}

if (Uniform->answer)
sprintf(Buf, "Uni. R. S.");
Expand Down
6 changes: 4 additions & 2 deletions raster/r.surf.contour/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ int main(int argc, char *argv[])
alt_row = (DCELL *)G_malloc(ncols * sizeof(DCELL));
seen = flag_create(nrows, ncols);
mask = flag_create(nrows, ncols);
if (NULL != G_find_file("cell", "MASK", G_mapset())) {
file_fd = Rast_open_old("MASK", G_mapset());
char mask_name[GNAME_MAX];
char mask_mapset[GMAPSET_MAX];
if (Rast_mask_status(mask_name, mask_mapset, NULL, NULL, NULL)) {
file_fd = Rast_open_old(mask_name, mask_mapset);
for (r = 0; r < nrows; r++) {
Rast_get_d_row_nomask(file_fd, alt_row, r);
for (c = 0; c < ncols; c++)
Expand Down

0 comments on commit 68534ea

Please sign in to comment.