[GRASS-SVN] r53836 - in grass/trunk/raster3d: r3.in.bin r3.in.bin/test_suite r3.out.bin

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 15 05:18:06 PST 2012


Author: huhabla
Date: 2012-11-15 05:18:05 -0800 (Thu, 15 Nov 2012)
New Revision: 53836

Modified:
   grass/trunk/raster3d/r3.in.bin/main.c
   grass/trunk/raster3d/r3.in.bin/r3.in.bin.html
   grass/trunk/raster3d/r3.in.bin/test_suite/test.r3.in.bin.sh
   grass/trunk/raster3d/r3.out.bin/main.c
   grass/trunk/raster3d/r3.out.bin/r3.out.bin.html
Log:
Fixed tests, removed swap flag


Modified: grass/trunk/raster3d/r3.in.bin/main.c
===================================================================
--- grass/trunk/raster3d/r3.in.bin/main.c	2012-11-15 12:54:20 UTC (rev 53835)
+++ grass/trunk/raster3d/r3.in.bin/main.c	2012-11-15 13:18:05 UTC (rev 53836)
@@ -222,7 +222,6 @@
 	struct {
 		struct Flag *integer_in;
 		struct Flag *sign;
-		struct Flag *swap;
 		struct Flag *depth;
 		struct Flag *row;
 	} flag;
@@ -366,11 +365,6 @@
 	flag.sign->description = _("Signed data (two's complement)");
 	flag.sign->guisection = _("Settings");
 
-	flag.swap = G_define_flag();
-	flag.swap->key = 'b';
-	flag.swap->description = _("Byte Swap the Data During Import");
-	flag.swap->guisection = _("Settings");
-
 	if (G_parser(argc, argv))
 		exit(EXIT_FAILURE);
 
@@ -386,12 +380,6 @@
 	else if (G_strcasecmp(parm.order->answer, "swap") == 0)
 		order = G_is_little_endian() ? 0 : 1;
 
-	if (flag.swap->answer) {
-		if (strcmp(parm.order->answer, "native") != 0)
-			G_fatal_error(_("order= and -b are mutually exclusive"));
-		order = G_is_little_endian() ? 0 : 1;
-	}
-
 	byte_swap = order == (G_is_little_endian() ? 0 : 1);
 
 	is_signed = !!flag.sign->answer;

Modified: grass/trunk/raster3d/r3.in.bin/r3.in.bin.html
===================================================================
--- grass/trunk/raster3d/r3.in.bin/r3.in.bin.html	2012-11-15 12:54:20 UTC (rev 53835)
+++ grass/trunk/raster3d/r3.in.bin/r3.in.bin.html	2012-11-15 13:18:05 UTC (rev 53836)
@@ -1,7 +1,7 @@
 <h2>DESCRIPTION</h2>
 
 <em>r3.in.bin</em> allows a user to create a GRASS 3D raster map 
-from a variety of binary 3D raster data formats. 
+from a variety of binary 3D raster data formats.
 
 <p>The top, bottom, north, south, east, and west field values entered 
 are the coordinates of the edges of the geographic region. 
@@ -10,6 +10,36 @@
 If the bytes field is entered incorrectly an error will be generated
 suggesting a closer bytes value. 
 
+<h2>NOTES</h2>
+
+The write order of the rows (north->south to south->north) and 
+the write order of the depths (bottom->top to top->bottom) can be switched.
+<p>
+Have a look at <a href="r3.out.ascii.html">r3.out.ascii</a> to manual page that 
+describes the internal layout of the 3D raster maps and the supported
+row and depth switch options.
+<p>
+Import of little and big endian byte order as well as signed and
+unsigned integer data types is supported. 
+
+<h2>Example</h2>
+
+First we create a specific region and a 3D raster map that we will export with
+<a href="r3.out.bin.html">r3.out.bin</a> and import again.
+
+<div class="code"><pre>
+g.region w=0 e=180 s=0 n=90 b=0 t=100 res3=10
+r3.mapcalc expr="test_out_bin_float = float(if(row() == 2, null(), row()))"
+
+r3.out.bin input=test_out_bin_float byte=4 null=-9999 \
+    output=test_out_bin_float_native_b4.bin order=native
+
+r3.in.bin output=test_in_bin_float byte=4 null=-9999 \
+    input=test_out_bin_float_native_b4.bin order=native \
+    bottom=0 top=100 west=0 east=180 south=0 north=90 \
+    cols=18 rows=9 depths=10
+</pre></div>
+
 <h2>SEE ALSO</h2>
 
 <em>

