[Mapserver-dev] Rect in polygon function

woodbri at swoodbridge.com woodbri at swoodbridge.com
Sat Feb 8 22:06:57 EST 2003


In addition step 2) can be done very fast using clipLine algorithm 
with the rectangle as the clipping box. I should think the mapserver 
already has this code somewhere. If you cycle through each line 
segment of the polygon and if any are inside the box or are clipped 
by the box then stop with a failure, if all are rejected as outside 
the box then you have containment.

If you need code for the clipLine algorithm, I have some that could 
easily be adapted.

-Steve W.

On 8 Feb 2003 at 19:59, woodbri at swoodbridge.com wrote:

> While I'm sure there are a bunch of ways to detect this, my first
> thought is to do it like this:
> 
> 1) check if any point is outside the polygon, 
>     if yes done
> 2) check if any rect edge intersects the polygon boundary, 
>     if yes done (there is a case where a polygon vertex lies on
>     an edge that you can treat is a none intersection)
> 3) else it is contained
> 
> -Steve W.
> 
> On 8 Feb 2003 at 17:29, Daniel Morissette wrote:
> 
> > Steve, all,
> > 
> > We are looking for a function that would tell us if a rectangle is
> > comprised completely inside a polygon, is such a function already
> > available in MapServer or anywhere else?  What we're trying to do is
> > find out if the current map view (a rectangle), is completely
> > contained inside a polygon that represents available raster
> > coverage. If the map view is completely contained inside the raster
> > coverage then we want to use a raster layer as the map, otherwise we
> > want to use vector data.  We want to avoid having both the raster
> > and vector layers showing up in the same map image, that's why we
> > need this function to test if the current map view is completely
> > contained inside the polygon defining the raster layer's coverage.
> > 
> > Thanks in advance for any help/pointers.
> > 
> > Daniel
> > -- 
> > ------------------------------------------------------------
> >  Daniel Morissette               morissette at dmsolutions.ca
> >  DM Solutions Group              http://www.dmsolutions.ca/
> > ------------------------------------------------------------
> > _______________________________________________
> > Mapserver-dev mailing list
> > Mapserver-dev at lists.gis.umn.edu
> > http://lists.gis.umn.edu/mailman/listinfo/mapserver-dev
> > 
> 
> 
> _______________________________________________
> Mapserver-dev mailing list
> Mapserver-dev at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-dev
> 





More information about the mapserver-dev mailing list