浏览代码

use the mapset's default DB instead of being locked to the one that layer 1 has used. (bug https://trac.osgeo.org/grass/ticket/809)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@40337 15284696-431f-4ddb-bdfa-cd5b030d7da7
Hamish Bowman 15 年之前
父节点
当前提交
91ac27c5b9
共有 2 个文件被更改,包括 8 次插入16 次删除
  1. 2 2
      scripts/v.db.addtable/v.db.addtable.html
  2. 6 14
      scripts/v.db.addtable/v.db.addtable.py

+ 2 - 2
scripts/v.db.addtable/v.db.addtable.html

@@ -18,8 +18,8 @@ and then use either a combinatino of <em>v.category</em> + <em>v.to.db</em> or
 <em><a href="wxGUI.Vector_Digitizing_Tool.html">wxGUI vector digitizer</a></em> to add the relevant lines to the table.
 
 The supported types of columns depend on the database backend. However, all
-backends should support VARCHAR, INT, DOUBLE PRECISION and DATE. The default
-dbf backend supports only these types.
+backends should support VARCHAR, INT, DOUBLE PRECISION and DATE.
+The dbf backend supports only these types.
 
 The existing database connection(s) can be verified with <em>v.db.connect</em>.
 

+ 6 - 14
scripts/v.db.addtable/v.db.addtable.py

@@ -15,7 +15,7 @@
 #############################################################################
 
 #%Module
-#%  description: Creates and adds a new attribute table to a given layer of an existing vector map.
+#%  description: Creates and connects a new attribute table to a given layer of an existing vector map.
 #%  keywords: vector
 #%  keywords: database
 #%  keywords: attribute table
@@ -83,21 +83,13 @@ def main():
     # check if DB parameters are set, and if not set them.
     grass.run_command('db.connect', flags = 'c')
 
-    #check if anything is connected:
-    nuldev = file(os.devnull, 'w')
-    db = grass.vector_db(map, stderr = nuldev)
-    if db:
-	f = db[min(db.keys())]
-	database = f['database']
-	driver = f['driver']
-    else:
-	# nothing defined
-	grass.message(_("Creating new DB connection based on default mapset settings..."))
-	kv = grass.db_connection()
-	database = kv['database']
-	driver = kv['driver']
+    grass.message(_("Creating new DB connection based on default mapset settings..."))
+    kv = grass.db_connection()
+    database = kv['database']
+    driver = kv['driver']
 
     # maybe there is already a table linked to the selected layer?
+    nuldev = file(os.devnull, 'w')
     try:
         grass.vector_db(map, stderr = nuldev)[int(layer)]
 	grass.fatal(_("There is already a table linked to layer <%s>") % layer)