From: Bborie Park Date: Thu, 21 Jul 2011 17:31:07 +0000 (+0000) Subject: Cleaned the grid alignment code to remove unnecessary cruft in rt_raster_gdal_warp X-Git-Tag: 2.0.0alpha1~1188 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ce3904ddaa3cbb4ce2a8e7a73253eded2a772cd;p=postgis Cleaned the grid alignment code to remove unnecessary cruft in rt_raster_gdal_warp git-svn-id: http://svn.osgeo.org/postgis/trunk@7658 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_core/rt_api.c b/raster/rt_core/rt_api.c index 7889a5015..13d7a4fed 100644 --- a/raster/rt_core/rt_api.c +++ b/raster/rt_core/rt_api.c @@ -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; }