|
@@ -33,6 +33,7 @@
|
|
|
#%end
|
|
|
|
|
|
#%option G_OPT_V_OUTPUT
|
|
|
+#% required: no
|
|
|
#%end
|
|
|
|
|
|
#%option G_OPT_DB_WHERE
|
|
@@ -42,6 +43,12 @@
|
|
|
#% key: t_where
|
|
|
#%end
|
|
|
|
|
|
+#%flag
|
|
|
+#% key: u
|
|
|
+#% label: Update attribute table of input vector map
|
|
|
+#% description: Instead of creating a new vector map update the attribute table with value(s)
|
|
|
+#%end
|
|
|
+
|
|
|
import grass.script as grass
|
|
|
import grass.temporal as tgis
|
|
|
from grass.pygrass.utils import copy as gcopy
|
|
@@ -88,6 +95,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(_("Attribute table of vector {name} will be updated...").format(name=input))
|
|
|
+
|
|
|
if where == "" or where == " " or where == "\n":
|
|
|
where = None
|
|
|
|
|
@@ -173,7 +187,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, 'vector')
|
|
|
+ else:
|
|
|
+ output = input
|
|
|
|
|
|
msgr = Messenger()
|
|
|
perc_curr = 0
|