[mapserver-users] is this possible or does this need to be a feature request

Stephen Woodbridge woodbri at swoodbridge.com
Fri Feb 15 13:41:05 PST 2002


Oops, Ken points out a big oversight on my part, looks-like you can
ignore point 2 in my response as it looks like you can already do a
querybyshape that is a polygon.

Thanks, Ken.
  -Steve

kenboss wrote:
> 
> I can't speak to the buffering part (I will be interested to see what others
> have to say on that), but the polygon query part is already available in
> mapscript through the (either map or layer) queryByShape method.  A quick look
> at http://mapserver.gis.umn.edu/doc/cgi-reference.html seems to indicate that
> this should be possible in the cgi version as well, using MAPSHAPE or IMGSHAPE
> and with the NQUERY mode.
> 
> --Ken Boss
> 
> > Fred,
> >
> > Steve Lime may want to jump in on this to add or correct this.
> >
> > I see two issues here:
> >
> > 1) You have to construct and offset polygon (unless you are willing to
> > accept the rectangular extents of the polygon). This is pretty straight
> > forward:
> >   a) pick the first edge and determine which side is outside of the
> >      polygon
> >   b) construct an offset line on the outside of the first segment
> >   c) construct an offset line for each successive segment and intersect
> >      it with the previous segment and save the intersection point, you
> >      also have to check and handle concave angles where the offsets
> >      eliminate the edges totally.
> >   d) then build a new poygon form the intersection points.
> >
> > 2) currently (I believe) the query code ONLY works for points and
> > rectangles. Modifing query code to do queries of arbitrary polygons
> > would be possible but require some additional computations like:
> >   a) first check that the extents of the obj and the query polygon
> >      overlap.
> >   b) if point, see if it is inside the query polygon
> >      if line,  see if it intersects the query polygon
> >      if polygon, polyline, see if extents are all inside or the extents
> >         intersect with the query polygon
> >        if extents intersect see if any edge intersects with the query
> >           polygon
> >          if not, see if all vertices are inside the query polygon
> >
> > You could do all of this in mapscript, but might be very slow if you
> > have lots of polygons or the polygon have lots of points. Also you have
> > to be able to deal with multipart objects. There may be some code
> > already in mapserver that can be adapted to some parts of this as
> > rotated label extents represent 5 node convex polygons.
> >
> > Anyway, I hope this helps,
> >   -Steve Woodbridge
> >
> > Fred McDavid wrote:
> > >
> > > What I'm wanting to do is:
> > >
> > > take a polygon from one layer, using that polygon and some function (in
> > > this case, one that would add a "buffer" to the original polygon) come
> > > up with a new polygon, then draw that polygon and/or use it to query
> > > layers.
> > >
> > > I'm wondering if there is presently a way to do this and, if not, what
> > > obstacles (WRT design issues) would I face if I tried to make mapserver
> > > and/or php-mapscript do this?
> > >
> > > Regards,
> > >
> > > Fred



More information about the MapServer-users mailing list