On Jan 26, 2010, at 1:37 PM, Oliver Tonnhofer wrote:

> Hi,
>
> It seems the CAPI version is really unreliable for feature checks.
> Functions like GEOSFree[1] and GEOSProject[2] where added without
> incrementing the CAPI version. I think we should extend the checks to
> the GEOS and not only the CAPI version.
>
> Another problem that arises: What do we do with functions/classes that
> require a specific version?
> I would suggest adding a decorator that rises an exception when a
> function that depends on a higher GEOS version is called. Any ideas?
>
>
> Regards,
> Oliver
>
> [1] http://trac.gispython.org/lab/ticket/198
> [2] http://trac.gispython.org/lab/ticket/202

In Shapely's architecture (at the risk of using too strong a word), we  
have a base geometry class (shapely.geometry.base.BaseGeometry) that  
provides the methods such as buffer, intersection, &c, and it  
delegates to a module level proxy for the libgeos_c DLL (an instance  
of shapely.geos.LGEOS14/15/16). The base geometry provides all  
methods, supported or not, and the proxy raises exceptions when the  
requested feature is not found in the DLL. That exception is currently  
an AttributeError, and that's not even the most helpful exception.  
NotImplementedError may be an improvement.

We could version the base class as well. The advantage being that  
versioned classes wouldn't advertise methods that aren't implemented  
and you could test capabilities with hasattr(). The disadvantage is  
more code to maintain and potential for surprises when the base class  
of our geometries isn't determined until run time. I was planning to  
save those surprises for version 2.0 ;)

I could be persuaded that the new project and interpolate methods be  
decorated to raise NotImplementedError if there's no support in the  
proxy. But that doesn't help the case where one wants to test with  
hasattr(). I suppose we remove unsupported methods from the base  
class's __dict__ at runtime (at the end of base.py). Any of these  
approaches appeal to you?

--
Sean

_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to