[mapserver-users] PHP MapScript - Selecting Polygons by Buffer

Hankley, Chip Chip.Hankley at GASAI.Com
Wed Oct 3 13:47:45 PDT 2001


I'm having trouble writing a function that selects the polygons surrounding
another polygon. For instance, the user selects a given polygon and then
requests MS to display all polygons within 2 miles.

Has anyone done this... willing to share their code?

Here's my pseudo-code:

function buff_list($map, $ID, $dist) {

  //Get the ShapeObj of the polygon that has an attribute of $ID

  //Get the bounding box of the shape

  //Increase the bounding box coordinates by $dist (i.e. xmin - $dist, 
  //  ymin - $dist, xmax + $dist, ymax + $dist)

 //Use the increased bounding box to create a new RectObj

 //QueryByRect to return the new records

}

I can't figure out how to get past the first step - I was trying 

  $Layer->queryByAttributes(MS_SINGLE);

but this returned a "Fatal error: Object has an invalid '_map_handle_'
property in c:\..." This could be more of the bug that Daniel reported the
other day regarding the way PHP was handling  objects internally (I'm still
using a pre-Sept 13 dll).

Also, my approach is the most rudimentary in that it will really only give
decent results on polygons that resemble rectangles.

Seems like somebody would have done this in MapScript...Help would be much
appreciated.


Chip Hankley



More information about the MapServer-users mailing list