[GRASS-SVN] r43954 - grass/branches/develbranch_6/raster/r.proj.seg

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Oct 17 14:10:45 EDT 2010


Author: neteler
Date: 2010-10-17 11:10:45 -0700 (Sun, 17 Oct 2010)
New Revision: 43954

Modified:
   grass/branches/develbranch_6/raster/r.proj.seg/bilinear.c
   grass/branches/develbranch_6/raster/r.proj.seg/cubic.c
   grass/branches/develbranch_6/raster/r.proj.seg/main.c
Log:
fix off by half pixel (backport of r43943)

Modified: grass/branches/develbranch_6/raster/r.proj.seg/bilinear.c
===================================================================
--- grass/branches/develbranch_6/raster/r.proj.seg/bilinear.c	2010-10-17 18:10:16 UTC (rev 43953)
+++ grass/branches/develbranch_6/raster/r.proj.seg/bilinear.c	2010-10-17 18:10:45 UTC (rev 43954)
@@ -32,8 +32,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;
 
@@ -57,8 +57,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 = G_interp_bilinear(t, u, *c00, *c01, *c10, *c11);

Modified: grass/branches/develbranch_6/raster/r.proj.seg/cubic.c
===================================================================
--- grass/branches/develbranch_6/raster/r.proj.seg/cubic.c	2010-10-17 18:10:16 UTC (rev 43953)
+++ grass/branches/develbranch_6/raster/r.proj.seg/cubic.c	2010-10-17 18:10:45 UTC (rev 43954)
@@ -34,8 +34,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 ||
@@ -58,8 +58,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/branches/develbranch_6/raster/r.proj.seg/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.proj.seg/main.c	2010-10-17 18:10:16 UTC (rev 43953)
+++ grass/branches/develbranch_6/raster/r.proj.seg/main.c	2010-10-17 18:10:45 UTC (rev 43954)
@@ -234,10 +234,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)
-	G_fatal_error(_("You have to use a different location for input than the current"));
-
+    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