[GRASS-SVN] r47920 - grass/trunk/vector/v.select

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 28 12:11:34 EDT 2011


Author: martinl
Date: 2011-08-28 09:11:34 -0700 (Sun, 28 Aug 2011)
New Revision: 47920

Modified:
   grass/trunk/vector/v.select/main.c
Log:
v.select: fix writting attributes for OGR output


Modified: grass/trunk/vector/v.select/main.c
===================================================================
--- grass/trunk/vector/v.select/main.c	2011-08-28 14:05:20 UTC (rev 47919)
+++ grass/trunk/vector/v.select/main.c	2011-08-28 16:11:34 UTC (rev 47920)
@@ -3,7 +3,8 @@
  *
  * MODULE:       v.select - select features from one map by features in another map.
  * AUTHOR(S):    Radim Blazek <radim.blazek gmail.com> (original contributor)
- *               Glynn Clements <glynn gclements.plus.com>, Markus Neteler <neteler itc.it>
+ *               Glynn Clements <glynn gclements.plus.com>
+ *               Markus Neteler <neteler itc.it>
  *               Martin Landa <landa.martin gmail.com> (GEOS support)
  * PURPOSE:      
  * COPYRIGHT:    (C) 2003-2011 by the GRASS Development Team
@@ -28,7 +29,7 @@
 {
     int i, iopt;
     int operator;
-    int aline, nalines, nskipped;
+    int aline, nalines, nskipped, is_ogr;
     int ltype, itype[2], ifield[2];
     int **cats, *ncats, nfields, *fields;
     struct GModule *module;
@@ -416,6 +417,18 @@
 #endif
 
     /* Write lines */
+    is_ogr = Vect_maptype(&Out) == GV_FORMAT_OGR_DIRECT;
+    if (!flag.table->answer && is_ogr) {
+	/* Copy attributes for OGR output */
+	struct field_info *Fi;
+	Fi = Vect_get_field2(&(In[0]), parm.field[0]->answer);
+	if (!Fi)
+	    G_fatal_error(_("Database connection not defined for layer <%s>"),
+			  parm.field[0]->answer);
+	Vect_map_add_dblink(&Out, Fi->number, Fi->name, Fi->table, Fi->key,
+			    Fi->database, Fi->driver);
+    }
+    
     nfields = Vect_cidx_get_num_fields(&(In[0]));
     cats = (int **)G_malloc(nfields * sizeof(int *));
     ncats = (int *)G_malloc(nfields * sizeof(int));
@@ -459,7 +472,7 @@
     }
 
     /* Copy tables */
-    if (!(flag.table->answer)) {
+    if (!flag.table->answer && !is_ogr) {
 	int ttype, ntabs = 0;
 
 	G_message(_("Writing attributes..."));



More information about the grass-commit mailing list