[GRASS-SVN] r52195 - grass/branches/develbranch_6/display/d.what.rast

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jun 23 05:17:52 PDT 2012


Author: hamish
Date: 2012-06-23 05:17:50 -0700 (Sat, 23 Jun 2012)
New Revision: 52195

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

Modified: grass/branches/develbranch_6/display/d.what.rast/local_proto.h
===================================================================
--- grass/branches/develbranch_6/display/d.what.rast/local_proto.h	2012-06-23 11:56:13 UTC (rev 52194)
+++ grass/branches/develbranch_6/display/d.what.rast/local_proto.h	2012-06-23 12:17:50 UTC (rev 52195)
@@ -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/develbranch_6/display/d.what.rast/show.c
===================================================================
--- grass/branches/develbranch_6/display/d.what.rast/show.c	2012-06-23 11:56:13 UTC (rev 52194)
+++ grass/branches/develbranch_6/display/d.what.rast/show.c	2012-06-23 12:17:50 UTC (rev 52195)
@@ -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/develbranch_6/display/d.what.rast/what.c
===================================================================
--- grass/branches/develbranch_6/display/d.what.rast/what.c	2012-06-23 11:56:13 UTC (rev 52194)
+++ grass/branches/develbranch_6/display/d.what.rast/what.c	2012-06-23 12:17:50 UTC (rev 52195)
@@ -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