[mapserver-dev] [mapserver-users] Detect featureless areas

Stephen Woodbridge woodbri at swoodbridge.com
Fri Oct 5 17:59:36 PDT 2012

On 10/5/2012 6:31 PM, Ian Walberg wrote:
> Hello list,
> We need to be able to detect when there are no features on a map and
> limit the extent so that the user does not zoom in any further if there
> is nothing to see.
> This could be for example no labels or no vector data for the given extent.
> We are using php mapscript .
> Any ideas how we can do this?

Well on the one hand why do you care? Does this cause a problem in some 
way? If the user wants to do something useless and stupid, then let him. 
I would limit zooming based on scale or resolution.

The above would be my approach, but if you really want to do this, one 
way to do this would be to setup the mapfile to do a query and then 
query the layers you want to check for features based on the bbox of the 
view and then check if you got any hits. But this can be potentially 
much more expensive then drawing nothing in the case above.

It has been a while since I have used mapscript, but their might be a 
return code that tells you if the layer drew anything (if not you might 
want to write a ticket to add that.

You proposed method has the problem of scale dependencies, in the you 
might have a situation where a some scale there is very little turned on 
and it you stop zooming there, then you can never get to the scale where 
other things get turned on. What you draw on any given scale is not 
predictive of what you might draw at some other scale.

Think of a small island that is turned off because it is very small 
until you get zoomed in. If you pan over the ocean to the vicinity of 
the island and it is off, you would prevent zooming in to the point that 
the it got turned on.

I would keep is simple, I think it will work better in the long run.

-Steve W

More information about the mapserver-dev mailing list