point within polygon

Steve Lime steve.lime at DNR.STATE.MN.US
Mon Aug 22 12:41:16 PDT 2005


MapServer has that capability within MapScript. shapeObj's have a contains method
that will tell you if a point is contained in a polygon. E.g.:

  $status = $polygon->contains($point);

The behaviour of the MapServer point-in-polygon algorithm is indeterminent if the point
lies exactly on the edge of the polygon. The return value is consistent though. I guess the
point is that contains really means contains.

Steve

>>> Dylan Beaudette <dylan at IICI.NO-IP.ORG> 08/22/05 1:59 PM >>>
Greetings,

I am currently looking for a way to test if a point is within a polygon, 
without using PostGIS. The first method I have tried, and which works but not 
well, is with a simple comparison within MySQL:

point at x,y

polygon extent: min_x,min_y,max_x,max_y

if x >= min_x and x <= max_x and y >= min_y and y <= max_y then OK

however, most of my polygons are not rectangular, and thus many point may 
seemingly be in multiple polygons when rectangular extents overlap...

is there a better way to do this within mapserver, or phpmapscript?

or is there a postGIS-like patch for MySQL ? 

thanks in advance!


-- 
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341



More information about the MapServer-users mailing list