[GRASS-SVN] r38583 - grass/branches/releasebranch_6_4/vector/v.out.ogr

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 2 14:00:04 EDT 2009


Author: mmetz
Date: 2009-08-02 14:00:03 -0400 (Sun, 02 Aug 2009)
New Revision: 38583

Modified:
   grass/branches/releasebranch_6_4/vector/v.out.ogr/main.c
Log:
fix for #634

Modified: grass/branches/releasebranch_6_4/vector/v.out.ogr/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.out.ogr/main.c	2009-08-02 17:40:08 UTC (rev 38582)
+++ grass/branches/releasebranch_6_4/vector/v.out.ogr/main.c	2009-08-02 18:00:03 UTC (rev 38583)
@@ -171,8 +171,14 @@
     /* Check output type */
     otype = Vect_option_to_types(type_opt);
 
-    if (!layer_opt->answer)
-	layer_opt->answer = G_store(in_opt->answer);
+    if (!layer_opt->answer) {
+	char xname[GNAME_MAX],	xmapset[GMAPSET_MAX];
+	
+	if (G__name_is_fully_qualified(in_opt->answer, xname, xmapset))
+	    layer_opt->answer = G_store(xname);
+	else
+	    layer_opt->answer = G_store(in_opt->answer);
+    }
 
     if (otype & GV_POINTS)
 	wkbtype = wkbPoint;
@@ -259,7 +265,7 @@
 	i++;
     }
 
-    papszDSCO = dsco->answers;
+    G_debug(1, "Create OGR data source");
     Ogr_ds = OGR_Dr_CreateDataSource(Ogr_driver, dsn_opt->answer, papszDSCO);
     CSLDestroy(papszDSCO);
     if (Ogr_ds == NULL)
@@ -298,6 +304,7 @@
 	}
     }
 
+    G_debug(1, "Create OGR layer");
     Ogr_layer =
 	OGR_DS_CreateLayer(Ogr_ds, layer_opt->answer, Ogr_projection, wkbtype,
 			   papszLCO);
@@ -309,6 +316,7 @@
 
     /* Vector attributes -> OGR fields */
     if (field > 0) {
+	G_debug(1, "Create attribute table");
 	doatt = 1;		/* do attributes */
 	Fi = Vect_get_field(&In, field);
 	if (Fi == NULL) {
@@ -316,6 +324,7 @@
 
 	    Ogr_field = OGR_Fld_Create("cat", OFTInteger);
 	    OGR_L_CreateField(Ogr_layer, Ogr_field, 0);
+	    OGR_Fld_Destroy(Ogr_field);
 
 	    doatt = 0;
 	}
@@ -372,6 +381,7 @@
 		Ogr_field =
 		    OGR_Fld_Create(db_get_column_name(Column), ogr_ftype);
 		OGR_L_CreateField(Ogr_layer, Ogr_field, 0);
+		OGR_Fld_Destroy(Ogr_field);
 	    }
 	    if (keycol == -1)
 		G_fatal_error(_("Key column '%s' not found"), Fi->key);
@@ -604,6 +614,8 @@
 
 		OGR_G_AddGeometryDirectly(Ogr_geometry, ring);
 
+		OGR_F_SetGeometry(Ogr_feature, Ogr_geometry);
+
 		/* Output one feature for each category */
 		for (j = -1; j < Cats->n_cats; j++) {
 		    if (j == -1) {
@@ -621,8 +633,6 @@
 		    OGR_L_CreateFeature(Ogr_layer, Ogr_feature);
 		}
 
-		OGR_F_SetGeometry(Ogr_feature, Ogr_geometry);
-
 		OGR_G_DestroyGeometry(Ogr_geometry);
 	    }			/* if type & GV_FACE */
 



More information about the grass-commit mailing list