[GRASS-SVN] r52884 - grass/branches/releasebranch_6_4/display/d.what.rast

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Aug 25 03:37:58 PDT 2012


Author: mmetz
Date: 2012-08-25 03:37:57 -0700 (Sat, 25 Aug 2012)
New Revision: 52884

Modified:
   grass/branches/releasebranch_6_4/display/d.what.rast/local_proto.h
   grass/branches/releasebranch_6_4/display/d.what.rast/main.c
   grass/branches/releasebranch_6_4/display/d.what.rast/show.c
   grass/branches/releasebranch_6_4/display/d.what.rast/what.c
Log:
hamish: export floats and doubles with correct precision (#335)

Modified: grass/branches/releasebranch_6_4/display/d.what.rast/local_proto.h
===================================================================
--- grass/branches/releasebranch_6_4/display/d.what.rast/local_proto.h	2012-08-25 10:29:49 UTC (rev 52883)
+++ grass/branches/releasebranch_6_4/display/d.what.rast/local_proto.h	2012-08-25 10:37:57 UTC (rev 52884)
@@ -4,7 +4,8 @@
 /* show.c */
 int show_cat(int, int, char *, char *, int, char *, int, char *,
 	     RASTER_MAP_TYPE);
-int show_dval(int, int, char *, char *, DCELL, char *, int, char *);
+int show_dval(int, int, char *, char *, DCELL, char *, int, char *,
+	     RASTER_MAP_TYPE);
 int show_utm(char *, char *, double, double, struct Cell_head *, int, int,
 	     int, char *);
 int show_buttons(int);

Modified: grass/branches/releasebranch_6_4/display/d.what.rast/main.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.what.rast/main.c	2012-08-25 10:29:49 UTC (rev 52883)
+++ grass/branches/releasebranch_6_4/display/d.what.rast/main.c	2012-08-25 10:37:57 UTC (rev 52884)
@@ -136,6 +136,7 @@
     if (D_do_conversions(&window, t, b, l, r))
 	G_fatal_error(_("Error in calculating conversions"));
 
+    width = mwidth = 0;
     if (rast) {
 	for (i = 0; rast[i]; i++) ;
 	nrasts = i;
@@ -146,7 +147,6 @@
 	cats =
 	    (struct Categories *)G_malloc(nrasts * sizeof(struct Categories));
 
-	width = mwidth = 0;
 	for (i = 0; i < nrasts; i++) {
 	    name[i] = (char *)G_malloc(GNAME_MAX);
 	    mapset[i] = (char *)G_malloc(GMAPSET_MAX);

Modified: grass/branches/releasebranch_6_4/display/d.what.rast/show.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.what.rast/show.c	2012-08-25 10:29:49 UTC (rev 52883)
+++ grass/branches/releasebranch_6_4/display/d.what.rast/show.c	2012-08-25 10:37:57 UTC (rev 52884)
@@ -55,7 +55,7 @@
 
 int show_dval(int width, int mwidth,
 	      char *name, char *mapset, DCELL dval, char *label,
-	      int terse, char *fs)
+	      int terse, char *fs, RASTER_MAP_TYPE map_type)
 {
     DCELL dcell_val;
     char *fname;
@@ -71,10 +71,10 @@
 	}
 	else {
 	    if (!isatty(fileno(stdout)))
-		fprintf(stdout, "%s, actual %s%f%s%s\n", fname, fs, dval, fs,
-			label);
-	    fprintf(stderr, "%s, actual %s%f%s%s\n", fname, fs, dval, fs,
-		    label);
+		fprintf(stdout, "%s, actual %s%.*g%s%s\n", fname, fs,
+			map_type == FCELL_TYPE ? 7 : 15, dval, fs, label);
+	    fprintf(stderr, "%s, actual %s%.*g%s%s\n", fname, fs,
+		    map_type == FCELL_TYPE ? 7 : 15, dval, fs, label);
 	}
     }
     else {
@@ -87,10 +87,12 @@
 	}
 	else {
 	    if (!isatty(fileno(stdout)))
-		fprintf(stdout, "%*s in %-*s, actual  (%f)%s\n", width, name,
-			mwidth, mapset, dval, label);
-	    fprintf(stderr, "%*s in %-*s, actual  (%f)%s\n", width, name,
-		    mwidth, mapset, dval, label);
+		fprintf(stdout, "%*s in %-*s, actual  (%.*g)%s\n", width, name,
+			mwidth, mapset, map_type == FCELL_TYPE ? 7 : 15,
+			dval, label);
+	    fprintf(stderr, "%*s in %-*s, actual  (%.*g)%s\n", width, name,
+		    mwidth, mapset, map_type == FCELL_TYPE ? 7 : 15, dval,
+		    label);
 	}
     }
     nlines += 1;

Modified: grass/branches/releasebranch_6_4/display/d.what.rast/what.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.what.rast/what.c	2012-08-25 10:29:49 UTC (rev 52883)
+++ grass/branches/releasebranch_6_4/display/d.what.rast/what.c	2012-08-25 10:37:57 UTC (rev 52884)
@@ -77,11 +77,12 @@
 
 	    if (G_get_d_raster_row(fd[i], dbuf, row) < 0)
 		show_dval(width, mwidth, name[i], mapset[i], null_dcell,
-			  "ERROR reading fcell file", terse, fs);
+			  "ERROR reading fcell file", terse, fs,
+			  map_type[i]);
 	    else
 		show_dval(width, mwidth, name[i], mapset[i], dbuf[col],
 			  G_get_d_raster_cat(&dbuf[col], &cats[i]), terse,
-			  fs);
+			  fs, map_type[i]);
 	}
     }
     while (!once);



More information about the grass-commit mailing list