[GRASS-SVN] r56372 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Thu May 23 01:50:43 PDT 2013


Author: martinl
Date: 2013-05-23 01:50:41 -0700 (Thu, 23 May 2013)
New Revision: 56372

Modified:
   grass/trunk/lib/vector/Vlib/header_finfo.c
Log:
vlib(pg): Vect_get_finfo_geometry_type() reports 3D for coord_dimension == 3


Modified: grass/trunk/lib/vector/Vlib/header_finfo.c
===================================================================
--- grass/trunk/lib/vector/Vlib/header_finfo.c	2013-05-23 08:49:30 UTC (rev 56371)
+++ grass/trunk/lib/vector/Vlib/header_finfo.c	2013-05-23 08:50:41 UTC (rev 56372)
@@ -16,6 +16,8 @@
    \author Update to GRASS 7 (OGR/PostGIS support) by Martin Landa <landa.martin gmail.com>
 */
 
+#include <string.h>
+
 #include <grass/vector.h>
 #include <grass/glocale.h>
 
@@ -141,6 +143,7 @@
 */
 const char *Vect_get_finfo_geometry_type(const struct Map_info *Map)
 {
+    int dim;
     char *ftype, *ftype_tmp;
     
     ftype_tmp = ftype = NULL;
@@ -155,6 +158,8 @@
     if (!Map->fInfo.ogr.layer)
         return NULL;
 
+    dim = -1;
+    
     Ogr_feature_defn = OGR_L_GetLayerDefn(Map->fInfo.ogr.layer);
     Ogr_geom_type = wkbFlatten(OGR_FD_GetGeomType(Ogr_feature_defn));
     
@@ -172,7 +177,7 @@
         PGresult *res;
                 
         pg_info = &(Map->fInfo.pg);
-        sprintf(stmt, "SELECT type FROM geometry_columns "
+        sprintf(stmt, "SELECT type,coord_dimension FROM geometry_columns "
                 "WHERE f_table_schema = '%s' AND f_table_name = '%s'",
                 pg_info->schema_name, pg_info->table_name);
         G_debug(2, "SQL: %s", stmt);
@@ -185,6 +190,8 @@
             return NULL;
         }
         ftype_tmp = G_store(PQgetvalue(res, 0, 0));
+        dim = atoi(PQgetvalue(res, 0, 1));
+
         PQclear(res);
 #endif
     }
@@ -194,8 +201,16 @@
 
     ftype = G_str_replace(ftype_tmp, " ", "");
     G_free(ftype_tmp);
+    ftype_tmp = NULL;
     G_str_to_lower(ftype);
 
+    if (dim == 3) {
+        ftype_tmp = (char *) G_malloc(3 + strlen(ftype) + 1);
+        sprintf(ftype_tmp, "3D %s", ftype);
+        G_free(ftype);
+        ftype = ftype_tmp;
+    }
+
     return ftype;
 }
 



More information about the grass-commit mailing list