Modified: grass/trunk/raster3d/r3.in.bin/test_suite/test.r3.in.bin.sh
===================================================================
--- grass/trunk/raster3d/r3.in.bin/test_suite/test.r3.in.bin.sh	2012-11-15 12:54:20 UTC (rev 53835)
+++ grass/trunk/raster3d/r3.in.bin/test_suite/test.r3.in.bin.sh	2012-11-15 13:18:05 UTC (rev 53836)
@@ -15,9 +15,6 @@
 r3.out.bin --o input=test_out_bin_float byte=8 null=-9999 \
     output=test_out_bin_float_native_b8.bin order=native
 
-r3.out.bin --o -s input=test_out_bin_float byte=4 null=-9999 \
-    output=test_out_bin_float_native_s_b4.bin order=native
-
 r3.out.bin --o -r input=test_out_bin_float byte=4 null=-9999 \
     output=test_out_bin_float_native_r_b4.bin order=native
 
@@ -32,21 +29,25 @@
 r3.out.bin --o input=test_out_bin_float byte=4 null=-9999 \
     output=test_out_bin_float_little_b4.bin order=little
 
+#r3.out.bin --o input=test_out_bin_float byte=4 null=-9999 \
+#    output=test_out_bin_float_big_b4.bin order=big
+
 r3.out.bin --o input=test_out_bin_float byte=4 null=-9999 \
-    output=test_out_bin_float_big_b4.bin order=big
+    output=test_out_bin_float_swap_b4.bin order=swap
 
+    
 # Write float map as integer array
 
-r3.out.bin --o -i input=test_out_bin_float byte=1 null=-9999 \
+r3.out.bin --o -i input=test_out_bin_float byte=1 null=0 \
     output=test_out_bin_float_native_b1_as_integer.bin order=native
 
-r3.out.bin --o -i input=test_out_bin_float byte=2 null=-9999 \
+r3.out.bin --o -i input=test_out_bin_float byte=2 null=0 \
     output=test_out_bin_float_native_b2_as_integer.bin order=native
 
-r3.out.bin --o -i input=test_out_bin_float byte=4 null=-9999 \
+r3.out.bin --o -i input=test_out_bin_float byte=4 null=0 \
     output=test_out_bin_float_native_b4_as_integer.bin order=native
 
-r3.out.bin --o -i input=test_out_bin_float byte=8 null=-9999 \
+r3.out.bin --o -i input=test_out_bin_float byte=8 null=0 \
     output=test_out_bin_float_native_b8_as_integer.bin order=native
 
 # Double precision
@@ -69,11 +70,6 @@
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     cols=18 rows=9 depths=10
 
-#r3.in.bin --o output=test_in_bin_float_3 byte=4 null=-9999 \
-#    input=test_out_bin_float_native_s_b4.bin order=native \
-#    bottom=0 top=100 west=0 east=180 south=0 north=90 \
-#    cols=18 rows=9 depths=10 -s
-
 r3.in.bin --o output=test_in_bin_float_4 byte=4 null=-9999 \
     input=test_out_bin_float_native_d_b4.bin order=native \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
@@ -89,27 +85,45 @@
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     cols=18 rows=9 depths=10 -rd
 
-r3.in.bin --o output=test_in_bin_float_7 byte=1 null=-9999 \
+# Integer binary file import
+
+r3.in.bin --o output=test_in_bin_float_7 byte=1 null=0 \
     input=test_out_bin_float_native_b1_as_integer.bin order=native \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     cols=18 rows=9 depths=10 -i
 
-r3.in.bin --o output=test_in_bin_float_8 byte=2 null=-9999 \
+r3.in.bin --o output=test_in_bin_float_8 byte=2 null=0 \
     input=test_out_bin_float_native_b2_as_integer.bin order=native \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     cols=18 rows=9 depths=10 -i
 
-r3.in.bin --o output=test_in_bin_float_9 byte=4 null=-9999 \
+r3.in.bin --o output=test_in_bin_float_9 byte=4 null=0 \
     input=test_out_bin_float_native_b4_as_integer.bin order=native \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     cols=18 rows=9 depths=10 -i
 
-r3.in.bin --o output=test_in_bin_float_10 byte=8 null=-9999 \
+r3.in.bin --o output=test_in_bin_float_10 byte=8 null=0 \
     input=test_out_bin_float_native_b8_as_integer.bin order=native \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     cols=18 rows=9 depths=10 -i
+    
+# Test little and big endian
 
