[GRASS-SVN] r53889 - grass/trunk/raster/r.neighbors
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Nov 18 04:21:58 PST 2012
Author: marisn
Date: 2012-11-18 04:21:58 -0800 (Sun, 18 Nov 2012)
New Revision: 53889
Modified:
grass/trunk/raster/r.neighbors/bufs.c
grass/trunk/raster/r.neighbors/main.c
Log:
Fix shifting of original data with selection option
Modified: grass/trunk/raster/r.neighbors/bufs.c
===================================================================
--- grass/trunk/raster/r.neighbors/bufs.c 2012-11-18 12:18:23 UTC (rev 53888)
+++ grass/trunk/raster/r.neighbors/bufs.c 2012-11-18 12:21:58 UTC (rev 53889)
@@ -15,12 +15,12 @@
int i;
int bufsize;
- bufsize = (Rast_window_cols() + 2 * ncb.nsize) * sizeof(DCELL);
+ bufsize = (Rast_window_cols() + 2 * ncb.dist) * sizeof(DCELL);
ncb.buf = (DCELL **) G_malloc(ncb.nsize * sizeof(DCELL *));
for (i = 0; i < ncb.nsize; i++) {
ncb.buf[i] = (DCELL *) G_malloc(bufsize);
- Rast_set_d_null_value(ncb.buf[i], Rast_window_cols() + 2 * ncb.nsize);
+ Rast_set_d_null_value(ncb.buf[i], Rast_window_cols() + 2 * ncb.dist);
}
return 0;
Modified: grass/trunk/raster/r.neighbors/main.c
===================================================================
--- grass/trunk/raster/r.neighbors/main.c 2012-11-18 12:18:23 UTC (rev 53888)
+++ grass/trunk/raster/r.neighbors/main.c 2012-11-18 12:21:58 UTC (rev 53889)
@@ -322,7 +322,9 @@
DCELL *rp = &result[col];
if (selection && selection[col]) {
- *rp = ncb.buf[ncb.dist][col];
+ /* ncb.buf length is region row length + 2 * ncb.dist (eq. floor(neighborhood/2))
+ * Thus original data start is shifted by ncb.dist! */
+ *rp = ncb.buf[ncb.dist][col+ncb.dist];
continue;
}
More information about the grass-commit
mailing list