MapServer / MapServer-import

3 stars 2 forks source link

Make shapeObj.add() accept pointObj's too, not just lineObj. #1202

Open tbonfort opened 12 years ago

tbonfort commented 12 years ago

Reporter: tylermitchell@shaw.ca Date: 2005/02/02 - 06:13

shapeObj.add() only accepts lineObj, make it accept pointObj too.

This limitation threw me into a loop of confusion.  How do I add points into a
shapeObj?  Then I found that the process of adding my _single_ point to a
lineObj, and then adding it to shapeObj worked.  That was a pretty round about
way of doing things and will be confusing for other newbies, I'm sure.  

I would like to share some code on doing this with my readers, but will have to
also include a warning of this non-intuitive work-flow.  I'd love it if it were
modified or an shapeObj.addPoint method were created.

Tyler
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2005/02/02 - 17:10

Tyler, we can't have polymorphic arguments for mapscript.  SWIG won't support it.

As for the lines and points, this is just how a shapeObj is.  It is a collection
of lines and lines are collections of points.  The better way, IMO, to satisfy
your request is to extend pointObj with a "toShape" method that promotes a point
to a shapeObj.  The calls could be chained up simply like:

    so = pointObj(x, y).toShape()   # returns a shapeObj

I'm sorta running out of steam on adding new features to mapscript, but this
is a natural.