Sfoglia il codice sorgente

Fixed tests, removed swap flag

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53836 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 12 anni fa
parent
commit
ae2304ae2a

+ 0 - 12
raster3d/r3.in.bin/main.c

@@ -222,7 +222,6 @@ int main(int argc, char *argv[]) {
 	struct {
 	struct {
 		struct Flag *integer_in;
 		struct Flag *integer_in;
 		struct Flag *sign;
 		struct Flag *sign;
-		struct Flag *swap;
 		struct Flag *depth;
 		struct Flag *depth;
 		struct Flag *row;
 		struct Flag *row;
 	} flag;
 	} flag;
@@ -366,11 +365,6 @@ int main(int argc, char *argv[]) {
 	flag.sign->description = _("Signed data (two's complement)");
 	flag.sign->description = _("Signed data (two's complement)");
 	flag.sign->guisection = _("Settings");
 	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))
 	if (G_parser(argc, argv))
 		exit(EXIT_FAILURE);
 		exit(EXIT_FAILURE);
 
 
@@ -386,12 +380,6 @@ int main(int argc, char *argv[]) {
 	else if (G_strcasecmp(parm.order->answer, "swap") == 0)
 	else if (G_strcasecmp(parm.order->answer, "swap") == 0)
 		order = G_is_little_endian() ? 0 : 1;
 		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);
 	byte_swap = order == (G_is_little_endian() ? 0 : 1);
 
 
 	is_signed = !!flag.sign->answer;
 	is_signed = !!flag.sign->answer;

+ 31 - 1
raster3d/r3.in.bin/r3.in.bin.html

@@ -1,7 +1,7 @@
 <h2>DESCRIPTION</h2>
 <h2>DESCRIPTION</h2>
 
 
 <em>r3.in.bin</em> allows a user to create a GRASS 3D raster map 
 <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 
 <p>The top, bottom, north, south, east, and west field values entered 
 are the coordinates of the edges of the geographic region. 
 are the coordinates of the edges of the geographic region. 
@@ -10,6 +10,36 @@ of the matrix of data to follow.
 If the bytes field is entered incorrectly an error will be generated
 If the bytes field is entered incorrectly an error will be generated
 suggesting a closer bytes value. 
 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>
 <h2>SEE ALSO</h2>
 
 
 <em>
 <em>

+ 31 - 17
raster3d/r3.in.bin/test_suite/test.r3.in.bin.sh

@@ -15,9 +15,6 @@ r3.out.bin --o input=test_out_bin_float byte=4 null=-9999 \
 r3.out.bin --o input=test_out_bin_float byte=8 null=-9999 \
 r3.out.bin --o input=test_out_bin_float byte=8 null=-9999 \
     output=test_out_bin_float_native_b8.bin order=native
     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 \
 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
     output=test_out_bin_float_native_r_b4.bin order=native
 
 
@@ -32,21 +29,25 @@ r3.out.bin --o -rd input=test_out_bin_float byte=4 null=-9999 \
 r3.out.bin --o input=test_out_bin_float byte=4 null=-9999 \
 r3.out.bin --o input=test_out_bin_float byte=4 null=-9999 \
     output=test_out_bin_float_little_b4.bin order=little
     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 \
 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
 # 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
     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
     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
     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
     output=test_out_bin_float_native_b8_as_integer.bin order=native
 
 
 # Double precision
 # Double precision
@@ -69,11 +70,6 @@ r3.in.bin --o output=test_in_bin_float_2 byte=8 null=-9999 \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     cols=18 rows=9 depths=10
     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 \
 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 \
     input=test_out_bin_float_native_d_b4.bin order=native \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
@@ -89,26 +85,44 @@ r3.in.bin --o output=test_in_bin_float_6 byte=4 null=-9999 \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     cols=18 rows=9 depths=10 -rd
     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 \
     input=test_out_bin_float_native_b1_as_integer.bin order=native \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     cols=18 rows=9 depths=10 -i
     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 \
     input=test_out_bin_float_native_b2_as_integer.bin order=native \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     cols=18 rows=9 depths=10 -i
     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 \
     input=test_out_bin_float_native_b4_as_integer.bin order=native \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     cols=18 rows=9 depths=10 -i
     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 \
     input=test_out_bin_float_native_b8_as_integer.bin order=native \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     bottom=0 top=100 west=0 east=180 south=0 north=90 \
     cols=18 rows=9 depths=10 -i
     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
 for map in `g.mlist type=rast3d pattern=test_in_bin_float*` ; do
   r3.out.ascii input=${map} output=${map}.txt dp=0
   r3.out.ascii input=${map} output=${map}.txt dp=0

+ 2 - 12
raster3d/r3.out.bin/main.c

@@ -185,7 +185,7 @@ int main(int argc, char *argv[]) {
 		struct Option *bytes;
 		struct Option *bytes;
 	} parm;
 	} parm;
 	struct {
 	struct {
-		struct Flag *swap, *row, *depth, *integer;
+		struct Flag *row, *depth, *integer;
 	} flag;
 	} flag;
 	char *name;
 	char *name;
 	char *outfile;
 	char *outfile;
@@ -233,11 +233,7 @@ int main(int argc, char *argv[]) {
 	parm.order->required = NO;
 	parm.order->required = NO;
 	parm.order->options = "big,little,native,swap";
 	parm.order->options = "big,little,native,swap";
 	parm.order->description = _("Output byte order");
 	parm.order->description = _("Output byte order");
-	parm.order->answer = "native";
-
-	flag.swap = G_define_flag();
-	flag.swap->key = 's';
-	flag.swap->description = _("Byte swap output");
+	parm.order->answer = "native";;
 
 
 	flag.row = G_define_flag();
 	flag.row = G_define_flag();
 	flag.row->key = 'r';
 	flag.row->key = 'r';
@@ -293,12 +289,6 @@ int main(int argc, char *argv[]) {
 	else if (G_strcasecmp(parm.order->answer, "swap") == 0)
 	else if (G_strcasecmp(parm.order->answer, "swap") == 0)
 		order = G_is_little_endian() ? 0 : 1;
 		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);
 	swap_flag = order == (G_is_little_endian() ? 0 : 1);
 
 
 	do_stdout = strcmp("-", outfile) == 0;
 	do_stdout = strcmp("-", outfile) == 0;

+ 15 - 3
raster3d/r3.out.bin/r3.out.bin.html

@@ -1,7 +1,7 @@
 <h2>DESCRIPTION</h2>
 <h2>DESCRIPTION</h2>
 
 
 The <em>r3.out.bin</em> program exports a GRASS 3D raster map to a binary array
 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
 input (pipe) into other applications. Data is exported according to the
 original GRASS 3D raster type (float, double). 
 original GRASS 3D raster type (float, double). 
 
 
@@ -12,11 +12,23 @@ the write order of the depths (bottom->top to top->bottom) can be switched.
 <p>
 <p>
 The region parameters are printed to stderr when setting the verbose flag.
 The region parameters are printed to stderr when setting the verbose flag.
 Export of little and big endian byte order is supported.
 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>
 <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>
 <h2>AUTHOR</h2>