[postgis-devel] [PostGIS] #2089: liblwgeom cannot be used through python ctypes
PostGIS
trac at osgeo.org
Mon Nov 12 15:44:19 PST 2012
#2089: liblwgeom cannot be used through python ctypes
-------------------------+--------------------------------------------------
Reporter: brushtyler | Owner: strk
Type: enhancement | Status: new
Priority: medium | Milestone: PostGIS 2.1.0
Component: liblwgeom | Version: trunk
Keywords: |
-------------------------+--------------------------------------------------
Comment(by darkpanda):
After seeing this ticket I decided to see what it would take to write a
similar bit of code using ruby and its FFI extensions, which is basically
the equivalent of python's ctypes module. I ended up having to write a
small shim that implemented lwgeom_init_allocators and set up handlers for
errors and notices. The whole thing clocked in at around 40 lines of code
in C and the rest can be done in pure ruby at this point.
Perhaps what could be added on the lwgeom side is a set of functions that
allow you to set the pointers to lwalloc_var, lwrealloc_var, lwfree_var,
lwnotice_var and lwerror_var as necessary and have them point to the
defaults initially. This way you wouldn't need to implement
lwgeom_set_handlers directly but could set them via a initialization
function (or functions). GEOS does something similar to this with its
initGEOS function for setting its error and notice handlers, for instance.
I'll attach the shim I wrote for ruby at any rate as an example. Basically
I just load that in and let the ruby code do the rest via FFI.
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2089#comment:6>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-devel
mailing list