[GRASS-SVN] r39532 - in grass/trunk: include lib/vector/Vlib
vector/v.info
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Oct 16 14:56:20 EDT 2009
Author: martinl
Date: 2009-10-16 14:56:18 -0400 (Fri, 16 Oct 2009)
New Revision: 39532
Modified:
grass/trunk/include/vector.h
grass/trunk/lib/vector/Vlib/header.c
grass/trunk/vector/v.info/print.c
Log:
* print more useful info about OGR layers in v.info
* Vect_get_ogr_format_info(), Vect_get_ogr_dns_name() and
Vect_get_ogr_layer_name() added
Modified: grass/trunk/include/vector.h
===================================================================
--- grass/trunk/include/vector.h 2009-10-16 18:08:47 UTC (rev 39531)
+++ grass/trunk/include/vector.h 2009-10-16 18:56:18 UTC (rev 39532)
@@ -159,6 +159,9 @@
const char *Vect_get_name(const struct Map_info *);
const char *Vect_get_mapset(const struct Map_info *);
const char *Vect_get_full_name(const struct Map_info *);
+const char *Vect_get_ogr_dsn_name(const struct Map_info *);
+const char *Vect_get_ogr_layer_name(const struct Map_info *);
+const char *Vect_get_ogr_format_info(const struct Map_info *);
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/lib/vector/Vlib/header.c
===================================================================
--- grass/trunk/lib/vector/Vlib/header.c 2009-10-16 18:08:47 UTC (rev 39531)
+++ grass/trunk/lib/vector/Vlib/header.c 2009-10-16 18:56:18 UTC (rev 39532)
@@ -1,5 +1,5 @@
/*!
- \file header.c
+ \file lib/vector/Vlib/header.c
\brief Vector library - header manipulation
@@ -23,7 +23,6 @@
static int lookup(const char *file, const char *key, char *value, size_t len);
-
/*!
\brief Print vector map header
@@ -237,6 +236,49 @@
}
/*!
+ \brief Get OGR datasource name (relevant only for OGR format)
+
+ \param Map pointer to Map_info structure
+
+ \return poiter to string with OGR datasource name
+ */
+const char *Vect_get_ogr_dsn_name(const struct Map_info *Map)
+{
+ return (Map->fInfo.ogr.dsn);
+}
+
+/*!
+ \brief Get OGR layer name (relevant only for OGR format)
+
+ \param Map pointer to Map_info structure
+
+ \return poiter to string with OGR layer name
+ */
+const char *Vect_get_ogr_layer_name(const struct Map_info *Map)
+{
+ return (Map->fInfo.ogr.layer_name);
+}
+
+/*!
+ \brief Get OGR format info (relevant only for OGR format)
+
+ \param Map pointer to Map_info structure
+
+ \return poiter to string with OGR format info (allocated by G_store())
+ \return NULL on error
+*/
+const char *Vect_get_ogr_format_info(const struct Map_info *Map)
+{
+#ifdef HAVE_OGR
+ if (!Map->fInfo.ogr.ds)
+ return NULL;
+
+ return G_store(OGR_Dr_GetName(OGR_DS_GetDriver(Map->fInfo.ogr.ds)));
+#endif
+ return NULL;
+}
+
+/*!
\brief Check if vector map is 3D (with z)
\param Map vector map
Modified: grass/trunk/vector/v.info/print.c
===================================================================
--- grass/trunk/vector/v.info/print.c 2009-10-16 18:08:47 UTC (rev 39531)
+++ grass/trunk/vector/v.info/print.c 2009-10-16 18:56:18 UTC (rev 39532)
@@ -173,12 +173,23 @@
struct bound_box box;
divider('+');
- sprintf(line, "%-17s%s", _("Name:"),
- Vect_get_name(Map));
- printline(line);
- sprintf(line, "%-17s%s", _("Mapset:"),
- Vect_get_mapset(Map));
- printline(line);
+ if (Vect_maptype(Map) == GV_FORMAT_OGR) {
+ /* for OGR format print also datasource and layer */
+ sprintf(line, "%-17s%s", _("OGR layer:"),
+ Vect_get_ogr_layer_name(Map));
+ printline(line);
+ sprintf(line, "%-17s%s", _("OGR datasource:"),
+ Vect_get_ogr_dsn_name(Map));
+ printline(line);
+ }
+ else {
+ sprintf(line, "%-17s%s", _("Name:"),
+ Vect_get_name(Map));
+ printline(line);
+ sprintf(line, "%-17s%s", _("Mapset:"),
+ Vect_get_mapset(Map));
+ printline(line);
+ }
sprintf(line, "%-17s%s", _("Location:"),
G_location());
printline(line);
@@ -191,8 +202,14 @@
sprintf(line, "%-17s1:%d", _("Map scale:"),
Vect_get_scale(Map));
printline(line);
- sprintf(line, "%-17s%s", _("Map format:"),
- Vect_maptype_info(Map));
+ if (Vect_maptype(Map) == GV_FORMAT_OGR) {
+ sprintf(line, "%-17s%s (%s)", _("Map format:"),
+ Vect_maptype_info(Map), Vect_get_ogr_format_info(Map));
+ }
+ else {
+ sprintf(line, "%-17s%s", _("Map format:"),
+ Vect_maptype_info(Map));
+ }
printline(line);
sprintf(line, "%-17s%s", _("Name of creator:"),
Vect_get_person(Map));
More information about the grass-commit
mailing list