diff --git a/mapresample.c b/mapresample.c index 6922ee15ff..d0dfb9cf77 100644 --- a/mapresample.c +++ b/mapresample.c @@ -342,6 +342,13 @@ msBilinearRasterResampler( imageObj *psSrcImage, rasterBufferObj *src_rb, continue; } + /* If we are right off the source, skip this pixel */ + nSrcX = (int) floor(x[nDstX]); + nSrcY = (int) floor(y[nDstX]); + if( nSrcX < 0 || (!bWrapAtLeftRight && nSrcX >= nSrcXSize) + || nSrcY < 0 || nSrcY >= nSrcYSize ) + continue; + /* ** Offset to treat TL pixel corners as pixel location instead ** of the center. @@ -358,11 +365,6 @@ msBilinearRasterResampler( imageObj *psSrcImage, rasterBufferObj *src_rb, dfRatioX2 = x[nDstX] - nSrcX; dfRatioY2 = y[nDstX] - nSrcY; - /* If we are right off the source, skip this pixel */ - if( nSrcX2 < 0 || (!bWrapAtLeftRight && nSrcX >= nSrcXSize) - || nSrcY2 < 0 || nSrcY >= nSrcYSize ) - continue; - /* Trim in stuff one pixel off the edge */ nSrcX = MS_MAX(nSrcX,0); nSrcY = MS_MAX(nSrcY,0); diff --git a/msautotest/gdal/bilinear_left_right.map b/msautotest/gdal/bilinear_left_right.map new file mode 100644 index 0000000000..fcb70e5219 --- /dev/null +++ b/msautotest/gdal/bilinear_left_right.map @@ -0,0 +1,37 @@ +# Test assembling two rasters and bilinear resampling +MAP + + NAME TEST + PROJECTION + "init=epsg:4326" + END + + EXTENT -3.515625 -35.15625 3.515625 35.15625 + SIZE 32 320 + IMAGETYPE png + + LAYER + NAME "east-bilinear" + TYPE RASTER + STATUS default + + PROJECTION + "init=epsg:4326" + END + PROCESSING "RESAMPLE=BILINEAR" + DATA "data/east.tif" + END + + LAYER + NAME "west-bilinear" + TYPE RASTER + STATUS default + + PROJECTION + "init=epsg:4326" + END + PROCESSING "RESAMPLE=BILINEAR" + DATA "data/west.tif" + END + +END diff --git a/msautotest/gdal/bilinear_src_transp.map b/msautotest/gdal/bilinear_src_transp.map index cda421a2b7..57f04fbdc5 100644 --- a/msautotest/gdal/bilinear_src_transp.map +++ b/msautotest/gdal/bilinear_src_transp.map @@ -6,7 +6,7 @@ MAP NAME TEST STATUS ON SIZE 400 40 -EXTENT 0.5 0.5 39.5 1.5 +EXTENT 0.5 1.5 39.5 2.5 IMAGECOLOR 0 0 0 OUTPUTFORMAT diff --git a/msautotest/gdal/data/east.tif b/msautotest/gdal/data/east.tif new file mode 100644 index 0000000000..e0bee966cb Binary files /dev/null and b/msautotest/gdal/data/east.tif differ diff --git a/msautotest/gdal/data/west.tif b/msautotest/gdal/data/west.tif new file mode 100644 index 0000000000..3f68c90423 Binary files /dev/null and b/msautotest/gdal/data/west.tif differ diff --git a/msautotest/gdal/expected/bilinear_left_right.png b/msautotest/gdal/expected/bilinear_left_right.png new file mode 100644 index 0000000000..9b092fa5d0 Binary files /dev/null and b/msautotest/gdal/expected/bilinear_left_right.png differ diff --git a/msautotest/gdal/expected/bilinear_src_transp.png b/msautotest/gdal/expected/bilinear_src_transp.png index b6b7672012..70b0eaeac3 100644 Binary files a/msautotest/gdal/expected/bilinear_src_transp.png and b/msautotest/gdal/expected/bilinear_src_transp.png differ diff --git a/msautotest/gdal/expected/bilinear_src_transp2.png b/msautotest/gdal/expected/bilinear_src_transp2.png index 25605f5f34..9e50dcd503 100644 Binary files a/msautotest/gdal/expected/bilinear_src_transp2.png and b/msautotest/gdal/expected/bilinear_src_transp2.png differ diff --git a/msautotest/gdal/expected/rawmode_nodata_resample.png b/msautotest/gdal/expected/rawmode_nodata_resample.png index 4e8b4e741e..7f774f3980 100644 --- a/msautotest/gdal/expected/rawmode_nodata_resample.png +++ b/msautotest/gdal/expected/rawmode_nodata_resample.png @@ -3,33 +3,33 @@ nrows 30 xllcorner -6.206896551724 yllcorner -4.655172413793 cellsize 10.310344827586 - -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -9 -10 -10 -10 -10 -10 -10 -10 -9 -10 -10 -10 -10 -10 -10 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4 4 4 4 4 - 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 - 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 - 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 - 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 - 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 - 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 - 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 - 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 - 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 - 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 - 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 - 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 - 23 23 23 23 23 23 23 23 23 23 23 23 22 23 23 23 23 23 23 23 23 23 23 23 23 23 23 22 23 23 23 23 23 23 23 23 23 23 23 23 - 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 - 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 - 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 - 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 + 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 + 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 0 + 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 0 + 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 0 + 0 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 0 + 0 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 0 + 0 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 0 + 0 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 0 + 0 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 0 + 0 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 0 + 0 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 0 + 0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 0 + 0 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 0 + 0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0 + 0 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 0 + 0 23 23 23 23 23 23 23 23 23 23 23 22 23 23 23 23 23 23 23 23 23 23 23 23 23 23 22 23 23 23 23 23 23 23 23 23 23 23 0 + 0 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 0 + 0 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 0 + 0 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 0 + 0 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 0