+r3.in.bin --o output=test_in_bin_float_11 byte=4 null=-9999 \
+    input=test_out_bin_float_little_b4.bin order=little \
+    bottom=0 top=100 west=0 east=180 south=0 north=90 \
+    cols=18 rows=9 depths=10
 
+#r3.in.bin --o output=test_in_bin_float_12 byte=4 null=-9999 \
+#    input=test_out_bin_float_big_b4.bin order=big \
+#    bottom=0 top=100 west=0 east=180 south=0 north=90 \
+#    cols=18 rows=9 depths=10
+
+r3.in.bin --o output=test_in_bin_float_13 byte=4 null=-9999 \
+    input=test_out_bin_float_swap_b4.bin order=swap \
+    bottom=0 top=100 west=0 east=180 south=0 north=90 \
+    cols=18 rows=9 depths=10
+
 for map in `g.mlist type=rast3d pattern=test_in_bin_float*` ; do
   r3.out.ascii input=${map} output=${map}.txt dp=0
 done

Modified: grass/trunk/raster3d/r3.out.bin/main.c
===================================================================
--- grass/trunk/raster3d/r3.out.bin/main.c	2012-11-15 12:54:20 UTC (rev 53835)
+++ grass/trunk/raster3d/r3.out.bin/main.c	2012-11-15 13:18:05 UTC (rev 53836)
@@ -185,7 +185,7 @@
 		struct Option *bytes;
 	} parm;
 	struct {
-		struct Flag *swap, *row, *depth, *integer;
+		struct Flag *row, *depth, *integer;
 	} flag;
 	char *name;
 	char *outfile;
@@ -233,12 +233,8 @@
 	parm.order->required = NO;
 	parm.order->options = "big,little,native,swap";
 	parm.order->description = _("Output byte order");
-	parm.order->answer = "native";
+	parm.order->answer = "native";;
 
-	flag.swap = G_define_flag();
-	flag.swap->key = 's';
-	flag.swap->description = _("Byte swap output");
-
 	flag.row = G_define_flag();
 	flag.row->key = 'r';
 	flag.row->description = _("Switch the row order in output from "
@@ -293,12 +289,6 @@
 	else if (G_strcasecmp(parm.order->answer, "swap") == 0)
 		order = G_is_little_endian() ? 0 : 1;
 
-	if (flag.swap->answer) {
-		if (strcmp(parm.order->answer, "native") != 0)
-			G_fatal_error(_("order= and -s are mutually exclusive"));
-		order = G_is_little_endian() ? 0 : 1;
-	}
-
 	swap_flag = order == (G_is_little_endian() ? 0 : 1);
 
 	do_stdout = strcmp("-", outfile) == 0;

Modified: grass/trunk/raster3d/r3.out.bin/r3.out.bin.html
===================================================================
--- grass/trunk/raster3d/r3.out.bin/r3.out.bin.html	2012-11-15 12:54:20 UTC (rev 53835)
+++ grass/trunk/raster3d/r3.out.bin/r3.out.bin.html	2012-11-15 13:18:05 UTC (rev 53836)
@@ -1,7 +1,7 @@
 <h2>DESCRIPTION</h2>
 
 The <em>r3.out.bin</em> program exports a GRASS 3D raster map to a binary array
-file. Optionally, output can be sent to standard output (stdout) for direct
+file. Optionally, output can be send to standard output (stdout) for direct
 input (pipe) into other applications. Data is exported according to the
 original GRASS 3D raster type (float, double). 
 
@@ -12,11 +12,23 @@
 <p>
 The region parameters are printed to stderr when setting the verbose flag.
 Export of little and big endian byte order is supported.
+<p>
+Have a look at <a href="r3.out.ascii.html">r3.out.ascii</a> to manual page that 
+describes the internal layout of the 3D raster maps and the supported
+row and depth switch options. 
 
+<h2>Examples</h2>
+
+Have a look at the examples in <a href="r3.in.bin.html">r3.in.bin</a>.
+
+
 <h2>SEE ALSO</h2>
 
-<em><a href="r.out.bin.html">r.out.bin</a>,
-<a href="r3.out.ascii.html">r3.out.bin</a></em>
+<em>
+<a href="r3.in.bin.html">r3.in.bin</a>,
+<a href="r3.out.ascii.html">r3.out.bin</a>,
+<a href="r3.in.ascii.html">r3.in.bin</a>
+</em>
 
 
 <h2>AUTHOR</h2>



More information about the grass-commit mailing list