ODP: [GRASS-user] MOLA data elevation problem

Glynn Clements glynn at gclements.plus.com
Thu Feb 8 05:46:21 EST 2007


Maciej Sieczka wrote:

> > There is in r.in.bin a -s flag(high bit means negative value) but when i used it, effect was the same.
> 
> That's because (after the manual) "The  -s flag is used for importing
> signed one byte data (range -128 - 127)."
> 
> It would be very useful to have it extended to support 2 and 4 byte data.

That should be easy enough; I'll commit the following patch once I've
tested it.

-- 
Glynn Clements <glynn at gclements.plus.com>

-------------- next part --------------
--- raster/r.in.bin/main.c	18 Nov 2006 14:45:26 -0000	2.9
+++ raster/r.in.bin/main.c	8 Feb 2007 10:43:07 -0000
@@ -501,12 +501,18 @@
 				/* Import 2 byte Short */
 				if (swap)
 					SwabShort(&x_s[col]);
-				cell[col] = (CELL) x_s[col] ;
+				if (sflag)
+					cell[col] = (CELL) (signed short) x_s[col] ;
+				else
+					cell[col] = (CELL) (unsigned short) x_s[col] ;
 			} else {
 				/* Import 4 byte Int */
 				if (swap)
 					SwabLong(&x_i[col]);
-				cell[col] = (CELL) x_i[col] ;
+				if (sflag)
+					cell[col] = (CELL) (signed int) x_i[col] ;
+				else
+					cell[col] = (CELL) (unsigned int) x_i[col] ;
 			}
 			if(parm.anull->answer) {
 				if(flag.f->answer) {


More information about the grass-user mailing list