[gdal-dev] PGeo TestCapability always returns FALSE
Frank Warmerdam
warmerdam at pobox.com
Wed Oct 8 15:57:58 EDT 2008
Todd.Southen at bentley.com wrote:
> Hi all,
>
> In my application, I'm calling layer->TestCapability(OLCRandomRead)
> before calling layer->GetFeature(fid). When I try this with a PGeo
> datasource, TestCapability always returns FALSE.
>
> Looking at the OGRPGeoLayer code this indeed seems to be the case:
>
> int OGRPGeoLayer::TestCapability( const char * pszCap )
> {
> if( EQUAL(pszCap,OLCRandomRead) )
> return FALSE;
>
> else if( EQUAL(pszCap,OLCFastFeatureCount) )
> return FALSE;
>
> else if( EQUAL(pszCap,OLCFastSpatialFilter) )
> return FALSE;
>
> else if( EQUAL(pszCap,OLCTransactions) )
> return FALSE;
>
> else
> return FALSE;
> }
>
> Is this a bug?
>
> Should I be calling TestCapability before calling GetFeature?
> GetFeature seems to work for the PGeo datasource even though
> TestCapability is returning FALSE.
Todd,
Contrary to the documentation at:
http://www.gdal.org/ogr/classOGRLayer.html#eedbda1a62f9b89b8e5f24332cf22286
it appears that OGRLayer::GetFeature() always works. But for drivers
without a custom implementation it is slow because it just uses
ResetReading(), and GetNextFeature() to search for the corresponding
feature. So I will adjust the documentation to indicate that the
OLCRandomRead test really means "does this layer support optimized
reading by feature id".
The second issue is whether the various flags are true. Note that there
are two classes derived from OGRPGeoLayer. One for direct access to
tables, and one for results from ExecuteSQL().
The OGRPGeoTableLayer class returns TRUE for OCLSequentialWrite,
OCLRandomWrite and OCLCreateField. Howeever, it returns the default
for everything else even though it *ought* to TRUE for OLCRandomRead,
OLCFastFeatureCount and OLCFastSpatialFilter.
I have created a ticket on this issue. I would encourage you to add
yourself as a cc: so you will be notified when it is fixed. I'll try to
get this in today for the 1.5.3 release.
http://trac.osgeo.org/gdal/ticket/2601
I would add that in general the OGR drivers tend to be sloppy about
returning the proper testcapability values which significantly undermines
the utility of the method. I encourage anyone noting inconsistencies to
file tickets so we can fix things up.
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