Forráskód Böngészése

Do not calculate median if only one variable is provided.
Fixes https://trac.osgeo.org/grass/ticket/3296 (backport of https://trac.osgeo.org/grass/changeset/70674)


git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@70675 15284696-431f-4ddb-bdfa-cd5b030d7da7

Maris Nartiss 8 éve
szülő
commit
f4c5466288
1 módosított fájl, 6 hozzáadás és 0 törlés
  1. 6 0
      raster/r.mapcalc/xnmedian.c

+ 6 - 0
raster/r.mapcalc/xnmedian.c

@@ -84,6 +84,8 @@ int f_nmedian(int argc, const int *argt, void **args)
 
 		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 @@ int f_nmedian(int argc, const int *argt, void **args)
 
 		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 @@ int f_nmedian(int argc, const int *argt, void **args)
 
 		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;