[GRASS-SVN] r62298 - in grass/branches/releasebranch_7_0/raster: r.in.bin r.out.bin

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Oct 19 15:34:35 PDT 2014


Author: neteler
Date: 2014-10-19 15:34:35 -0700 (Sun, 19 Oct 2014)
New Revision: 62298

Modified:
   grass/branches/releasebranch_7_0/raster/r.in.bin/main.c
   grass/branches/releasebranch_7_0/raster/r.out.bin/main.c
Log:
r.in.bin, r.out.bin: sync to trunk (error msg, explicit support for null=nan

Modified: grass/branches/releasebranch_7_0/raster/r.in.bin/main.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.in.bin/main.c	2014-10-19 22:15:39 UTC (rev 62297)
+++ grass/branches/releasebranch_7_0/raster/r.in.bin/main.c	2014-10-19 22:34:35 UTC (rev 62298)
@@ -228,7 +228,7 @@
     const char *outpre;
     char output[GNAME_MAX];
     const char *title;
-    double null_val = 0;
+    double null_val = 0.0/0.0;
     int is_fp;
     int is_signed;
     int bytes, hbytes;
@@ -425,7 +425,8 @@
 
     if (flag.swap->answer) {
 	if (strcmp(parm.order->answer, "native") != 0)
-	    G_fatal_error(_("order= and -b are mutually exclusive"));
+	    G_fatal_error(_("-%c and %s= are mutually exclusive"),
+			    flag.swap->key, parm.order->key);
 	order = G_is_little_endian() ? 0 : 1;
     }
 
@@ -460,11 +461,13 @@
 	bytes = atoi(parm.bytes->answer);
 
     if (flag.float_in->answer && flag.double_in->answer)
-	G_fatal_error(_("-f and -d are mutually exclusive"));
+	G_fatal_error(_("-%c and -%c are mutually exclusive"),
+			flag.float_in->key, flag.double_in->key);
 
     if (flag.float_in->answer) {
 	if (bytes && bytes < 4)
-	    G_fatal_error(_("-f incompatible with bytes=%d; must be 4 or 8"), bytes);
+	    G_fatal_error(_("-%c incompatible with %s=%d; must be 4 or 8"),
+			    flag.float_in->key, parm.bytes->key, bytes);
 	if (!bytes)
 	    bytes = 4;
 	is_fp = 1;
@@ -472,24 +475,26 @@
 
     if (flag.double_in->answer) {
 	if (bytes && bytes != 8)
-	    G_fatal_error(_("-d incompatible with bytes=%d; must be 8"), bytes);
+	    G_fatal_error(_("-%c incompatible with %s=%d; must be 8"),
+			    flag.double_in->key, parm.bytes->key, bytes);
 	if (!bytes)
 	    bytes = 8;
 	is_fp = 1;
     }
 
     if (!is_fp && !bytes)
-	G_fatal_error(_("bytes= required for integer data"));
+	G_fatal_error(_("%s= required for integer data"), parm.bytes->key);
 
 #ifndef HAVE_LONG_LONG_INT
     if (!is_fp && bytes > 4)
-	G_fatal_error(_("Integer input doesn't support size=8 in this build"));
+	G_fatal_error(_("Integer input doesn't support %s=8 in this build"),
+			parm.bytes->key);
 #endif
 
     if (bytes != 1 && bytes != 2 && bytes != 4 && bytes != 8)
-	G_fatal_error(_("bytes= must be 1, 2, 4 or 8"));
+	G_fatal_error(_("%s= must be 1, 2, 4 or 8"), parm.bytes->key);
 
-    if (parm.null->answer)
+    if (parm.null->answer && G_strcasecmp(parm.null->answer, "nan") != 0)
 	null_val = atof(parm.null->answer);
 
     cellhd.zone = G_zone();
@@ -500,12 +505,15 @@
 	int num_bounds;
 
 	if (!parm.rows->answer || !parm.cols->answer)
-	    G_fatal_error(_("Either -h or rows= and cols= must be given"));
+	    G_fatal_error(_("Either -%c or %s= and %s= must be given"),
+			    flag.gmt_hd->key, parm.rows->key, parm.cols->key);
 
 	num_bounds = !!parm.north->answer + !!parm.south->answer +
 	    !!parm.east->answer + !!parm.west->answer;
 	if (num_bounds != 0 && num_bounds != 4)
-	    G_fatal_error(_("Either all or none of north=, south=, east= and west= must be given"));
+	    G_fatal_error(_("Either all or none of %s=, %s=, %s= and %s= must be given"),
+			    parm.north->key, parm.south->key,
+			    parm.east->key, parm.west->key);
 
 	cellhd.rows = atoi(parm.rows->answer);
 	cellhd.cols = atoi(parm.cols->answer);
@@ -547,8 +555,8 @@
 	G_warning(
 	    _("East-West (ewres: %f) and North-South (nwres: %f) "
 	      "resolution differ significantly. "
-	      "Did you assign east= and west= correctly?"),
-	    cellhd.ew_res, cellhd.ns_res);
+	      "Did you assign %s= and %s= correctly?"),
+	    cellhd.ew_res, cellhd.ns_res, parm.east->key, parm.west->key);
 
     grass_nrows = nrows = cellhd.rows;
     grass_ncols = ncols = cellhd.cols;

