浏览代码

v.select: Avoid database warnings when no features are selected and copy an
empty table


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@70582 15284696-431f-4ddb-bdfa-cd5b030d7da7

Huidae Cho 8 年之前
父节点
当前提交
71fc283ba8
共有 2 个文件被更改,包括 12 次插入7 次删除
  1. 11 6
      vector/v.select/copy_tabs.c
  2. 1 1
      vector/v.select/main.c

+ 11 - 6
vector/v.select/copy_tabs.c

@@ -55,12 +55,17 @@ void copy_tabs(struct Map_info *In, struct Map_info *Out,
 	OFi =
 	    Vect_default_field_info(Out, IFi->number, IFi->name, ttype);
 	
-	ret =
-	    db_copy_table_by_ints(IFi->driver, IFi->database, IFi->table,
-				  OFi->driver,
-				  Vect_subst_var(OFi->database, Out),
-				  OFi->table, IFi->key, cats[i],
-				  ncats[i]);
+	if (ncats[i] > 0)
+	    ret = db_copy_table_by_ints(IFi->driver, IFi->database, IFi->table,
+					OFi->driver,
+					Vect_subst_var(OFi->database, Out),
+					OFi->table, IFi->key, cats[i],
+					ncats[i]);
+	else
+	    ret = db_copy_table_where(IFi->driver, IFi->database, IFi->table,
+				      OFi->driver,
+				      Vect_subst_var(OFi->database, Out),
+				      OFi->table, "0 = 1");
 	
 	if (ret == DB_FAILED) {
 	    G_warning(_("Unable to copy table for layer %d"), fields[i]);

+ 1 - 1
vector/v.select/main.c

@@ -7,7 +7,7 @@
  *               Markus Neteler <neteler itc.it>
  *               Martin Landa <landa.martin gmail.com> (GEOS support)
  * PURPOSE:      Select features from one map by features in another map.
- * COPYRIGHT:    (C) 2003-2014 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2003-2017 by the GRASS Development Team
  *
  *               This program is free software under the GNU General
  *               Public License (>=v2). Read the file COPYING that