[GRASS-SVN] r62079 - grass/trunk/raster/r.in.bin

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Sep 25 01:11:35 PDT 2014


Author: mmetz
Date: 2014-09-25 01:11:35 -0700 (Thu, 25 Sep 2014)
New Revision: 62079

Modified:
   grass/trunk/raster/r.in.bin/main.c
Log:
r.in.bin: add flag to flip North and South

Modified: grass/trunk/raster/r.in.bin/main.c
===================================================================
--- grass/trunk/raster/r.in.bin/main.c	2014-09-24 15:43:34 UTC (rev 62078)
+++ grass/trunk/raster/r.in.bin/main.c	2014-09-25 08:11:35 UTC (rev 62079)
@@ -204,6 +204,7 @@
 	struct Flag *gmt_hd;
 	struct Flag *sign;
 	struct Flag *swap;
+	struct Flag *flip;
     } flag;
     const char *input;
     const char *output;
@@ -214,6 +215,7 @@
     int bytes;
     int order;
     int swap_flag;
+    int flipns;
     struct Cell_head cellhd;
     int nrows, ncols;
     int grass_nrows, grass_ncols;
@@ -257,6 +259,11 @@
     flag.swap->description = _("Byte swap the data during import");
     flag.swap->guisection = _("Settings");
 
+    flag.flip = G_define_flag();
+    flag.flip->key = 'n';
+    flag.flip->description = _("Flip North and South");
+    flag.flip->guisection = _("Settings");
+
     flag.gmt_hd = G_define_flag();
     flag.gmt_hd->key = 'h';
     flag.gmt_hd->description = _("Get region info from GMT style header");
@@ -371,6 +378,7 @@
     swap_flag = order == (G_is_little_endian() ? 0 : 1);
 
     is_signed = !!flag.sign->answer;
+    flipns = !!flag.flip->answer;
 
     is_fp = 0;
     bytes = 0;
@@ -514,6 +522,10 @@
     for (row = 0; row < grass_nrows; row++) {
 	G_percent(row, nrows, 2);
 
+	if (flipns) {
+	    G_fseek(fp, (off_t) (grass_nrows - row - 1) * ncols * bytes, SEEK_SET);
+	}
+
 	if (fread(in_buf, bytes, ncols, fp) != ncols)
 	    G_fatal_error(_("Error reading data"));
 



More information about the grass-commit mailing list