[gdal-dev] getting the Layer id or index from a Feature object

Even Rouault even.rouault at spatialys.com
Sun Aug 24 08:46:45 PDT 2014


Le dimanche 24 août 2014 15:24:55, mccorb a écrit :
> Is there anything in the Feature object which contains the layer id/index
> which it is in?
> 
> I was thinking I could carry around the Feature and then when I wanted to
> update any of the geometry or FielfDefn items I could just call
> setField/unsetField but it appears I need to also call
> Layer.setFeature(...) to actually save it back to the file after I modify
> the feature.
> 
> Anyway, I just need to know if I need to carry the layer id along
> everywhere or I can get it from the Feature instance. I am using Java API
> if that makes any difference.

There's no direct way of retrieving the Layer. But you can iterate over layers 
and test feature.GetDefnRef().equals(layer.GetLayerDefn())

> 
> Thanks.
> 
> 
> 
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/getting-the-Layer-id-or-index-from-a-F
> eature-object-tp5158041.html Sent from the GDAL - Dev mailing list archive
> at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list