]> granicus.if.org Git - postgis/commitdiff
Cleaned the grid alignment code to remove unnecessary cruft in rt_raster_gdal_warp
authorBborie Park <bkpark at ucdavis.edu>
Thu, 21 Jul 2011 17:31:07 +0000 (17:31 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Thu, 21 Jul 2011 17:31:07 +0000 (17:31 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7658 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_core/rt_api.c

index 7889a50154ff741d233884c88596a365ca2fe99a..13d7a4fedca0df48e2ee74f5afbd7ea2536946cf 100644 (file)
@@ -6189,15 +6189,12 @@ rt_raster rt_raster_gdal_warp(
                grid_shift_yw = grid_pix_y * modf(fabs(*grid_yw - dst_gt[3]) / grid_pix_y, &djunk);
 
                /* shift along X axis for upper left */
-               if (FLT_NEQ(grid_shift_xw, 0.)) {
-                       min_x = dst_gt[0] + grid_shift_xw;
+               if (FLT_NEQ(grid_shift_xw, 0.) && FLT_NEQ(grid_shift_xw, grid_pix_x)) {
+                       min_x = dst_gt[0] - grid_shift_xw;
                        min_x = modf(fabs(*grid_xw - min_x) / grid_pix_x, &djunk);
-                       if (FLT_NEQ(min_x, 0.) && FLT_NEQ(min_x, 1.)) grid_shift_xw *= -1;
-                       min_x = dst_gt[0] + grid_shift_xw;
-                       if (min_x > dst_gt[0]) {
-                               grid_shift_xw = grid_pix_x - fabs(grid_shift_xw);
-                               min_x = dst_gt[0] - grid_shift_xw;
-                       }
+                       if (FLT_NEQ(min_x, 0.) && FLT_NEQ(min_x, 1.))
+                               grid_shift_xw = grid_pix_x - grid_shift_xw;
+                       min_x = dst_gt[0] - grid_shift_xw;
 
                        ul_user = 1;
                }
@@ -6205,15 +6202,12 @@ rt_raster rt_raster_gdal_warp(
                        min_x = dst_gt[0];
 
                /* shift along Y axis for upper left */
-               if (FLT_NEQ(grid_shift_yw, 0.)) {
+               if (FLT_NEQ(grid_shift_yw, 0.) && FLT_NEQ(grid_shift_yw, grid_pix_y)) {
                        max_y = dst_gt[3] + grid_shift_yw;
                        max_y = modf(fabs(*grid_yw - max_y) / grid_pix_y, &djunk);
-                       if (FLT_NEQ(max_y, 0.) && FLT_NEQ(max_y, 1.)) grid_shift_yw *= -1;
+                       if (FLT_NEQ(max_y, 0.) && FLT_NEQ(max_y, 1.))
+                               grid_shift_yw = grid_pix_y - grid_shift_yw;
                        max_y = dst_gt[3] + grid_shift_yw;
-                       if (max_y < dst_gt[3]) {
-                               grid_shift_yw = grid_pix_y - fabs(grid_shift_yw);
-                               max_y = dst_gt[3] + grid_shift_yw;
-                       }
 
                        ul_user = 1;
                }