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

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Nov 25 11:53:58 PST 2013


Author: martinl
Date: 2013-11-25 11:53:58 -0800 (Mon, 25 Nov 2013)
New Revision: 58306

Modified:
   grass/trunk/include/defs/vector.h
   grass/trunk/include/vect/dig_defines.h
   grass/trunk/lib/vector/Vlib/header_finfo.c
Log:
vlib: Vect_get_finfo_topology_info() added


Modified: grass/trunk/include/defs/vector.h
===================================================================
--- grass/trunk/include/defs/vector.h	2013-11-25 19:50:46 UTC (rev 58305)
+++ grass/trunk/include/defs/vector.h	2013-11-25 19:53:58 UTC (rev 58306)
@@ -170,6 +170,7 @@
 const char *Vect_get_finfo_format_info(const struct Map_info *);
 const char *Vect_get_finfo_geometry_type(const struct Map_info *);
 const struct Format_info *Vect_get_finfo(const struct Map_info *);
+int Vect_get_finfo_topology_info(const struct Map_info *, char **, char **, int*);
 int Vect_is_3d(const struct Map_info *);
 int Vect_set_organization(struct Map_info *, const char *);
 const char *Vect_get_organization(const struct Map_info *);

Modified: grass/trunk/include/vect/dig_defines.h
===================================================================
--- grass/trunk/include/vect/dig_defines.h	2013-11-25 19:50:46 UTC (rev 58305)
+++ grass/trunk/include/vect/dig_defines.h	2013-11-25 19:53:58 UTC (rev 58306)
@@ -88,6 +88,13 @@
 /*! \brief PostGIS format */
 #define GV_FORMAT_POSTGIS          3
 
+/*! \brief GRASS topology - native format */
+#define GV_TOPO_NATIVE             0
+/*! \brief Pseudo-topology - external simple features (OGR/PostGIS) format */
+#define GV_TOPO_PSEUDO             1
+/*! \brief PostGIS topology - external PostGIS format */
+#define GV_TOPO_POSTGIS            2
+
 /*! \brief One table linked to vector map */
 #define GV_1TABLE  0
 /*! \brief More tables linked to vector map */

Modified: grass/trunk/lib/vector/Vlib/header_finfo.c
===================================================================
--- grass/trunk/lib/vector/Vlib/header_finfo.c	2013-11-25 19:50:46 UTC (rev 58305)
+++ grass/trunk/lib/vector/Vlib/header_finfo.c	2013-11-25 19:53:58 UTC (rev 58306)
@@ -6,7 +6,7 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2010, 2012 by the GRASS Development Team
+   (C) 2001-2013 by the GRASS Development Team
 
    This program is free software under the GNU General Public License
    (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -97,7 +97,7 @@
 }
 
 /*!
-  \brief Get format info (relevant only for non-native formats)
+  \brief Get format info as string (relevant only for non-native formats)
 
   \param Map pointer to Map_info structure
   
@@ -130,7 +130,7 @@
 }
 
 /*!
-  \brief Get geometry type (relevant only for non-native formats)
+  \brief Get geometry type as string (relevant only for non-native formats)
 
   Note: All inner spaces are removed, function returns feature type in
   lowercase.
@@ -232,3 +232,49 @@
 
     return NULL;
 }
+
+/*!
+  \brief Get topology type (relevant only for non-native formats)
+
+  \param Map pointer to Map_info structure
+  \param[out] toposchema Topology schema name or NULL
+  \param[out] topogeom   TopoGeometry column name or NULL
+  \param[out] topo_geo_only TRUE for Topo-Geo data model or NULL
+
+  \return GV_TOPO_NATIVE for native format
+  \return GV_TOPO_PSEUDO for pseudo-topology
+  \return GV_TOPO_POSTGIS for PostGIS Topology
+*/
+int Vect_get_finfo_topology_info(const struct Map_info *Map,
+                                 char **toposchema, char **topogeom, int* topo_geo_only)
+{
+    if (Map->format == GV_FORMAT_OGR ||
+        Map->format == GV_FORMAT_OGR_DIRECT) {
+#ifndef HAVE_OGR
+        G_warning(_("GRASS is not compiled with OGR support"));
+#else
+        return GV_TOPO_PSEUDO;
+#endif
+    }
+    
+    if (Map->format == GV_FORMAT_POSTGIS) {
+        const struct Format_info_pg *pg_info;
+
+        pg_info = &(Map->fInfo.pg);
+        if (pg_info->toposchema_name) {
+            if (toposchema)
+                *toposchema = G_store(pg_info->toposchema_name);
+            if (topogeom)
+                *topogeom = G_store(pg_info->topogeom_column);
+            if (topo_geo_only)
+                *topo_geo_only = pg_info->topo_geo_only;
+            
+            return GV_TOPO_POSTGIS;
+        }
+        else {
+            return GV_TOPO_PSEUDO;
+        }
+    }
+
+    return GV_TOPO_NATIVE;
+}



More information about the grass-commit mailing list