[Gdal-dev] Re: A list of things in the wrappers and geom type in ogr

Kevin Ruland kruland at ku.edu
Tue Oct 11 10:42:26 EDT 2005


Hi guys,

There are some wierd ones:

Layer.GetExtent()
CreateGeometryFromWkb()
CreateGeometryFromWkt()
Geometry.ExportToWkt()

These methods had previously been defined to return something other than
OGRErr.

Layer.GetExtent() used an argout to return the real value.  This method
wraps just fine in python because of the way lists would be returned.

CreateGeometryFromWkb() and CreateGeometryFromWkt() both return
%newobject OGRGeometryShadow*.  I have coded them to return NULL if an
error occurred.  This is most definitely wrong for the error should be
converted into an exception.  I am uncertain right now how to handle
this.  There are two solutions I can think of:  Either recode them to be
like this:

OGRErr CreateGeometryFromWkb( int len, char *bin_string,
OSRSpatialReferenceShadow* reference, OGRGeometryShadow** argout)

Then code a special %typemap(argout) OGRGeometryShadow* which manually
does the newobject.  Or like this:

OGRGeometryShadow *CreateGeometryFromWkb( int len, char *bin_string,
OSRSpatialReferenceShadow* reference)

And code a %typemap(out) OGRGeometryShadow* which traps the NULL and
issues an exception.

Geometry.ExportToWkt() had a returned char const *.  I have changed this to:

OGRErr ExportToWkt( char **argout)

And because of python's argout handling, this comes out fine in python.

We need to discuss the handling of the two creation methods soon.

Kevin

Charles F. I. Savage wrote:

>
>> 1)  Ari pointed out a serious flaw in ogr.i SetGeometry.  None of the
>> functions should have an explicit throw in them.  There are of course
>> ways to wrap a "throw" but we don't really want to go there.  Instead
>> this method should be fixed and we should just use the OGRErr
>> typemap.  I've committed the fix
>
> Kevin, I noticed that there were other methods in OGR that also had
> this issue.  Just do a search on throw.
>
> Charlie




More information about the Gdal-dev mailing list