[Gdal-dev] GetGeometryRef in scripts

Frank Warmerdam warmerdam at pobox.com
Wed Sep 21 09:50:16 EDT 2005


On 9/21/05, Ari Jolma <ari.jolma at tkk.fi> wrote:
> Am I missing something? Isn't this all about objects, references to
> objects and their containers? And the about when an object or container
> is really destroyed. There aren't that many possible cases and it
> shouldn't be impossible to look at each case and decide what happens.
> And, is there a difference between an object and a container? A
> container is just an object which owns another object?

Ari,

You express some desirable rules (such as if you hold a reference
to a member of a container and the container is destroyed, the member
should be copied to keep the reference valid) but I just feel that these
rules are not practical to support because the underlying OGR
objects provide no help.

For instance, OGRFeatureDefn, OGRSpatialReference and
OGRDataSource are all referenced counted in C++.  So we can
ensure that any direct scripting variable referencing them takes
a reference.  However OGRLayer, and OGRGeometry are not
reference counted, and it is very difficult to give them full
object semantics as you wish.

Charlie says:
> There is no such link and thus this would require either an extensive
> rewrite of OGR or a whole lot of complicated code in the SWIG binding.
> And in the end, I don't see what you gain from it but slower code
> because I think there will be edge cases where you can subvert this
> layer and get in trouble.  Better to keep things simpler.

I agree with this.  Attempt to build huge amounts of reference
holding logic into the swig interface is likely to make things so
complicated that I am unable to touch the swig stuff anymore.
Better to keep things simple and understandable.

I realize this leaves scripters in the position of having to follow
some conventions and risk crashes if they don't.  This is
unfortunate and indicates an imperfect packaging but it is really
because the underlying library was not designed for the kind of
use you wish.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list