[Gdal-dev] Bugs in the bindings

Ari Jolma ari.jolma at tkk.fi
Mon Jun 26 16:27:19 EDT 2006


Frank Warmerdam kirjoitti:
> I've created new GDAL/OGR components for:
>  * PerlBindings - defaults to Ari
>  * PythonBindings - defaults to me.
>  * JavaBindings - defaults to me.
>  * RubyBindings - defaults to Charlie.

thanks, how about general bindings..?

>
>> Second, two bugs in ogr.i:
>>
>> - CreateGeometryFromWk?: it is not nice to silently return null in 
>> case of an
>> error, I'm going to use croak(OGRErrMessages(err)) in Perl bindings
>
> It would seem in general that an error should be produced on failure.

My problem is that the croak (even swig_croak) is probably a Perl-only 
solution, but I'll look into it more and post it as a bug -- that's an 
example of a general bindings bug or "undesirable feature".

>
>> - SetPoint: test wkb25DBit and call ..SetPoint _or_ ..SetPoint_2D
>
> I'm not too sure what you mean.  In the NG bindings I see:
>
>   %feature("kwargs") SetPoint;
>   void SetPoint(int point, double x, double y, double z=0) {
>     OGR_G_SetPoint(self, point, x, y, z);
>   }
>
> In the old bindings we have:
>
>
>     def SetPoint( self, i, x, y, z = 0):
>         return _gdal.OGR_G_SetPoint( self._o, i, x, y, z )
>
>     def SetPoint_2D( self, i, x, y):
>         return _gdal.OGR_G_SetPoint_2D( self._o, i, x, y )
>
> What would you be doing the wkb25DBit check on in the new bindings?  I
> suspect we ought to offer two methods, a SetPoint() method which is
> implicitly 3D and SetPoint_2D() which is 2D.
>
> It would be nicer if we could have distinct versions of SetPoint()
> for two arguments and three, but I don't imagine that is safe for
> us to do.

I was/am a bit confused with this. At least two things should be done I 
think:

- from ogrpoint.cpp: setZ: "Setting a zero zIn value will make the point 
2D", but ogr_geometry.h: "setZ( double zIn ) { z = zIn; 
nCoordDimension=3; }", i.e., no test for the zIn == 0 case? I think the 
docs should be changed?

- In the bindings there is no method "setCoordinateDimension", but one 
is needed.

I believe I'll manage with the set/get CoordinateDimension methods, 
which I'll call as appropriate in the new Perl bindings mostly after 
SetPoint, depending on whether the input contains value for z or not.

BTW, my plans for the classes in Geo::GDAL namespace have escalated a 
bit (after reading Sean's and Charlie's posts on geos-devel). For 
example I intend to introduce Geo::GDAL::Point etc. classes and leave 
the Geometry class, whihc swig bindings provide, as a virtual class (not 
to instantiated by users).

Regards,

Ari

>
> Best regards,


-- 
Prof. Ari Jolma
Kartografia ja Geoinformatiikka / Cartography and Geoinformatics
Teknillinen Korkeakoulu / Helsinki University of Technology
POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma




More information about the Gdal-dev mailing list