[GRASS-SVN] r62080 - grass/branches/releasebranch_7_0/raster/r.in.bin

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Sep 25 01:12:03 PDT 2014


Author: mmetz
Date: 2014-09-25 01:12:03 -0700 (Thu, 25 Sep 2014)
New Revision: 62080

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

Modified: grass/branches/releasebranch_7_0/raster/r.in.bin/main.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.in.bin/main.c	2014-09-25 08:11:35 UTC (rev 62079)
+++ grass/branches/releasebranch_7_0/raster/r.in.bin/main.c	2014-09-25 08:12:03 UTC (rev 62080)
@@ -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");
@@ -370,6 +377,7 @@
     swap_flag = order == (G_is_little_endian() ? 0 : 1);
 
     is_signed = !!flag.sign->answer;
+    flipns = !!flag.flip->answer;
 
     is_fp = 0;
     bytes = 0;
@@ -506,6 +514,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