[gdal-dev] When should OGRLayer::TestCapability be called?

Jason Roberts jason.roberts at duke.edu
Thu Mar 25 11:48:21 EDT 2010


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?

                                                                        

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.

 

(As a side issue, I realize that the approach above is imperfect in other
aspects, e.g. it is not optimal, and another thread could conceivably change
the layer between step #1 and #2, but I'm not concerned about those issues
in my scenario and would like to use this approach for various reasons.
Thus, suggestions for how I can moot my question by changing my approach
will not work for me.)

 

Thanks for your help with this esoteric question,

 

Jason

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100325/48c6de82/attachment.html


More information about the gdal-dev mailing list