[GRASS-SVN] r72274 - grass/trunk/general/g.region

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Feb 23 15:44:43 PST 2018


Author: lucadelu
Date: 2018-02-23 15:44:43 -0800 (Fri, 23 Feb 2018)
New Revision: 72274

Modified:
   grass/trunk/general/g.region/main.c
Log:
g.region: added pixel option, working on #789

Modified: grass/trunk/general/g.region/main.c
===================================================================
--- grass/trunk/general/g.region/main.c	2018-02-22 19:16:03 UTC (rev 72273)
+++ grass/trunk/general/g.region/main.c	2018-02-23 23:44:43 UTC (rev 72274)
@@ -32,7 +32,7 @@
     int print_flag = 0;
     int flat_flag; 
     int set_flag;
-    double x;
+    double x, xs, ys, zs;
     int ival;
     int row_flag = 0, col_flag = 0;
     struct Cell_head window, temp_window;
@@ -40,6 +40,7 @@
     const char *name;
     const char *mapset;
     char **rast_ptr, **vect_ptr;
+    int pix;
 
     struct GModule *module;
     struct
@@ -55,7 +56,7 @@
 	    *north, *south, *east, *west, *top, *bottom,
 	    *res, *nsres, *ewres, *res3, *tbres, *rows, *cols,
 	    *save, *region, *raster, *raster3d, *align,
-	    *zoom, *vect;
+	    *zoom, *vect, *pixels;
     } parm;
 
     G_gisinit(argv[0]);
@@ -335,6 +336,16 @@
     parm.align->gisprompt = "old,cell,raster";
     parm.align->guisection = _("Bounds");
 
+    parm.pixels = G_define_option();
+    parm.pixels->key = "pixels";
+    parm.pixels->key_desc = "value";
+    parm.pixels->required = NO;
+    parm.pixels->multiple = NO;
+    parm.pixels->type = TYPE_INTEGER;
+    parm.pixels->description =	
+    _("Number of pixels to increase the bounding box");
+    parm.pixels->guisection = _("Bounds");
+
     parm.save = G_define_option();
     parm.save->key = "save";
     parm.save->key_desc = "name";
@@ -353,7 +364,7 @@
                       parm.raster3d, parm.vect, parm.north, parm.south, parm.east,
                       parm.west, parm.top, parm.bottom, parm.rows, parm.cols,
                       parm.res, parm.res3, parm.nsres, parm.ewres, parm.tbres,
-                      parm.zoom, parm.align, parm.save, NULL);
+                      parm.zoom, parm.align, parm.save, parm.pixels, NULL);
 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
@@ -775,7 +786,22 @@
 	Rast_get_cellhd(name, mapset, &temp_window);
 	Rast_align_window(&window, &temp_window);
     }
-
+    
+    /* pixels */
+    if ((value = parm.pixels->answer)){
+		if (sscanf(value, "%i", &pix)){
+		    xs = window.ns_res * pix;
+		    window.north += xs;
+		    window.south -= xs;
+		    ys = window.ew_res * pix;
+		    window.west -= ys;
+		    window.east += ys;
+		    zs = window.tb_res * pix;
+		    window.top += zs;
+		    window.bottom -= zs;
+		}
+	}
+	
     /* save= */
     if ((name = parm.save->answer)) {
 	temp_window = window;



More information about the grass-commit mailing list