[postgis-devel] Moving some algorithms into liblwgeom

Sandro Santilli strk at keybit.net
Wed Nov 14 00:09:23 PST 2012


Hi J,
yes, there is interest in moving things to liblwgeom.

What you looked at was also already ticketed here:
http://trac.osgeo.org/postgis/ticket/1941

And, oh, there's also a patch already, which would need
a little action (see feedback).

--strk;

On Tue, Nov 13, 2012 at 03:18:40PM -0500, J Smith wrote:
> G'day list.
> 
> The recent talk about python and ctypes[1] has got me to thinking it
> would be pretty slick to be able to wrap python (or in my case, ruby)
> around liblwgeom and have access to the various algorithms available
> in liblwgeom. I have already written a ruby gem that wraps the
> functionality of GEOS in an FFI interface called ffi-geos[2] and I
> think it would be pretty sweet to also wrap liblwgeom in a similar
> manner. I had already begun the process of implementing some of the
> algorithms available in PostGIS such as ST_SnapToGrid in native ruby
> code using PostGIS as a guide, but it would be even nicer I think to
> wrap the actual PostGIS implementations themselves.
> 
> I took a look at the source for ST_SnapToGrid as an example and notice
> that the implementation of the various grid snapping functions are
> currently in the postgis directory and not actually a part of
> liblwgeom. I extracted the relevant functions from the postgis
> directory and put them into liblwgeom, replaced the calls to palloc,
> pfree, etc., elog, POSTGIS_DEBUG and so forth with their equivalent
> calls such as lwalloc, lwerror, LWDEBUG and the like and got the grid
> functions working in liblwgeom on their own. The PostGIS functions
> themselves reference them accordingly and everything seems to work
> fine (no regressions after a "make check" at least, and I notice that
> ST_SnapToGrid is used all over the place in the regression tests, so
> that's a good sign.)
> 
> I then wrote the necessary wrapper code in ruby for the gridspec
> struct and the calls to the lwgeom_grid and things look good -- I'm
> now able to call something like the following in ruby:
> 
> LWGeom::Geometry.new('POINT (10.10 20.20)').snap_to_grid(1)
> 
> And that's pretty cool.
> 
> The question is, would there be any interest in moving some these
> sorts of algorithms out of the postgis directory and into liblwgeom so
> they can be called directly from code linked to liblwgeom? I've only
> taken a look at the snap to grid code because it seemed to be a good
> starting point given how often it gets used in the regression tests,
> but I'd be interested in moving similar code into liblwgeom.
> 
> Thoughts or suggestions? Seems like it would be a cool project, and I
> like the idea of having access to PostGIS' spatial functions and
> algorithms in C from my ruby code. (And perhaps python and whatever
> else.)
> 
> Cheers
> 
> [1] - http://trac.osgeo.org/postgis/ticket/2089
> [2] - https://github.com/dark-panda/ffi-geos
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel

-- 

 http://www.cartodb.com - Map, analyze and build applications with your data

                                       ~~ http://strk.keybit.net 




More information about the postgis-devel mailing list