Modified: grass/branches/releasebranch_7_0/raster/r.out.bin/main.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.out.bin/main.c	2014-10-19 22:15:39 UTC (rev 62297)
+++ grass/branches/releasebranch_7_0/raster/r.out.bin/main.c	2014-10-19 22:34:35 UTC (rev 62298)
@@ -341,7 +341,9 @@
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
-    if (sscanf(parm.null->answer, "%lf", &null_val) != 1)
+    if (G_strcasecmp(parm.null->answer, "nan") == 0)
+	Rast_set_d_null_value(&null_val, 1);
+    else if (sscanf(parm.null->answer, "%lf", &null_val) != 1)
 	G_fatal_error(_("Invalid value for null (integers only)"));
 
     name = parm.input->answer;
@@ -364,7 +366,8 @@
 
     if (flag.swap->answer) {
 	if (strcmp(parm.order->answer, "native") != 0)
-	    G_fatal_error(_("order= and -s are mutually exclusive"));
+	    G_fatal_error(_("-%c and %s= are mutually exclusive"),
+			    flag.swap->key, parm.order->key);
 	order = G_is_little_endian() ? 0 : 1;
     }
 
@@ -373,7 +376,8 @@
     do_stdout = strcmp("-", outfile) == 0;
 
     if (flag.int_out->answer && flag.float_out->answer)
-	G_fatal_error(_("-i and -f are mutually exclusive"));
+	G_fatal_error(_("-%c and -%c are mutually exclusive"),
+			flag.int_out->key, flag.float_out->key);
 
     fd = Rast_open_old(name, "");
 
@@ -392,11 +396,13 @@
 	bytes = 2;
 
     if (is_fp && bytes < 4)
-	G_fatal_error(_("Floating-point output requires bytes=4 or bytes=8"));
+	G_fatal_error(_("Floating-point output requires %s=4 or %s=8"),
+			parm.bytes->key, parm.bytes->key);
 
 #ifndef HAVE_LONG_LONG_INT
     if (!is_fp && bytes > 4)
-	G_fatal_error(_("Integer output doesn't support bytes=8 in this build"));
+	G_fatal_error(_("Integer output doesn't support %s=8 in this build"),
+			parm.bytes->key);
 #endif
 
     G_get_window(&region);
@@ -433,12 +439,14 @@
     out_buf = G_malloc(ncols * bytes);
 
     if (is_fp) {
-	G_message(_("Exporting raster as floating values (bytes=%d)"), bytes);
+	G_message(_("Exporting raster as floating values (%s=%d)"),
+			parm.bytes->key, bytes);
 	if (flag.gmt_hd->answer)
 	    G_message(_("Writing GMT float format ID=1"));
     }
     else {
-	G_message(_("Exporting raster as integer values (bytes=%d)"), bytes);
+	G_message(_("Exporting raster as integer values (%s=%d)"),
+			parm.bytes->key, bytes);
 	if (flag.gmt_hd->answer)
 	    G_message(_("Writing GMT integer format ID=2"));
     }



More information about the grass-commit mailing list