# [Mapserver-dev] Rect in polygon function

Ed McNierney ed at topozone.com
Sat Feb 8 20:22:18 EST 2003

```Daniel -

In addition, if you know that the polygon is convex, you can just look
to see if all four corners of the rectangle are inside it.

- Ed

-----Original Message-----
From: woodbri at swoodbridge.com [mailto:woodbri at swoodbridge.com]
Sent: Saturday, February 08, 2003 7:59 PM
To: Stephen Lime; mapserver-dev; Daniel Morissette
Subject: Re: [Mapserver-dev] Rect in polygon function

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

```