[GRASS-SVN] r69816 - in grass/branches/releasebranch_7_2/raster: r.info r.support
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Nov 13 15:24:40 PST 2016
Author: annakrat
Date: 2016-11-13 15:24:40 -0800 (Sun, 13 Nov 2016)
New Revision: 69816
Modified:
grass/branches/releasebranch_7_2/raster/r.info/main.c
grass/branches/releasebranch_7_2/raster/r.support/main.c
Log:
r.support/r.info: set the right title and show it properly, see #3035 (merge from trunk, r68746-8, r69645)
Modified: grass/branches/releasebranch_7_2/raster/r.info/main.c
===================================================================
--- grass/branches/releasebranch_7_2/raster/r.info/main.c 2016-11-13 23:15:06 UTC (rev 69815)
+++ grass/branches/releasebranch_7_2/raster/r.info/main.c 2016-11-13 23:24:40 UTC (rev 69816)
@@ -40,6 +40,7 @@
int main(int argc, char **argv)
{
const char *name, *mapset;
+ const char *title;
char tmp1[100], tmp2[100], tmp3[100];
char timebuff[256];
char *units, *vdatum;
@@ -128,6 +129,21 @@
out = stdout;
+ if (eflag->answer || (!gflag->answer && !rflag->answer && !hflag->answer)) {
+ title = "";
+ /* empty title by default */
+ /* use title from category file as the primary (and only) title */
+ if (cats_ok)
+ title = cats.title;
+ /* only use hist file title if there is none in the category file */
+ if ((!title || title[0] == '\0') && hist_ok) {
+ title = Rast_get_history(&hist, HIST_TITLE);
+ /* if the title is the same as name of the map, don't use it */
+ if (strcmp(title, name) == 0)
+ title = "";
+ }
+ }
+
if (!gflag->answer && !rflag->answer &&
!eflag->answer && !hflag->answer) {
divider('+');
@@ -138,9 +154,7 @@
mapset, hist_ok ? Rast_get_history(&hist, HIST_CREATOR) : "??");
compose_line(out, "Location: %s", G_location());
compose_line(out, "DataBase: %s", G_gisdbase());
- compose_line(out, "Title: %s ( %s )",
- cats_ok ? cats.title : "??",
- hist_ok ? Rast_get_history(&hist, HIST_TITLE) : "??");
+ compose_line(out, "Title: %s", title);
/* This shows the TimeStamp */
if (time_ok && (first_time_ok || second_time_ok)) {
@@ -368,8 +382,7 @@
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, "title=\"%s\"\n", title);
if (time_ok && (first_time_ok || second_time_ok)) {
G_format_timestamp(&ts, timebuff);
Modified: grass/branches/releasebranch_7_2/raster/r.support/main.c
===================================================================
--- grass/branches/releasebranch_7_2/raster/r.support/main.c 2016-11-13 23:15:06 UTC (rev 69815)
+++ grass/branches/releasebranch_7_2/raster/r.support/main.c 2016-11-13 23:24:40 UTC (rev 69816)
@@ -45,7 +45,6 @@
struct Flag *stats_flag, *null_flag, *del_flag;
int is_reclass; /* Is raster reclass? */
const char *infile;
- char title[MAX_TITLE_LEN + 1];
struct History hist;
/* Initialize GIS engine */
@@ -151,13 +150,8 @@
is_reclass = (Rast_is_reclass(raster->answer, "", rname, rmapset) > 0);
if (title_opt->answer) {
- strncpy(title, title_opt->answer, MAX_TITLE_LEN);
- title[MAX_TITLE_LEN - 1] = '\0'; /* strncpy doesn't null terminate oversized input */
- G_strip(title);
- G_debug(3, "map title= [%s] (%li chars)", title, strlen(title));
- Rast_read_history(raster->answer, "", &hist);
- Rast_set_history(&hist, HIST_TITLE, title);
- Rast_write_history(raster->answer, &hist);
+ Rast_put_cell_title(raster->answer, title_opt->answer);
+ G_debug(3, "map title= [%s] (%li chars)", title_opt->answer, strlen(title_opt->answer));
}
if (save_opt->answer) {
More information about the grass-commit
mailing list