[Gdal-dev] Layer Equality
Simon Perkins
sy at perkins.net
Thu Jul 19 13:21:47 EDT 2007
Thanks for that. I wasn't sure whether the FeatureDefn name was
guaranteed to be the same as the name used by GetLayerByName().
Is there any way of determining the index number of a Layer from the
OGRLayer?
Cheers,
Simon
Frank Warmerdam wrote:
> 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,
More information about the Gdal-dev
mailing list