[GRASS-SVN] r63608 - grass/trunk/vector/v.external

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Dec 19 02:23:48 PST 2014


Author: martinl
Date: 2014-12-19 02:23:48 -0800 (Fri, 19 Dec 2014)
New Revision: 63608

Modified:
   grass/trunk/vector/v.external/args.c
   grass/trunk/vector/v.external/list.c
Log:
v.external: -t print also geometry column (useful when layer has multiple geometries)


Modified: grass/trunk/vector/v.external/args.c
===================================================================
--- grass/trunk/vector/v.external/args.c	2014-12-19 09:31:33 UTC (rev 63607)
+++ grass/trunk/vector/v.external/args.c	2014-12-19 10:23:48 UTC (rev 63608)
@@ -51,7 +51,7 @@
     flags->tlist->key = 't';
     flags->tlist->label = _("List available layers including feature type "
 			    "in data source and exit");
-    flags->tlist->description = _("Format: layer name,type,projection check");
+    flags->tlist->description = _("Format: layer name,type,projection check,geometry");
     flags->tlist->guisection = _("Print");
     flags->tlist->suppress_required = YES;
 

Modified: grass/trunk/vector/v.external/list.c
===================================================================
--- grass/trunk/vector/v.external/list.c	2014-12-19 09:31:33 UTC (rev 63607)
+++ grass/trunk/vector/v.external/list.c	2014-12-19 10:23:48 UTC (rev 63608)
@@ -283,9 +283,10 @@
 
 	if (fd) {
 	    if (print_types) {
-		int proj_same;
+                int proj_same, igeom;
 		OGRSpatialReferenceH Ogr_projection;
-
+                OGRGeomFieldDefnH Ogr_geomdefn;
+                
 		/* projection check */
 		Ogr_projection = OGR_L_GetSpatialRef(Ogr_layer);
 		proj_same = 0;
@@ -304,9 +305,18 @@
 			proj_same = 0;
 		}
 		G_suppress_warnings(FALSE);
-		fprintf(fd, "%s,%s,%d\n", layer_name,
-			feature_type(OGRGeometryTypeToName(Ogr_geom_type)),
-			proj_same);
+
+                for (igeom = 0; igeom < OGR_FD_GetGeomFieldCount(Ogr_featuredefn); igeom++) {
+                    Ogr_geomdefn = OGR_FD_GetGeomFieldDefn(Ogr_featuredefn, igeom);
+                    if (!Ogr_geomdefn) {
+                        G_warning(_("Invalid geometry column %d"), igeom);
+                        continue;
+                    }
+                    
+                    fprintf(fd, "%s,%s,%d,%s\n", layer_name,
+                            feature_type(OGRGeometryTypeToName(Ogr_geom_type)),
+                            proj_same, OGR_GFld_GetNameRef(Ogr_geomdefn));
+                }
 	    }
 	    else {
 		fprintf(fd, "%s\n", layer_name);



More information about the grass-commit mailing list