[gdal-dev] Layers and features

Tim Keitt tkeitt at utexas.edu
Wed Feb 26 14:15:18 PST 2014


On Wed, Feb 26, 2014 at 3:02 PM, Even Rouault
<even.rouault at mines-paris.org>wrote:

> Tim,
>
> > When I extract a feature from a layer, what issues arise with the
> lifetime
> > of the feature and the layer? If I keep the layer alive, will the feature
> > continue to be valid?
>
> Yes, feature objects (at least at C++ objects, not speaking about bindings)
> retrieved by GetNextFeature() and GetFeature() are completely
> free-standing.
> You can close the datasource and they should still be valid (reason: they
> keep
> a reference to their feature definition object, and once the last feature
> has
> been destroyed and the datasource closed, the feature definition will be
> destroyed)
>

OK. That was not clear.


>
> >
> > If I clone a feature, is it now standalone or does it still depend on the
> > layer/datasource in anyway?
>
> No, and you don't need to clone it actually. See above
>

Ah. OK. That will simplify my code a bit.

I assume this is not true of the return from OGR_F_GetGeometryRef, which
needs to be cloned or it can become invalid.


>
> >
> > I see the note about destroying features prior to deleting the layer but
> > need a bit of clarification on the dependencies.
>
> Are you refering to "It is critical that
>  all features associated with an OGRLayer (more specifically an
>  OGRFeatureDefn) be deleted before that layer/datasource is deleted." ?
> Well, I think the note is wrong actually. Perhaps it dates back to old ages
> where the feature definition was not yet ref-counted ??
>

Yes, that was the bit that had me concerned.

THK


>
> Best regards,
>
> Even
>
> --
> Geospatial professional services
> http://even.rouault.free.fr/services.html
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
http://www.keittlab.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20140226/512fbfc6/attachment.html>


More information about the gdal-dev mailing list