소스 검색

export floats and doubles with correct precision (https://trac.osgeo.org/grass/ticket/335, merge from devbr6)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@52196 15284696-431f-4ddb-bdfa-cd5b030d7da7
Hamish Bowman 13 년 전
부모
커밋
c6c94e04c0
6개의 변경된 파일22개의 추가작업 그리고 16개의 파일을 삭제
  1. 2 2
      display/d.what.rast/Makefile
  2. 2 1
      display/d.what.rast/local_proto.h
  3. 3 2
      display/d.what.rast/main.c
  4. 1 0
      display/d.what.rast/opencell.c
  5. 13 10
      display/d.what.rast/show.c
  6. 1 1
      display/d.what.rast/what.c

+ 2 - 2
display/d.what.rast/Makefile

@@ -3,9 +3,9 @@ MODULE_TOPDIR = ../..
 
 PGM = d.what.rast
 
-LIBES        = $(DISPLAYLIB) $(GISLIB)
+LIBES        = $(DISPLAYLIB) $(RASTERLIB) $(GISLIB)
 
-DEPENDENCIES = $(DISPLAYDEP) $(GISDEP)
+DEPENDENCIES = $(DISPLAYDEP) $(RASTERDEP) $(GISDEP)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make
 

+ 2 - 1
display/d.what.rast/local_proto.h

@@ -4,7 +4,8 @@ int opencell(char *, char *, char *);
 /* 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);

+ 3 - 2
display/d.what.rast/main.c

@@ -23,6 +23,7 @@
 #include <string.h>
 #include "what.h"
 #include <grass/display.h>
+#include <grass/raster.h>
 #include <grass/glocale.h>
 #include "local_proto.h"
 
@@ -94,7 +95,7 @@ int main(int argc, char **argv)
     if (opt1->answers && opt1->answers[0])
 	rast = opt1->answers;
 
-    if (R_open_driver() != 0)
+    if (D_open_driver() != 0)
 	G_fatal_error(_("No graphics device selected"));
 
     D_setup(0);
@@ -133,6 +134,6 @@ int main(int argc, char **argv)
     what(once->answer, terse->answer, colrow->answer, fs->answer, width,
 	 mwidth);
 
-    R_close_driver();
+    D_close_driver();
     exit(EXIT_SUCCESS);
 }

+ 1 - 0
display/d.what.rast/opencell.c

@@ -1,5 +1,6 @@
 #include <string.h>
 #include <grass/gis.h>
+#include <grass/raster.h>
 #include <grass/glocale.h>
 
 int opencell(char *fullname, char *name, char *mapset)

+ 13 - 10
display/d.what.rast/show.c

@@ -1,6 +1,7 @@
-#include <grass/gis.h>
 #include <unistd.h>
 #include <string.h>
+#include <grass/gis.h>
+#include <grass/raster.h>
 
 static int nlines = 100;
 
@@ -55,7 +56,7 @@ int show_cat(int width, int mwidth,
 
 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 +72,10 @@ int show_dval(int width, int mwidth,
 	}
 	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 +88,12 @@ int show_dval(int width, int mwidth,
 	}
 	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;

+ 1 - 1
display/d.what.rast/what.c

@@ -75,7 +75,7 @@ int what(int once, int terse, int colrow, char *fs, int width, int mwidth)
 
 	    show_dval(width, mwidth, name[i], mapset[i], dbuf[col],
 		      Rast_get_d_cat(&dbuf[col], &cats[i]), terse,
-		      fs);
+		      fs, map_type[i]);
 	}
     }
     while (!once);