[gdal-dev] When should OGRLayer::TestCapability be called?
warmerdam at pobox.com
Thu Mar 25 12:55:37 EDT 2010
Jason Roberts wrote:
> Dear OGR devs,
> OGRLayer::TestCapability allows you to determine if an OGRLayer supports
> various things, such as creating new features or updating or deleting
> existing features. Can you advise me whether there are any drivers for
> which the capabilities differ for a given layer depending on whether it
> is instantiated as an OGRLayer via OGRDataSource::GetLayer vs.
> OGRDataSource::ExecuteSQL? Also, whether the capabilities will change
> after OGRLayer::SetAttributeFilter or OGRLayer::SetSpatialFilter is
> called on the resulting OGRLayer instance?
The results of TestCapability() do differ for regular layers vs
ExecuteSQL layers and also vary depending on whether filters are in
place or not. So, the "answer" to TestCapability() can be quite
> In my scenario, I occasionally need to open layers using the equivalent
> of a SQL WHERE and/or ORDER BY clauses. WHERE can be achieved by either
> including the expression in a call to OGRDataSource::ExecuteSQL, or by
> calling OGRDataSource::GetLayer and then OGRLayer::SetAttributeFilter on
> the resulting instance. ORDER BY can be only achieved via
> OGRDataSource::ExecuteSQL (please correct me if I'm wrong here).
> Basically, I would like to know if the following approach is a robust
> way of checking capabilities:
> 1. Call OGRDataSource::GetLayer and then OGRLayer::TestCapability to
> determine what capabilities are supported for that layer.
> 2. Sometime later, call either OGRDataSource::ExecuteSQL or
> OGRDataSource::GetLayer again (possibly followed by
> OGRLayer::SetAttributeFilter and/or OGRLayer::SetSpatialFilter),
> depending on whether ORDER BY or WHERE are ultimately required for the
> specific situation.
> I would like to know if the capabilities that were tested in step #1
> will remain true in step #2, or if OGRLayer::TestCapability must be
> called after the final OGRLayer is instantiated and
> OGRLayer::SetAttributeFilter and/or OGRLayer::SetSpatialFilter have been
> called, just prior to accessing the features.
No, they will not.
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