[GRASS-SVN] r61025 - grass/branches/releasebranch_7_0/raster/r.info
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jun 28 06:39:45 PDT 2014
Author: martinl
Date: 2014-06-28 06:39:45 -0700 (Sat, 28 Jun 2014)
New Revision: 61025
Modified:
grass/branches/releasebranch_7_0/raster/r.info/main.c
Log:
r.info: print all information in shell script style
(merge r60776 from trunk)
Modified: grass/branches/releasebranch_7_0/raster/r.info/main.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.info/main.c 2014-06-28 13:24:01 UTC (rev 61024)
+++ grass/branches/releasebranch_7_0/raster/r.info/main.c 2014-06-28 13:39:45 UTC (rev 61025)
@@ -77,15 +77,15 @@
gflag = G_define_flag();
gflag->key = 'g';
- gflag->description = _("Print raster array information only");
+ gflag->description = _("Print raster array information in shell script style");
rflag = G_define_flag();
rflag->key = 'r';
- rflag->description = _("Print range only");
+ rflag->description = _("Print range in shell script style");
eflag = G_define_flag();
eflag->key = 'e';
- eflag->description = _("Print extended metadata information only");
+ eflag->description = _("Print extended metadata information in shell script style");
hflag = G_define_flag();
hflag->key = 'h';
@@ -94,6 +94,9 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ if (hflag->answer && (gflag->answer || rflag->answer || eflag->answer))
+ G_fatal_error(_("Flags -%c and -%c/%c/%c are mutually exclusive"),
+ hflag->key, gflag->key, rflag->key, eflag->key);
name = G_store(opt1->answer);
if ((mapset = G_find_raster2(name, "")) == NULL)
@@ -129,7 +132,7 @@
!eflag->answer && !hflag->answer) {
divider('+');
- compose_line(out, "Layer: %-29.29s Date: %s", name,
+ compose_line(out, "Map: %-29.29s Date: %s", name,
hist_ok ? Rast_get_history(&hist, HIST_MAPID) : "??");
compose_line(out, "Mapset: %-29.29s Login of Creator: %s",
mapset, hist_ok ? Rast_get_history(&hist, HIST_CREATOR) : "??");
@@ -139,7 +142,7 @@
cats_ok ? cats.title : "??",
hist_ok ? Rast_get_history(&hist, HIST_TITLE) : "??");
- /*This shows the TimeStamp */
+ /* This shows the TimeStamp */
if (time_ok && (first_time_ok || second_time_ok)) {
G_format_timestamp(&ts, timebuff);
compose_line(out, "Timestamp: %s", timebuff);
@@ -328,6 +331,10 @@
(data_type == CELL_TYPE ? "CELL" :
(data_type == DCELL_TYPE ? "DCELL" :
(data_type == FCELL_TYPE ? "FCELL" : "??"))));
+ if (cats_ok)
+ format_double((double)cats.num, tmp1);
+ fprintf(out, "ncats=%s\n",
+ cats_ok ? tmp1 : "??");
}
if (rflag->answer) {
@@ -352,15 +359,14 @@
}
if (eflag->answer) {
+ fprintf(out, "map=%s\n", name);
+ fprintf(out, "mapset=%s\n", mapset);
+ fprintf(out, "location=%s\n", G_location());
+ fprintf(out, "database=%s\n", G_gisdbase());
+ fprintf(out, "date=\"%s\"\n", hist_ok ? Rast_get_history(&hist, HIST_MAPID) : "??");
+ fprintf(out, "creator=\"%s\"\n", hist_ok ? Rast_get_history(&hist, HIST_CREATOR) : "??");
fprintf(out, "title=\"%s (%s)\"\n", cats_ok ? cats.title :
"??", hist_ok ? Rast_get_history(&hist, HIST_TITLE) : "??");
-
- fprintf(out, "units=%s\n", units ? units : "\"none\"");
- fprintf(out, "vertical_datum=%s\n", vdatum ? vdatum : "\"none\"");
- fprintf(out, "source1=\"%s\"\n", hist_ok ? Rast_get_history(&hist, HIST_DATSRC_1) : "\"none\"");
- fprintf(out, "source2=\"%s\"\n", hist_ok ? Rast_get_history(&hist, HIST_DATSRC_2) : "\"none\"");
- fprintf(out, "description=\"%s\"\n", hist_ok ? Rast_get_history(&hist, HIST_KEYWRD) : "\"none\"");
-
if (time_ok && (first_time_ok || second_time_ok)) {
G_format_timestamp(&ts, timebuff);
@@ -372,6 +378,17 @@
else {
fprintf(out, "timestamp=\"none\"\n");
}
+ fprintf(out, "units=%s\n", units ? units : "\"none\"");
+ fprintf(out, "vdatum=%s\n", vdatum ? vdatum : "\"none\"");
+ fprintf(out, "source1=\"%s\"\n", hist_ok ? Rast_get_history(&hist, HIST_DATSRC_1) : "\"none\"");
+ fprintf(out, "source2=\"%s\"\n", hist_ok ? Rast_get_history(&hist, HIST_DATSRC_2) : "\"none\"");
+ fprintf(out, "description=\"%s\"\n", hist_ok ? Rast_get_history(&hist, HIST_KEYWRD) : "\"none\"");
+ if (Rast_history_length(&hist)) {
+ fprintf(out, "comments=\"");
+ for (i = 0; i < Rast_history_length(&hist); i++)
+ fprintf(out, "%s", Rast_history_line(&hist, i));
+ fprintf(out, "\"\n");
+ }
}
if (hflag->answer) {
More information about the grass-commit
mailing list