[GRASS-SVN] r34403 -
grass/branches/develbranch_6/raster/r.grow.distance
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Nov 20 11:34:01 EST 2008
Author: glynn
Date: 2008-11-20 11:34:01 -0500 (Thu, 20 Nov 2008)
New Revision: 34403
Modified:
grass/branches/develbranch_6/raster/r.grow.distance/main.c
Log:
Merge 34401 from trunk:
Output maps are optional; don't use them if they weren't chosen
Fix spelling of "euclidean"
Modified: grass/branches/develbranch_6/raster/r.grow.distance/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.grow.distance/main.c 2008-11-20 16:29:54 UTC (rev 34402)
+++ grass/branches/develbranch_6/raster/r.grow.distance/main.c 2008-11-20 16:34:01 UTC (rev 34403)
@@ -37,7 +37,7 @@
#define MAX(a, b) ((a) > (b) ? (a) : (b))
-static double distance_euclidian_squared(double dx, double dy)
+static double distance_euclidean_squared(double dx, double dy)
{
return dx * dx + dy * dy;
}
@@ -148,8 +148,8 @@
opt.met->type = TYPE_STRING;
opt.met->required = NO;
opt.met->description = _("Metric");
- opt.met->options = "euclidian,squared,maximum,manhattan";
- opt.met->answer = "euclidian";
+ opt.met->options = "euclidean,squared,maximum,manhattan";
+ opt.met->answer = "euclidean";
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
@@ -161,10 +161,10 @@
if (!dist_name && !val_name)
G_fatal_error(_("At least one of distance= and value= must be given"));
- if (strcmp(opt.met->answer, "euclidian") == 0)
- distance = &distance_euclidian_squared;
+ if (strcmp(opt.met->answer, "euclidean") == 0)
+ distance = &distance_euclidean_squared;
else if (strcmp(opt.met->answer, "squared") == 0)
- distance = &distance_euclidian_squared;
+ distance = &distance_euclidean_squared;
else if (strcmp(opt.met->answer, "maximum") == 0)
distance = &distance_maximum;
else if (strcmp(opt.met->answer, "manhattan") == 0)
@@ -176,13 +176,17 @@
if (in_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), in_name);
- dist_fd = G_open_raster_new(dist_name, DCELL_TYPE);
- if (dist_fd < 0)
- G_fatal_error(_("Unable to create distance map <%s>"), dist_name);
+ if (dist_name) {
+ dist_fd = G_open_raster_new(dist_name, DCELL_TYPE);
+ if (dist_fd < 0)
+ G_fatal_error(_("Unable to create distance map <%s>"), dist_name);
+ }
- val_fd = G_open_raster_new(val_name, DCELL_TYPE);
- if (val_fd < 0)
- G_fatal_error(_("Unable to create value map <%s>"), val_name);
+ if (val_name) {
+ val_fd = G_open_raster_new(val_name, DCELL_TYPE);
+ if (val_fd < 0)
+ G_fatal_error(_("Unable to create value map <%s>"), val_name);
+ }
temp_name = G_tempfile();
temp_fd = open(temp_name, O_RDWR | O_CREAT | O_EXCL, 0700);
@@ -208,7 +212,7 @@
dist_row = G_allocate_d_raster_buf();
- if (dist_name && strcmp(opt.met->answer, "euclidian") == 0)
+ if (dist_name && strcmp(opt.met->answer, "euclidean") == 0)
out_row = G_allocate_d_raster_buf();
else
out_row = dist_row;
@@ -302,8 +306,10 @@
close(temp_fd);
remove(temp_name);
- G_close_cell(dist_fd);
- G_close_cell(val_fd);
+ if (dist_name)
+ G_close_cell(dist_fd);
+ if (val_name)
+ G_close_cell(val_fd);
if (val_name) {
if (G_read_colors(in_name, "", &colors) < 0)
More information about the grass-commit
mailing list