[GRASS-SVN] r51070 - grass/trunk/lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 16 06:20:06 EDT 2012
Author: martinl
Date: 2012-03-16 03:20:06 -0700 (Fri, 16 Mar 2012)
New Revision: 51070
Modified:
grass/trunk/lib/vector/Vlib/header.c
Log:
vlib: Vect_get_finfo_geometry_type() - return lowercase (same for OGR and PostGIS links)
Modified: grass/trunk/lib/vector/Vlib/header.c
===================================================================
--- grass/trunk/lib/vector/Vlib/header.c 2012-03-16 10:18:20 UTC (rev 51069)
+++ grass/trunk/lib/vector/Vlib/header.c 2012-03-16 10:20:06 UTC (rev 51070)
@@ -362,13 +362,20 @@
/*!
\brief Get geometry type (relevant only for non-native formats)
+ Note: All inner spaces are removed, function returns feature type in
+ lowercase.
+
\param Map pointer to Map_info structure
\return allocated string containing geometry type info
+ (point, linestring, polygon, ...)
\return NULL on error (map format is native)
*/
const char *Vect_get_finfo_geometry_type(const struct Map_info *Map)
{
+ char *ftype, *ftype_tmp;
+
+ ftype_tmp = ftype = NULL;
if (Map->format == GV_FORMAT_OGR ||
Map->format == GV_FORMAT_OGR_DIRECT) {
#ifndef HAVE_OGR
@@ -383,14 +390,14 @@
Ogr_feature_defn = OGR_L_GetLayerDefn(Map->fInfo.ogr.layer);
Ogr_geom_type = wkbFlatten(OGR_FD_GetGeomType(Ogr_feature_defn));
- return OGRGeometryTypeToName(Ogr_geom_type);
+ ftype_tmp = G_store(OGRGeometryTypeToName(Ogr_geom_type));
#endif
}
else if (Map->format == GV_FORMAT_POSTGIS) {
#ifndef HAVE_POSTGRES
G_warning(_("GRASS is not compiled with PostgreSQL support"));
#else
- char stmt[DB_SQL_MAX], *ftype;
+ char stmt[DB_SQL_MAX];
const struct Format_info_pg *pg_info;
@@ -407,14 +414,19 @@
G_warning("%s\n%s", _("Unable to get feature type."),
PQresultErrorMessage(res));
- ftype = G_store(PQgetvalue(res, 0, 0));
+ ftype_tmp = G_store(PQgetvalue(res, 0, 0));
PQclear(res);
-
- return ftype;
#endif
}
- return NULL;
+ if (!ftype_tmp)
+ return NULL;
+
+ ftype = G_str_replace(ftype_tmp, " ", "");
+ G_free(ftype_tmp);
+ G_str_to_lower(ftype);
+
+ return ftype;
}
/*!
More information about the grass-commit
mailing list