[GRASS-SVN] r72380 - grass/trunk/raster/r.texture
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Mar 18 10:08:21 PDT 2018
Author: mlennert
Date: 2018-03-18 10:08:21 -0700 (Sun, 18 Mar 2018)
New Revision: 72380
Modified:
grass/trunk/raster/r.texture/main.c
Log:
r.texture: Fatal error if one of the requested output maps exists (fix for #3492)
Modified: grass/trunk/raster/r.texture/main.c
===================================================================
--- grass/trunk/raster/r.texture/main.c 2018-03-18 16:46:37 UTC (rev 72379)
+++ grass/trunk/raster/r.texture/main.c 2018-03-18 17:08:21 UTC (rev 72380)
@@ -76,7 +76,7 @@
char *name, *result;
char **mapname;
FCELL **fbuf;
- int n_measures, n_outputs, *measure_idx;
+ int n_measures, n_outputs, *measure_idx, overwrite;
int nrows, ncols;
int row, col, first_row, last_row, first_col, last_col;
int i, j;
@@ -105,7 +105,6 @@
G_add_keyword(_("texture"));
module->description =
_("Generate images with textural features from a raster map.");
- module->overwrite = 1;
/* Define the different options */
@@ -243,6 +242,8 @@
mapname[i] = G_malloc(GNAME_MAX * sizeof(char));
fbuf[i] = Rast_allocate_buf(out_data_type);
}
+
+ overwrite = G_check_overwrite(argc, argv);
/* open output maps */
outfd = G_malloc(n_outputs * sizeof(int));
@@ -251,13 +252,21 @@
for (j = 0; j < 4; j++) {
sprintf(mapname[i * 4 + j], "%s%s_%d", result,
menu[measure_idx[i]].suffix, j * 45);
- outfd[i * 4 + j] = Rast_open_new(mapname[i * 4 + j], out_data_type);
+ if (!G_find_raster(mapname[i * 4 + j], G_mapset()) || overwrite) {
+ outfd[i * 4 + j] = Rast_open_new(mapname[i * 4 + j], out_data_type);
+ } else {
+ G_fatal_error(_("At least one of the requested output maps exists. Use --o to overwrite."));
+ }
}
}
else {
sprintf(mapname[i], "%s%s", result,
menu[measure_idx[i]].suffix);
- outfd[i] = Rast_open_new(mapname[i], out_data_type);
+ if (!G_find_raster(mapname[i], G_mapset()) || overwrite) {
+ outfd[i] = Rast_open_new(mapname[i], out_data_type);
+ } else {
+ G_fatal_error(_("At least one of the requested output maps exists. Use --o to overwrite."));
+ }
}
}
nrows = Rast_window_rows();
More information about the grass-commit
mailing list