[GRASS-SVN] r70675 - grass/branches/releasebranch_7_0/raster/r.mapcalc
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Feb 26 02:01:10 PST 2017
Author: marisn
Date: 2017-02-26 02:01:10 -0800 (Sun, 26 Feb 2017)
New Revision: 70675
Modified:
grass/branches/releasebranch_7_0/raster/r.mapcalc/xnmedian.c
Log:
Do not calculate median if only one variable is provided.
Fixes #3296 (backport of r70674)
Modified: grass/branches/releasebranch_7_0/raster/r.mapcalc/xnmedian.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.mapcalc/xnmedian.c 2017-02-26 09:47:13 UTC (rev 70674)
+++ grass/branches/releasebranch_7_0/raster/r.mapcalc/xnmedian.c 2017-02-26 10:01:10 UTC (rev 70675)
@@ -84,6 +84,8 @@
if (!n)
SET_NULL_C(&res[i]);
+ else if (n == 1)
+ res[i] = *a1;
else {
qsort(a, n, sizeof(CELL), icmp);
res[i] = (*a1 + *a2) / 2;
@@ -111,6 +113,8 @@
if (!n)
SET_NULL_F(&res[i]);
+ else if (n == 1)
+ res[i] = *a1;
else {
qsort(a, n, sizeof(FCELL), fcmp);
res[i] = (*a1 + *a2) / 2;
@@ -138,6 +142,8 @@
if (!n)
SET_NULL_D(&res[i]);
+ else if (n == 1)
+ res[i] = *a1;
else {
qsort(a, n, sizeof(DCELL), dcmp);
res[i] = (*a1 + *a2) / 2;
More information about the grass-commit
mailing list