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

Steve Lime steve.lime at dnr.state.mn.us
Tue Feb 19 10:22:10 EST 2002


Couple of things, this type of processing would have to be taken care of
in C, just too slow
to do elsewhere. Building a buffered polygon is not a trivial
excercise. I've been looking for
quite some time now for code to swipe. No luck so far. IF such a
function could be written
then I'd look at implementing it using something like a PROCESS block
within a layer, for 
example

  PROCESS
    REMOVE 5000 # remove islands less than 5000 sq meters
    BUFFER 10 # then create a 10 m buffer
  END

I'd look at this in a similar fashion to how projections work. You read
the data, then do something
to it before actually using it for rendering or query.
    
Queries do support polygons, either those defined on an ad hoc basis
(via a URL or scripting
environment - MAP|IMGSHAPEQUERY) or those defined in another layer
(FEATUREQUERY). These
bother have been around for some time now...

Steve


Stephen Lime
Data & Applications Manager

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> Stephen Woodbridge <woodbri at swoodbridge.com> 02/15/02 01:34PM >>>
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