[GRASS-SVN] r34277 - grass/trunk/raster/r.grow.distance

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 13 13:52:24 EST 2008


Author: glynn
Date: 2008-11-13 13:52:24 -0500 (Thu, 13 Nov 2008)
New Revision: 34277

Modified:
   grass/trunk/raster/r.grow.distance/main.c
Log:
Only calculate square root for metric=euclidean


Modified: grass/trunk/raster/r.grow.distance/main.c
===================================================================
--- grass/trunk/raster/r.grow.distance/main.c	2008-11-13 16:31:06 UTC (rev 34276)
+++ grass/trunk/raster/r.grow.distance/main.c	2008-11-13 18:52:24 UTC (rev 34277)
@@ -112,6 +112,7 @@
     DCELL min, max;
     DCELL *out_row;
     struct Cell_head window;
+    int need_sqrt = 0;
 
     G_gisinit(argv[0]);
 
@@ -138,8 +139,10 @@
     in_name = opt.in->answer;
     out_name = opt.out->answer;
 
-    if (strcmp(opt.met->answer, "euclidian") == 0)
+    if (strcmp(opt.met->answer, "euclidian") == 0) {
 	distance = &distance_euclidian_squared;
+	need_sqrt = 1;
+    }
     else if (strcmp(opt.met->answer, "squared") == 0)
 	distance = &distance_euclidian_squared;
     else if (strcmp(opt.met->answer, "maximum") == 0)
@@ -252,7 +255,9 @@
 
 	if (out_row != dist_row)
 	    for (col = 0; col < ncols; col++)
-		out_row[col] = sqrt(dist_row[col]);
+		out_row[col] = need_sqrt
+		    ? sqrt(dist_row[col])
+		    : dist_row[col];
 
 	G_put_d_raster_row(out_fd, out_row);
 



More information about the grass-commit mailing list