[Gdal-dev] Layer Equality
Frank Warmerdam
warmerdam at pobox.com
Thu Jul 19 13:06:44 EDT 2007
Simon Perkins wrote:
> Hi,
>
> I'm trying to do something that on the face of it should be fairly
> straightforward, but I can't quite see how to do it in the best way.
> Basically, I have an open OGRLayer, and I'd like to see if this OGRLayer
> is the same as another layer in the same OGRDataSource, which I only
> know by name. Ultimately, if the named layer already exists, I'd like to
> delete it and replace it with the contents of the OGRLayer. Unless, that
> named layer is actually the same layer as the existing OGRLayer, in
> whcih case nothing needs to happen. The question is, how can I check for
> this? I know the index number of the existing OGRLayer, but I'm not sure
> I see how to determine the index number of the named layer to see if
> they are the same. Similarly, I'm not sure how to get the name of the
> existing OGRLayer to use that as a comparison. Any ideas?
Simon,
Somewhat obtusely, the only way to get the name of a layer is to look in
the OGRFeatureDefn associated with it. So in ogrinfo this is done as:
printf( "%d: %s",
iLayer+1,
poLayer->GetLayerDefn()->GetName() );
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 | President OSGeo, http://osgeo.org
More information about the Gdal-dev
mailing list