Skip to content

Commit

Permalink
OAPIF: avoid TestCapability(OLCFastFeatureCount) to cause a network a…
Browse files Browse the repository at this point in the history
…ccess, as well as SetAttributeFilter(NULL)
  • Loading branch information
rouault committed Oct 7, 2019
1 parent de3e736 commit 503585c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion autotest/ogr/ogr_oapif.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,9 @@ def test_ogr_opaif_get_feature_count_from_numberMatched():
{'Content-Type': 'application/geo+json'},
'{ "type": "FeatureCollection", "features": [], "numberMatched": 1234 }')
with webserver.install_http_handler(handler):
assert lyr.TestCapability(ogr.OLCFastFeatureCount) == 1
assert lyr.TestCapability(ogr.OLCFastFeatureCount) == 0 # Cannot know yet
assert lyr.GetFeatureCount() == 1234
assert lyr.TestCapability(ogr.OLCFastFeatureCount) == 1


###############################################################################
Expand All @@ -674,6 +675,7 @@ def test_ogr_opaif_attribute_filter():
with webserver.install_http_handler(handler):
ds = ogr.Open('OAPIF:http://localhost:%d/oapif' % gdaltest.webserver_port)
lyr = ds.GetLayer(0)
lyr.SetAttributeFilter(None) # should not cause network request

handler = webserver.SequentialHandler()
handler.add('GET', '/oapif/collections/foo/items?limit=10', 200,
Expand Down
4 changes: 3 additions & 1 deletion gdal/ogr/ogrsf_frmts/wfs/ogroapifdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,9 @@ void OGROAPIFLayer::GetQueriableAttributes()
OGRErr OGROAPIFLayer::SetAttributeFilter( const char *pszQuery )

{
if( m_poAttrQuery == nullptr && pszQuery == nullptr )
return OGRERR_NONE;

if( !m_bFeatureDefnEstablished )
EstablishFeatureDefn();

Expand Down Expand Up @@ -1669,7 +1672,6 @@ int OGROAPIFLayer::TestCapability(const char* pszCap)
{
if( EQUAL(pszCap, OLCFastFeatureCount) )
{
GetLayerDefn();
return m_nTotalFeatureCount >= 0 &&
m_poFilterGeom == nullptr && m_poAttrQuery == nullptr;
}
Expand Down

0 comments on commit 503585c

Please sign in to comment.