[geos-devel] GEOS Swig Patch - New support for Ruby

Charlie Savage cfis at interserv.com
Thu Dec 15 13:24:11 EST 2005


Hi everyone,

I have just provided a patch to strk that updates the GEOS swig 
bindings.  I have not included it below, because it is quite large due 
to the inclusion of SWIG generated wrapper files.

What the patch does:

* adds a swig/ruby directory - this includes bindings for the Ruby 
language plus a port of example.cpp

* significantly modifies swig/geos.i.  Language specific functionality, 
such as renaming methods and classes, was taken out and moved to 
language specific files (python.i for python, ruby.i for ruby)

* Adds typemaps to support istreams and ostreams - this makes methods 
like WKBReader.printHex and WKBWriter.write accessible now to scripting 
languages

* A few other bug fixes like keyword conflicts in Python (the print keyword)


What needs work:

* As always, the key issues with SWIG bindings is memory management.  
Right now the bindings assume that any time one of the following 3 types 
is passed in as a parameter to a method, then the method's class takes 
over ownernship of the parameter:

geos::CoordinateSequence *
geos::LinearRing *
std::vector<geos::Geometry * > *

I'd guess this is not true.  If someone who is more familiar with the 
GEOS C++ api could let me know, I can fix this

Similarly, a brief look through the GEOS api shows some methods return 
new objects.  SWIG must be told about these methods.  So once again, 
does someone have a list of these methods?

* The example.py and example.rb files crash when trying any of the 
combination methods (union, intersection, etc.).  My guess it has to do 
with the memory management item listed above.  

* The bindings compile against the C++ api, not the C api.  This could 
be changed, but would require a significant amount of work.

Hope people find this useful.

Thanks,

Charlie


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2781 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.osgeo.org/pipermail/geos-devel/attachments/20051215/331c6a71/smime.bin


More information about the geos-devel mailing list