[GRASS-SVN] r66450 - grass/branches/releasebranch_7_0/raster/r.patch

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Oct 9 09:55:34 PDT 2015


Author: wenzeslaus
Date: 2015-10-09 09:55:34 -0700 (Fri, 09 Oct 2015)
New Revision: 66450

Modified:
   grass/branches/releasebranch_7_0/raster/r.patch/do_patch.c
   grass/branches/releasebranch_7_0/raster/r.patch/local_proto.h
   grass/branches/releasebranch_7_0/raster/r.patch/main.c
   grass/branches/releasebranch_7_0/raster/r.patch/r.patch.html
Log:
r.patch: call Rast_cell_size just once, not for every cell (backport r64877 and part of 66449)

Modified: grass/branches/releasebranch_7_0/raster/r.patch/do_patch.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.patch/do_patch.c	2015-10-09 16:45:29 UTC (rev 66449)
+++ grass/branches/releasebranch_7_0/raster/r.patch/do_patch.c	2015-10-09 16:55:34 UTC (rev 66450)
@@ -21,7 +21,7 @@
 
 int do_patch(void *result, void *patch,
 	     struct Cell_stats *statf, int ncols,
-	     RASTER_MAP_TYPE out_type, int use_zero)
+             RASTER_MAP_TYPE out_type, size_t out_cell_size, int use_zero)
 {
     int more;
 
@@ -56,8 +56,8 @@
 		}
 	    }			/* NULL support */
 	}
-	result = G_incr_void_ptr(result, Rast_cell_size(out_type));
-	patch = G_incr_void_ptr(patch, Rast_cell_size(out_type));
+        result = G_incr_void_ptr(result, out_cell_size);
+        patch = G_incr_void_ptr(patch, out_cell_size);
     }
     return more;
 }

Modified: grass/branches/releasebranch_7_0/raster/r.patch/local_proto.h
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.patch/local_proto.h	2015-10-09 16:45:29 UTC (rev 66449)
+++ grass/branches/releasebranch_7_0/raster/r.patch/local_proto.h	2015-10-09 16:55:34 UTC (rev 66450)
@@ -1,6 +1,6 @@
 /* do_patch.c */
 int do_patch(void *result, void *, struct Cell_stats *, int, RASTER_MAP_TYPE,
-	     int);
+             size_t, int);
 /* support.c */
 int support(char **, struct Cell_stats *, int, struct Categories *,
 	    int *, struct Colors *, int *, RASTER_MAP_TYPE);

Modified: grass/branches/releasebranch_7_0/raster/r.patch/main.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.patch/main.c	2015-10-09 16:45:29 UTC (rev 66449)
+++ grass/branches/releasebranch_7_0/raster/r.patch/main.c	2015-10-09 16:55:34 UTC (rev 66450)
@@ -31,6 +31,7 @@
     int colr_ok;
     int outfd;
     RASTER_MAP_TYPE out_type, map_type;
+    size_t out_cell_size;
     struct History history;
     void *presult, *patch;
     int nfiles;
@@ -54,6 +55,8 @@
     G_add_keyword(_("raster"));
     G_add_keyword(_("geometry"));
     G_add_keyword(_("mosaicking"));
+    G_add_keyword(_("merge"));
+    G_add_keyword(_("patching"));
     module->description =
 	_("Creates a composite raster map layer by using "
 	  "known category values from one (or more) map layer(s) "
@@ -111,6 +114,8 @@
 	Rast_get_cellhd(name, "", &cellhd[i]);
     }
 
+    out_cell_size = Rast_cell_size(out_type);
+
     rname = opt2->answer;
     outfd = Rast_open_new(new_name = rname, out_type);
 
@@ -143,7 +148,8 @@
 
 	    Rast_get_row(infd[i], patch, row, out_type);
 	    if (!do_patch
-		(presult, patch, &statf[i], ncols, out_type, use_zero))
+                (presult, patch, &statf[i], ncols, out_type, out_cell_size,
+                 use_zero))
 		break;
 	}
 	Rast_put_row(outfd, presult, out_type);

Modified: grass/branches/releasebranch_7_0/raster/r.patch/r.patch.html
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.patch/r.patch.html	2015-10-09 16:45:29 UTC (rev 66449)
+++ grass/branches/releasebranch_7_0/raster/r.patch/r.patch.html	2015-10-09 16:55:34 UTC (rev 66450)
@@ -21,12 +21,15 @@
 maps will be used, in order, to supply data values for for the remaining
 "no data" cells.
 
-<h2>EXAMPLE</h2>
+<h3>Example of filling areas</h3>
 
-Below, the raster map layer on the far left is <b>patched</b> 
-with the middle (<em>patching</em>) raster map layer, 
-to produce the <em>composite</em> raster map layer on the right. 
+<!-- this example is also used in the tests -->
 
+Below, the raster map layer on the far left is <b>patched</b>
+with the middle (<em>patching</em>) raster map layer,
+to produce the <em>composite</em> raster map layer on the right.
+The example assumes zero values to be treated as NULLs (<b>-z</b> flag).
+
 <div class="code"><pre>
   1 1 1 0 2 2 0 0    0 0 1 1 0 0 0 0    1 1 1 1 2 2 0 0
   1 1 0 2 2 2 0 0    0 0 1 1 0 0 0 0    1 1 1 2 2 2 0 0
@@ -48,6 +51,7 @@
   4 4 4 4 4 4 4 4    0 0 0 0 0 0 0 0    4 4 4 4 4 4 4 4
 </pre></div>
 
+
 <h2>NOTES</h2>
 
 Frequently, this program is used to patch together adjacent map layers which



More information about the grass-commit mailing list