Jelajahi Sumber

g.version: new flag for printing libraries info (GDAL, PROJ and GEOS)
manual updated


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53672 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 12 tahun lalu
induk
melakukan
99ac3cab98
2 mengubah file dengan 103 tambahan dan 26 penghapusan
  1. 45 24
      general/g.version/g.version.html
  2. 58 2
      general/g.version/main.c

+ 45 - 24
general/g.version/g.version.html

@@ -1,7 +1,8 @@
 <h2>DESCRIPTION</h2>
 <h2>DESCRIPTION</h2>
 
 
 <em>g.version</em> prints to standard output the GRASS version number,
 <em>g.version</em> prints to standard output the GRASS version number,
-date, the GRASS copyright and GRASS build information.
+date, the GRASS copyright (<b>-c</b> flag), and GRASS build information
+(<b>-b</b> flag).
 
 
 <h2>NOTES</h2>
 <h2>NOTES</h2>
 
 
@@ -9,47 +10,67 @@ This program requires no command line arguments; the user simply types
 <em>g.version</em> on the command line to see the version number and
 <em>g.version</em> on the command line to see the version number and
 date of the GRASS software currently being run by the user.
 date of the GRASS software currently being run by the user.
 
 
+<p>
+Information about GRASS
+core <a href="http://grass.osgeo.org/programming7/gislib.html">GIS
+Library</a> can be printed by <b>-r</b> flag.
+
+<p>
+Version numbers of additional libraries
+like <a href="http://trac.osgeo.org/proj/">PROJ.4</a>, <a href="http://gdal.org/">GDAL/OGR</a>
+or <a href="http://trac.osgeo.org/geos">GEOS</a> are printed
+by <b>-e</b> flag.
+
+<p>
+See also function <tt>version()</tt>
+from <a href="http://grass.osgeo.org/wiki/GRASS_Python_Scripting_Library">Python
+Scripting Library</a>.
+
+<div class="code"><pre>
+import grass.script as grass
+
+print grass.version()
+</div>
+
 <h2>EXAMPLES</h2>
 <h2>EXAMPLES</h2>
 
 
+<h3>Basic info</h3>
 <div class="code"><pre>
 <div class="code"><pre>
 g.version 
 g.version 
 
 
-GRASS 7.0.svn45136 (2011)
+GRASS 7.0.svn (2012)
 </pre></div>
 </pre></div>
 
 
+<h3>GIS Library info</h3>
+
 <div class="code"><pre>
 <div class="code"><pre>
 g.version -r
 g.version -r
 
 
-GRASS 7.0.svn45136 (2011)
-Revision: 45093 
-Date: 2011-01-20 13:10:50 +0100 (Thu, 20 Jan 2011)
+GRASS 7.0.svn (2012)
+libgis Revision: 52468 
+libgis Date: 2012-07-27 22:53:30 +0200 (Fri, 27 Jul 2012) 
 </pre></div>
 </pre></div>
 
 
+<h3>Full info in shell script style</h3>
 <div class="code"><pre>
 <div class="code"><pre>
-g.version -rg
+g.version -rge
 
 
 version=7.0.svn
 version=7.0.svn
-revision=45136
-date=2011
-gis_revision=Revision: 45093 
-gis_date=Date: 2011-01-20 13:10:50 +0100 (Thu, 20 Jan 2011) 
+revision=53670
+date=2012
+libgis_revision=52468 
+libgis_date="2012-07-27 22:53:30 +0200 (Fri, 27 Jul 2012) "
+proj4=4.8.0
+gdal=1.9.2
+geos=3.3.5
 </pre></div>
 </pre></div>
 
 
-<h2>PYTHON</h2>
-
-See <em><a href="http://grass.osgeo.org/programming7/pythonlib.html">Python
-Scripting Library</a></em> for more info.
-
-<div class="code"><pre>
-import grass.script as grass
-
-grass.version()
-</div>
-
-<h2>AUTHOR</h2>
+<h2>AUTHORS</h2>
 
 
 Michael Shapiro, 
 Michael Shapiro, 
 U.S. Army Construction Engineering 
 U.S. Army Construction Engineering 
-Research Laboratory
+Research Laboratory<br>
+Extended info by Martin Landa, Czech Technical University in Prague, Czech Republic
 
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>

+ 58 - 2
general/g.version/main.c

@@ -5,9 +5,10 @@
 * AUTHOR(S):	Michael Shapiro, CERL
 * AUTHOR(S):	Michael Shapiro, CERL
 *               Andreas Lange - <andreas.lange rhein-main.de>
 *               Andreas Lange - <andreas.lange rhein-main.de>
 *  	    	Justin Hickey - Thailand - jhickey hpcc.nectec.or.th
 *  	    	Justin Hickey - Thailand - jhickey hpcc.nectec.or.th
