Kaynağa Gözat

Check datatype of input map - translated from shell.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@46379 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anne Ghisla 14 yıl önce
ebeveyn
işleme
cd8c31a54e
1 değiştirilmiş dosya ile 10 ekleme ve 0 silme
  1. 10 0
      scripts/r.mask/r.mask.py

+ 10 - 0
scripts/r.mask/r.mask.py

@@ -68,6 +68,16 @@ def main():
     if not grass.find_file(input)['file'] and not remove:
         grass.fatal(_("<%s> does not exist.") % input)
 
+    if not 'MASKCATS' in grass.gisenv() and not remove:
+        ## beware: next check is made with != , not with 'is', otherwise:
+        #>>> grass.raster_info("basin_50K")['datatype'] is "CELL"
+        #False
+        # even if:
+        #>>> "CELL" is "CELL"
+        #True 
+        if grass.raster_info(input)['datatype'] != "CELL":
+            grass.fatal(_("Raster map %s must be integer for maskcats parameter") % input)
+
     mapset = grass.gisenv()['MAPSET']
     exists = bool(grass.find_file('MASK', element = 'cell', mapset = mapset)['file'])