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

Stephen Woodbridge woodbri at swoodbridge.com
Sat Oct 6 14:42:59 PDT 2012


On 10/6/2012 4:33 PM, Ian Walberg wrote:
> Stephen,
>
> For an application that a user is zooming in I tend to agree I would not
> care.
>
> In our case we are displaying a rotating sequence of maps and want to
> work out a way of not showing an image with an empty map on it.

Well you might be able to do something along the lines of checking the 
image size. I bet that if the image is below some threshold for a given 
image size, that it has very little if any content in it. For an 8 bit 
png image that is a 256x256 tile an empty tile is 103 bytes and most of 
that is the header and the color lookup table.

I think if you sample you images that you will find that all the images 
that are empty are easy to detect by size.

The tricky part to giving you a better answer is that you have not 
defined "empty". If you mean a N x M image of one constant color, then 
the above should work fine for your needs.

-Steve W

> Thanks
>
> Ian
>
> -----Original Message-----
> From: Stephen Woodbridge [mailto:woodbri at swoodbridge.com]
> Sent: Friday, October 05, 2012 6:00 PM
> To: Ian Walberg
> Cc: mapserver-users at lists.osgeo.org; mapserver-dev at lists.osgeo.org
> Subject: Re: [mapserver-users] Detect featureless areas
>
> 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