Permalink
Browse files

Merge pull request #5360 from dshorthouse/patch-1

Repeat transformation if extent is extreme
  • Loading branch information...
jmckenna committed Nov 13, 2017
2 parents e7362a1 + bbfa866 commit 51ea1eeeac2239f0793ef6653ba48445b0a797b8
Showing with 35 additions and 2 deletions.
  1. +35 −2 mapresample.c
View
@@ -1356,14 +1356,47 @@ int msResampleGDALToMap( mapObj *map, layerObj *layer, imageObj *image,
/* -------------------------------------------------------------------- */
if( CSLFetchBoolean( layer->processing, "LOAD_WHOLE_IMAGE", FALSE ) )
bSuccess = FALSE;
else
else {
bSuccess =
msTransformMapToSource( nDstXSize, nDstYSize, adfDstGeoTransform,
&(map->projection),
nSrcXSize, nSrcYSize,adfInvSrcGeoTransform,
&(layer->projection),
&sSrcExtent, FALSE );
if (bSuccess) {
/* -------------------------------------------------------------------- */
/* Repeat transformation for a rectangle interior to the output */
/* requested region. If the latter results in a more extreme y */
/* extent, then extend extents in source layer projection to */
/* southern/northing bounds and entire x extent. */
/* -------------------------------------------------------------------- */
memcpy( &sOrigSrcExtent, &sSrcExtent, sizeof(sSrcExtent) );
adfDstGeoTransform[0] = adfDstGeoTransform[0] + adfDstGeoTransform[1];
adfDstGeoTransform[3] = adfDstGeoTransform[3] + adfDstGeoTransform[5];
bSuccess =
msTransformMapToSource( nDstXSize-2, nDstYSize-2, adfDstGeoTransform,
&(map->projection),
nSrcXSize, nSrcYSize,adfInvSrcGeoTransform,
&(layer->projection),
&sSrcExtent, FALSE );
/* Reset this array to its original value! */
memcpy( adfDstGeoTransform, map->gt.geotransform, sizeof(double)*6 );
if (bSuccess) {
if (sSrcExtent.maxy > sOrigSrcExtent.maxy || sSrcExtent.miny < sOrigSrcExtent.miny) {
msDebug( "msTransformMapToSource(): extending bounds.\n");
sOrigSrcExtent.minx = 0;
sOrigSrcExtent.maxx = nSrcXSize;
if (sSrcExtent.maxy > sOrigSrcExtent.maxy)
sOrigSrcExtent.maxy = nSrcYSize;
if (sSrcExtent.miny < sOrigSrcExtent.miny)
sOrigSrcExtent.miny = 0;
}
}
memcpy( &sSrcExtent, &sOrigSrcExtent, sizeof(sOrigSrcExtent) );
bSuccess = TRUE;
}
}
/* -------------------------------------------------------------------- */
/* If the transformation failed, it is likely that we have such */
/* broad extents that the projection transformation failed at */

0 comments on commit 51ea1ee

Please sign in to comment.