Problems with tiled raster layers
We've found problems when using tiled raster layers from MapScript: the map
rendering was aborted when a given tiled raster layer was used. This was not
noticeable with shp2img which would silently exit, but MapScript would have a
problem since the map->draw() call would return an error.
The problem is in msDrawRasterLayerLow(), in the code that handles tile indexes.
The possibility of msLayerWhichShapes() returning MS_DONE was not handled and
was treated as a failure.
A few other issues were noted:
- The code that cleaned up the temporary tile layer was using an
if(tileitemindex == -1). I believe it should be if(tilelayerindex == -1)
so I changed it.
- There was a TODO note about cleaning up when msLayerWhichShapes() didn't
return at least one tile... I added the same cleanup as was found at the end of
the function, hopefully that does it.
- The function used to return(0) on success. I fixed it to return(MS_SUCCESS)
as it should (MS_SUCCESS==0, but it's still better to explicitly use it).
The diff with the 4.3 CVS is attached below. Can you please review it and
confirm that all is ok so that I can apply it to the 4.2 branch. This is an
important issue for users of tiled rasters in 4.2.
===================================================================
RCS file: /data2/cvsroot/mapserver/mapraster.c,v
retrieving revision 1.117
diff -u -r1.117 mapraster.c
--- mapraster.c 1 Jun 2004 14:33:43 -0000 1.117
+++ mapraster.c 15 Jun 2004 15:56:43 -0000
@@ -1317,7 +1317,17 @@
if((map->projection.numargs > 0) && (layer->projection.numargs > 0))
msProjectRect(&map->projection, &layer->projection, &searchrect);
#endif
status = msLayerWhichShapes(tlp, searchrect);
- if(status != MS_SUCCESS) return(MS_FAILURE); // TODO: probably need more
clean up here
+ if (status != MS_SUCCESS) {
+ // Can be either MS_DONE or MS_FAILURE
+ msLayerClose(tlp);
+ if(tilelayerindex == -1) {
+ freeLayer(tlp); // cleanup temporary tile layer
+ free(tlp);
+ }
+ if (status == MS_DONE)
+ return MS_SUCCESS;
+ return MS_FAILURE;
+ }
}
done = MS_FALSE;
@@ -1508,13 +1518,13 @@
if(layer->tileindex) { // tiling clean-up
msLayerClose(tlp);
- if(tileitemindex == -1) {
+ if(tilelayerindex == -1) {
freeLayer(tlp);
free(tlp);
}
}
- return 0;
+ return MS_SUCCESS;
}