浏览代码

r.info: make category title the primary, use hist as fallback (see https://trac.osgeo.org/grass/ticket/3035)

This also makes the line shorter, so it more often fits
into the character limit and it does not contain the
stange parentheses (with spaces around them)
which were hard to interpret.

Follows https://trac.osgeo.org/grass/changeset/68746 and r68747.


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@68748 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 8 年之前
父节点
当前提交
fcba1db3e2
共有 1 个文件被更改,包括 15 次插入3 次删除
  1. 15 3
      raster/r.info/main.c

+ 15 - 3
raster/r.info/main.c

@@ -40,6 +40,7 @@ static void compose_line(FILE *, const char *, ...);
 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;
@@ -132,15 +133,26 @@ int main(int argc, char **argv)
 	!eflag->answer && !hflag->answer) {
 	divider('+');
 
+    /* empty title by default */
+    title = "";
+    /* 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 = "";
+    }
+
 	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) : "??");
 	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)) {