Преглед на файлове

add capabilities to add columns and values in the input vector file

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66326 15284696-431f-4ddb-bdfa-cd5b030d7da7
Luca Delucchi преди 9 години
родител
ревизия
322e58c06c
променени са 1 файла, в които са добавени 18 реда и са изтрити 1 реда
  1. 18 1
      scripts/v.what.strds/v.what.strds.py

+ 18 - 1
scripts/v.what.strds/v.what.strds.py

@@ -32,6 +32,7 @@
 #%end
 
 #%option G_OPT_V_OUTPUT
+#% required: no
 #%end
 
 #%option G_OPT_DB_WHERE
@@ -41,6 +42,12 @@
 #% key: t_where
 #%end
 
+#%flag
+#% key: u
+#% label: Update input vector
+#% description: Instead create a new vector update the input vector with the values
+#%end
+
 import grass.script as grass
 import grass.temporal as tgis
 from grass.pygrass.utils import copy as gcopy
@@ -87,6 +94,13 @@ def main():
     where = options["where"]
     tempwhere = options["t_where"]
 
+    if output and flags['u']:
+        grass.fatal(_("Cannot combine 'output' option and 'u' flag"))
+    elif not output and not flags['u']:
+        grass.fatal(_("'output' option or 'u' flag must be given"))
+    elif not output and flags['u']:
+        grass.warning(_("Vector {name} will be update...").format(name=input))
+
     if where == "" or where == " " or where == "\n":
         where = None
 
@@ -172,7 +186,10 @@ def main():
                 samples.append(s)
 
     # Get the layer and database connections of the input vector
-    gcopy(input, output, 'vect')
+    if output:
+        gcopy(input, output, 'vect')
+    else:
+        output = input
 
     msgr = Messenger()
     perc_curr = 0