[geos-devel] Adding STRtree and PreparedGeometry support to SWIG

Schuyler Erle schuyler at nocat.net
Mon Jul 13 01:55:51 EDT 2009

Howdy, folks. I've created tickets in GEOS Trac for three patches I
created to implement STRtree and PreparedGeometry in the SWIG bindings,
with the gracious financial support of FortiusOne's GeoCommons.

The first patch adds an iterate() method to AbstractSTRTree to permit
iterating (via the visitor pattern) over all items that have been
inserted into the tree, regardless of bounds. Currently, there is no
public method for accessing inserted items in an STRtree without having
to first build the tree (thus preventing insertion of further items). I
implemented this method in order to be able to store Ruby objects in the
the STRtree, thanks to Ruby's mark-and-sweep garbage collector.


The second patch adds the STRtree class to the C API. The ItemVisitor
class is subclassed to allow calling GEOSSTRtree_query() from C with a
callback function pointer and a (void *) accumulator.


The third patch adds STRtree and PreparedGeometry support to the SWIG
bindings. Also included are some niceties for the Ruby bindings, to
handle the aforementioned GC marking, and to permit Ruby code blocks to
be wrapped as ItemVisitor callbacks.


It took me quite a bit of time and effort to get my head around the way
GEOS is designed in order to get these patches implemented, so I'm keen
to do what's needed to get them into SVN. I welcome any feedback anyone
has to offer. Thanks very much!


More information about the geos-devel mailing list