[GRASS-SVN] r43943 - grass/trunk/raster/r.proj
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Oct 17 04:58:46 EDT 2010
Author: glynn
Date: 2010-10-17 01:58:46 -0700 (Sun, 17 Oct 2010)
New Revision: 43943
Modified:
grass/trunk/raster/r.proj/bilinear.c
grass/trunk/raster/r.proj/cubic.c
grass/trunk/raster/r.proj/cubic_f.c
grass/trunk/raster/r.proj/main.c
Log:
Fix off-by-half error
Modified: grass/trunk/raster/r.proj/bilinear.c
===================================================================
--- grass/trunk/raster/r.proj/bilinear.c 2010-10-17 08:37:24 UTC (rev 43942)
+++ grass/trunk/raster/r.proj/bilinear.c 2010-10-17 08:58:46 UTC (rev 43943)
@@ -33,8 +33,8 @@
FCELL *c00, *c01, *c10, *c11;
/* cut indices to integer */
- row0 = (int)floor(*row_idx);
- col0 = (int)floor(*col_idx);
+ row0 = (int)floor(*row_idx - 0.5);
+ col0 = (int)floor(*col_idx - 0.5);
row1 = row0 + 1;
col1 = col0 + 1;
@@ -58,8 +58,8 @@
}
/* do the interpolation */
- t = *col_idx - col0;
- u = *row_idx - row0;
+ t = *col_idx - 0.5 - col0;
+ u = *row_idx - 0.5 - row0;
tu = t * u;
result = Rast_interp_bilinear(t, u, *c00, *c01, *c10, *c11);
Modified: grass/trunk/raster/r.proj/cubic.c
===================================================================
--- grass/trunk/raster/r.proj/cubic.c 2010-10-17 08:37:24 UTC (rev 43942)
+++ grass/trunk/raster/r.proj/cubic.c 2010-10-17 08:58:46 UTC (rev 43943)
@@ -35,8 +35,8 @@
FCELL *cellp[4][4];
/* cut indices to integer */
- row = (int)floor(*row_idx);
- col = (int)floor(*col_idx);
+ row = (int)floor(*row_idx - 0.5);
+ col = (int)floor(*col_idx - 0.5);
/* check for out of bounds of map - if out of bounds set NULL value */
if (row - 1 < 0 || row + 2 >= cellhd->rows ||
@@ -59,8 +59,8 @@
}
/* do the interpolation */
- t = *col_idx - col;
- u = *row_idx - row;
+ t = *col_idx - 0.5 - col;
+ u = *row_idx - 0.5 - row;
for (i = 0; i < 4; i++) {
FCELL **tmp = cellp[i];
Modified: grass/trunk/raster/r.proj/cubic_f.c
===================================================================
--- grass/trunk/raster/r.proj/cubic_f.c 2010-10-17 08:37:24 UTC (rev 43942)
+++ grass/trunk/raster/r.proj/cubic_f.c 2010-10-17 08:58:46 UTC (rev 43943)
@@ -47,7 +47,7 @@
if (Rast_is_f_null_value(obufptr)) {
p_bilinear(ibuffer, obufptr, cell_type, col_idx, row_idx, cellhd);
/* fallback to nearest if bilinear is null */
- if (Rast_is_f_null_value(obufptr))
+ if (Rast_is_f_null_value(obufptr))
Rast_set_f_value(obufptr, *cellp, cell_type);
}
}
Modified: grass/trunk/raster/r.proj/main.c
===================================================================
--- grass/trunk/raster/r.proj/main.c 2010-10-17 08:37:24 UTC (rev 43942)
+++ grass/trunk/raster/r.proj/main.c 2010-10-17 08:58:46 UTC (rev 43943)
@@ -236,11 +236,13 @@
G_fatal_error(_("option <%s>: <%s> exists."), "output", mapname);
setname = imapset->answer ? imapset->answer : G_store(G_mapset());
-
if (strcmp(inlocation->answer, G_location()) == 0 &&
(!indbase->answer || strcmp(indbase->answer, G_gisdbase()) == 0))
+#if 0
G_fatal_error(_("Input and output locations can not be the same"));
-
+#else
+ G_warning(_("Input and output locations are the same"));
+#endif
G_get_window(&outcellhd);
if(gprint_bounds->answer && !print_bounds->answer)
More information about the grass-commit
mailing list