@@ -1206,6 +1206,7 @@ static int msTransformMapToSource( int nDstXSize, int nDstYSize,
1206
1206
double dfYMinOut = 0.0 ;
1207
1207
double dfXMaxOut = 0.0 ;
1208
1208
double dfYMaxOut = 0.0 ;
1209
+ const double dfHalfRes = adfDstGeoTransform [1 ] / 2 ;
1209
1210
1210
1211
/* Find out average y coordinate in src projection */
1211
1212
for ( i = 0 ; i < nSamples ; i ++ ) {
@@ -1255,7 +1256,7 @@ static int msTransformMapToSource( int nDstXSize, int nDstYSize,
1255
1256
msReleaseLock ( TLOCK_PROJ );
1256
1257
#endif
1257
1258
1258
- if ( x2 [0 ] >= dfXMinOut && x2 [0 ] <= dfXMaxOut &&
1259
+ if ( x2 [0 ] >= dfXMinOut - dfHalfRes && x2 [0 ] <= dfXMaxOut + dfHalfRes &&
1259
1260
y2 [0 ] >= dfYMinOut && y2 [0 ] <= dfYMaxOut )
1260
1261
{
1261
1262
double x_out = adfInvSrcGeoTransform [0 ]
@@ -1265,8 +1266,8 @@ static int msTransformMapToSource( int nDstXSize, int nDstYSize,
1265
1266
+ (dfLonWrap - 180 )* adfInvSrcGeoTransform [4 ]
1266
1267
+ dfY * adfInvSrcGeoTransform [5 ];
1267
1268
1268
- /* Does the raster cover a whole 360 deg range ? */
1269
- if ( nSrcXSize == (int )(adfInvSrcGeoTransform [1 ] * 360 + 0.5 ) )
1269
+ /* Does the raster cover, at least, a whole 360 deg range ? */
1270
+ if ( nSrcXSize >= (int )(adfInvSrcGeoTransform [1 ] * 360 ) )
1270
1271
{
1271
1272
psSrcExtent -> minx = 0 ;
1272
1273
psSrcExtent -> maxx = nSrcXSize ;
@@ -1280,8 +1281,8 @@ static int msTransformMapToSource( int nDstXSize, int nDstYSize,
1280
1281
psSrcExtent -> maxy = MS_MAX (psSrcExtent -> maxy , y_out );
1281
1282
}
1282
1283
1283
- if ( x2 [1 ] >= dfXMinOut && x2 [1 ] <= dfXMaxOut &&
1284
- x2 [1 ] >= dfYMinOut && y2 [1 ] <= dfYMaxOut )
1284
+ if ( x2 [1 ] >= dfXMinOut - dfHalfRes && x2 [1 ] <= dfXMaxOut + dfHalfRes &&
1285
+ y2 [1 ] >= dfYMinOut && y2 [1 ] <= dfYMaxOut )
1285
1286
{
1286
1287
double x_out = adfInvSrcGeoTransform [0 ]
1287
1288
+ (dfLonWrap + 180 )* adfInvSrcGeoTransform [1 ]
@@ -1290,8 +1291,8 @@ static int msTransformMapToSource( int nDstXSize, int nDstYSize,
1290
1291
+ (dfLonWrap + 180 )* adfInvSrcGeoTransform [4 ]
1291
1292
+ dfY * adfInvSrcGeoTransform [5 ];
1292
1293
1293
- /* Does the raster cover a whole 360 deg range ? */
1294
- if ( nSrcXSize == (int )(adfInvSrcGeoTransform [1 ] * 360 + 0.5 ) )
1294
+ /* Does the raster cover, at least, a whole 360 deg range ? */
1295
+ if ( nSrcXSize >= (int )(adfInvSrcGeoTransform [1 ] * 360 ) )
1295
1296
{
1296
1297
psSrcExtent -> minx = 0 ;
1297
1298
psSrcExtent -> maxx = nSrcXSize ;
0 commit comments