+*               Extended info by Martin Landa <landa.martin gmail.com>
 * PURPOSE: 	Output GRASS version number, date and copyright message.
 * PURPOSE: 	Output GRASS version number, date and copyright message.
 *             
 *             
-* COPYRIGHT:  	(C) 2000-2011 by the GRASS Development Team
+* COPYRIGHT:  	(C) 2000-2012 by the GRASS Development Team
 *
 *
 *   	    	This program is free software under the GPL (>=v2)
 *   	    	This program is free software under the GPL (>=v2)
 *   	    	Read the file COPYING that comes with GRASS for details.
 *   	    	Read the file COPYING that comes with GRASS for details.
@@ -20,6 +21,16 @@
 #include <grass/gis.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
 #include <grass/glocale.h>
 
 
+#include <proj_api.h>
+
+#ifdef HAVE_GDAL
+#include <gdal_version.h>
+#endif
+
+#ifdef HAVE_GEOS
+#include <geos_c.h>
+#endif
+
 #ifndef GRASS_VERSION_UPDATE_PKG
 #ifndef GRASS_VERSION_UPDATE_PKG
 #define GRASS_VERSION_UPDATE_PKG "0.1"
 #define GRASS_VERSION_UPDATE_PKG "0.1"
 #endif
 #endif
@@ -35,7 +46,7 @@ static const char GRASS_CONFIGURE_PARAMS[] =
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
     struct GModule *module;
     struct GModule *module;
-    struct Flag *copyright, *build, *gish_rev, *shell;
+    struct Flag *copyright, *build, *gish_rev, *shell, *extended;
 
 
     G_gisinit(argv[0]);
     G_gisinit(argv[0]);
 
 
@@ -60,6 +71,12 @@ int main(int argc, char *argv[])
 	_("Print also the GIS library revision number and time");
 	_("Print also the GIS library revision number and time");
     gish_rev->guisection = _("Additional info");
     gish_rev->guisection = _("Additional info");
 
 
+    extended = G_define_flag();
+    extended->key = 'e';
+    extended->label = _("Print also extended info for additional libraries");
+    extended->description = _("GDAL/OGR, PROJ.4, GEOS");
+    extended->guisection = _("Additional info");
+
     shell = G_define_flag();
     shell = G_define_flag();
     shell->key = 'g';
     shell->key = 'g';
     shell->description = _("Print info in shell script style (including SVN revision number)");
     shell->description = _("Print info in shell script style (including SVN revision number)");
@@ -104,5 +121,44 @@ int main(int argc, char *argv[])
 	G_free_tokens(rev_time);
 	G_free_tokens(rev_time);
     }
     }
 
 
+    if (extended->answer) {
+        char *proj = NULL;
+        G_asprintf(&proj, "%d", PJ_VERSION);
+        if (strlen(proj) == 3) {
+            if (shell->answer)
+                fprintf(stdout, "proj4=%c.%c.%c\n", proj[0], proj[1], proj[2]); 
+            else
+                fprintf(stdout, "PROJ.4: %c.%c.%c\n", proj[0], proj[1], proj[2]); 
+        }
+        else {
+            if (shell->answer)
+                fprintf(stdout, "proj4=%s\n", proj);
+            else
+                fprintf(stdout, "PROJ.4: %s\n", proj);
+        }
+#ifdef HAVE_GDAL
+        if (shell->answer)
+            fprintf(stdout, "gdal=%s\n", GDAL_RELEASE_NAME);
+        else
+            fprintf(stdout, "GDAL/OGR: %s\n", GDAL_RELEASE_NAME);
+#else
+        if (shell->answer)
+            fprintf(stdout, "gdal=\n");
+        else
+            fprintf(stdout, "%s\n", _("GRASS not compiled with GDAL/OGR support"));
+#endif
+#ifdef HAVE_GEOS
+        if (shell->answer)
+            fprintf(stdout, "geos=%s\n", GEOS_VERSION);
+        else
+            fprintf(stdout, "GEOS: %s\n", GEOS_VERSION);
+#else
+        if (shell->answer)
+            fprintf(stdout, "geos=\n");
+        else
+            fprintf(stdout, "%s\n", _("GRASS not compiled with GEOS support"));
+#endif
+    }
+    
     return (EXIT_SUCCESS);
     return (EXIT_SUCCESS);
 }
 }