Bläddra i källkod

r.reclass: Fix 'Unable to write range file' error when overwriting fp maps

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@61366 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 11 år sedan
förälder
incheckning
cf8b26670d
2 ändrade filer med 14 tillägg och 2 borttagningar
  1. 2 2
      raster/r.reclass/Makefile
  2. 12 0
      raster/r.reclass/reclass.c

+ 2 - 2
raster/r.reclass/Makefile

@@ -2,8 +2,8 @@ MODULE_TOPDIR = ../..
 
 PGM = r.reclass
 
-LIBES = $(RASTERLIB) $(GISLIB)
-DEPENDENCIES = $(RASTERDEP) $(GISDEP)
+LIBES = $(MANAGELIB) $(RASTERLIB) $(GISLIB)
+DEPENDENCIES = $(MANAGEDEP) $(RASTERDEP) $(GISDEP)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make
 

+ 12 - 0
raster/r.reclass/reclass.c

@@ -2,6 +2,7 @@
 #include <string.h>
 #include <grass/gis.h>
 #include <grass/raster.h>
+#include <grass/manage.h>
 #include <grass/glocale.h>
 #include "rule.h"
 
@@ -226,6 +227,17 @@ int reclass(const char *old_name, const char *old_mapset,
 	_reclass(rules, cats, &new);
     }
 
+    if (G_find_file2("cell", new_name, G_mapset())) {
+	G_suppress_warnings(1);
+
+	M_read_list(FALSE, NULL);
+        if (M_do_remove(M_get_element("rast"), new_name) == 1)
+	    G_fatal_error(_("Cannot overwrite existing raster map <%s>"),
+			  new_name);
+
+	G_suppress_warnings(0);
+    }
+
     if (Rast_put_reclass(new_name, &new) < 0)
 	G_fatal_error(_("Cannot create reclass file of <%s>"), new_name);