瀏覽代碼

v.rast.stats: check for existence of attribute table before launching v.to.rast

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@72865 15284696-431f-4ddb-bdfa-cd5b030d7da7
Moritz Lennert 6 年之前
父節點
當前提交
7338981293
共有 1 個文件被更改,包括 9 次插入9 次删除
  1. 9 9
      scripts/v.rast.stats/v.rast.stats.py

+ 9 - 9
scripts/v.rast.stats/v.rast.stats.py

@@ -119,6 +119,15 @@ def main():
     if vect_mapset != mapset or not grass.find_file(vector, 'vector', mapset)['file']:
         grass.fatal(_("Vector map <%s> not found in current mapset") % vector)
 
+    # check if DBF driver used, in this case cut to 10 chars col names:
+    try:
+        fi = grass.vector_db(map=vector)[int(layer)]
+    except KeyError:
+        grass.fatal(
+            _('There is no table connected to this map. Run v.db.connect or v.db.addtable first.'))
+    # we need this for non-DBF driver:
+    dbfdriver = fi['driver'] == 'dbf'
+
     vector = vs[0]
 
     rastertmp = "%s_%s" % (vector, tmpname)
@@ -159,15 +168,6 @@ def main():
     if number < 1:
         grass.fatal(_("No categories found in raster map"))
 
-    # check if DBF driver used, in this case cut to 10 chars col names:
-    try:
-        fi = grass.vector_db(map=vector)[int(layer)]
-    except KeyError:
-        grass.fatal(
-            _('There is no table connected to this map. Run v.db.connect or v.db.addtable first.'))
-    # we need this for non-DBF driver:
-    dbfdriver = fi['driver'] == 'dbf'
-
     # Find out which table is linked to the vector map on the given layer
     if not fi['table']:
         grass.fatal(