[GRASS-SVN] r51153 - in grass/trunk: include/defs lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 23 10:52:57 EDT 2012


Author: martinl
Date: 2012-03-23 07:52:57 -0700 (Fri, 23 Mar 2012)
New Revision: 51153

Modified:
   grass/trunk/include/defs/vector.h
   grass/trunk/lib/vector/Vlib/header.c
Log:
vlib: Vect_get_finfo_layer_name() return for pg links 'schema.table'


Modified: grass/trunk/include/defs/vector.h
===================================================================
--- grass/trunk/include/defs/vector.h	2012-03-23 14:43:48 UTC (rev 51152)
+++ grass/trunk/include/defs/vector.h	2012-03-23 14:52:57 UTC (rev 51153)
@@ -161,7 +161,7 @@
 const char *Vect_get_mapset(const struct Map_info *);
 const char *Vect_get_full_name(const struct Map_info *);
 const char *Vect_get_finfo_dsn_name(const struct Map_info *);
-const char *Vect_get_finfo_layer_name(const struct Map_info *);
+char *Vect_get_finfo_layer_name(const struct Map_info *);
 const char *Vect_get_finfo_format_info(const struct Map_info *);
 const char *Vect_get_finfo_geometry_type(const struct Map_info *);
 int Vect_is_3d(const struct Map_info *);

Modified: grass/trunk/lib/vector/Vlib/header.c
===================================================================
--- grass/trunk/lib/vector/Vlib/header.c	2012-03-23 14:43:48 UTC (rev 51152)
+++ grass/trunk/lib/vector/Vlib/header.c	2012-03-23 14:52:57 UTC (rev 51153)
@@ -291,31 +291,38 @@
     - layer name for OGR format (GV_FORMAT_OGR and GV_FORMAT_OGR_DIRECT)
     - table name for PostGIS format (GV_FORMAT_POSTGIS)
 
+   Note: allocated string should be freed by G_free()
+
    \param Map pointer to Map_info structure
 
    \return string containing layer name
    \return NULL on error (map format is native)
  */
-const char *Vect_get_finfo_layer_name(const struct Map_info *Map)
+char *Vect_get_finfo_layer_name(const struct Map_info *Map)
 {
+    char *name;
+    
+    name = NULL;
     if (Map->format == GV_FORMAT_OGR ||
 	Map->format == GV_FORMAT_OGR_DIRECT) {
 #ifndef HAVE_OGR
 	G_warning(_("GRASS is not compiled with OGR support"));
 #endif
-	return Map->fInfo.ogr.layer_name;
+	name = G_store(Map->fInfo.ogr.layer_name);
     }
     else if (Map->format == GV_FORMAT_POSTGIS) {
 #ifndef HAVE_POSTGRES
 	G_warning(_("GRASS is not compiled with PostgreSQL support"));
 #endif
-        return Map->fInfo.pg.table_name;
+	G_asprintf(&name, "%s.%s", Map->fInfo.pg.schema_name,
+		   Map->fInfo.pg.table_name);
     }
-
-    G_warning(_("Native vector format detected for <%s>"),
-	      Vect_get_full_name(Map));
+    else {
+	G_warning(_("Native vector format detected for <%s>"),
+		  Vect_get_full_name(Map));
+    }
     
-    return NULL;
+    return name;
 }
 
 /*!



More information about the grass-commit mailing list