[GRASS-SVN] r61159 - grass/trunk/raster/r.reclass

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jul 6 17:45:08 PDT 2014


Author: hcho
Date: 2014-07-06 17:45:08 -0700 (Sun, 06 Jul 2014)
New Revision: 61159

Modified:
   grass/trunk/raster/r.reclass/Makefile
   grass/trunk/raster/r.reclass/reclass.c
Log:
r.reclass: Fix "Unable to write range file" error when overwriting fp maps

Modified: grass/trunk/raster/r.reclass/Makefile
===================================================================
--- grass/trunk/raster/r.reclass/Makefile	2014-07-04 17:54:55 UTC (rev 61158)
+++ grass/trunk/raster/r.reclass/Makefile	2014-07-07 00:45:08 UTC (rev 61159)
@@ -2,8 +2,8 @@
 
 PGM = r.reclass
 
-LIBES = $(RASTERLIB) $(GISLIB)
-DEPENDENCIES = $(RASTERDEP) $(GISDEP)
+LIBES = $(MANAGELIB) $(RASTERLIB) $(GISLIB)
+DEPENDENCIES = $(MANAGEDEP) $(RASTERDEP) $(GISDEP)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make
 

Modified: grass/trunk/raster/r.reclass/reclass.c
===================================================================
--- grass/trunk/raster/r.reclass/reclass.c	2014-07-04 17:54:55 UTC (rev 61158)
+++ grass/trunk/raster/r.reclass/reclass.c	2014-07-07 00:45:08 UTC (rev 61159)
@@ -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 @@
 	_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);
 



More information about the grass-commit mailing list