Skip to content

Commit

Permalink
fix issue when querying reprojected rasters (#4403)
Browse files Browse the repository at this point in the history
change msRasterQueryByRectLow() to give pixel location results in layer SRS not map SRS
  • Loading branch information
embeepea authored and tbonfort committed Sep 29, 2012
1 parent 1903b7a commit 77dfc2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions maprasterquery.c
Expand Up @@ -546,7 +546,7 @@ msRasterQueryByRectLow(mapObj *map, layerObj *layer, GDALDatasetH hDS,
/* -------------------------------------------------------------------- */
for( iLine = 0; iLine < nWinYSize; iLine++ ) {
for( iPixel = 0; iPixel < nWinXSize; iPixel++ ) {
pointObj sPixelLocation;
pointObj sPixelLocation, sPixelLocationInLayerSRS;

if( rlinfo->query_results == rlinfo->query_result_hard_max )
break;
Expand All @@ -561,7 +561,10 @@ msRasterQueryByRectLow(mapObj *map, layerObj *layer, GDALDatasetH hDS,

/* If projections differ, convert this back into the map */
/* projection for distance testing, and comprison to the */
/* search shape. */
/* search shape. Save the original pixel location coordinates */
/* in sPixelLocationInLayerSRS, so that we can return those */
/* coordinates if we have a hit */
sPixelLocationInLayerSRS = sPixelLocation;
if( needReproject )
msProjectPoint( &(layer->projection), &(map->projection),
&sPixelLocation );
Expand Down Expand Up @@ -609,7 +612,8 @@ msRasterQueryByRectLow(mapObj *map, layerObj *layer, GDALDatasetH hDS,
}
}

msRasterQueryAddPixel( layer, &sPixelLocation,
msRasterQueryAddPixel( layer,
&sPixelLocationInLayerSRS, // return coords in layer SRS
pafRaster
+ (iLine*nWinXSize + iPixel) * nBandCount );
}
Expand Down
2 changes: 1 addition & 1 deletion msautotest
Submodule msautotest updated from f97a4a to 869601

0 comments on commit 77dfc2a

Please sign in to comment.