[ka-Map-users] Interesting Problem for precaching

Daniel Morissette dmorissette at mapgears.com
Tue Jul 4 11:37:17 EDT 2006


Stephen Woodbridge wrote:
> 
> Any thoughts on how we might be able to do this?
> Is there a way to get mapscript to return a flag like:
> 
>    $img = $oMap->draw();
>    if ($img->didDrawObjects()) {
>       // split the meta tile
>    } else {
>       // mark the metatile as empty
>    }
> 
> such it would return ture/false if it draws any objects.
> 

No. There is currently no way in MapServer to know if any shapes were 
drawn in a given map. A way to implement this could be to carry a 
counter of number of shapes drawn at the class level (e.g. 
$class->numShapesDrawn or $clas->numhits), and then provide methods at 
the layer and map level to compute the total for a given layer or the 
whole map  (e.g. $layer->getNumShapesDrawn()). This would also allow for 
things like showing only visible classes in a legend, but as was raised 
in a previous discussion on this topic, the contents of the legend would 
be valid only if it is generated after rendering the map so the value of 
this feature is arguable.

Note that even with such a counter you may not get the results that you 
expected in your case since water areas such as Hudson's Bay overlap 
with the MBR of the country outline (polygon) that you are likely 
drawing in your map, so even if you don't see any land, the bay itself 
overlaps with the land polygon and I believe MapServer attempts to draw 
it anyway even if it doesn't generate any pixel on the map image. The 
same may be true of most areas on the shore of a continent that fall 
within the MBR of the continent's polygon in the projection of your map.

I think the real solution is a smart precache script that hits only the 
areas that are expected to have data.

Daniel
-- 
Daniel Morissette
http://www.mapgears.com/


More information about the ka-Map-users mailing list