Skip to content

Commit

Permalink
Merge pull request #44013 from qgis/backport-43990-to-queued_ltr_back…
Browse files Browse the repository at this point in the history
…ports

[Backport queued_ltr_backports] [OAPIF provider] Fix extra query parameters (fixes #43905)
  • Loading branch information
rouault committed Jul 9, 2021
2 parents 3158eb9 + 42e4a56 commit a6fd43a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/providers/wfs/qgsoapifprovider.cpp
Expand Up @@ -690,10 +690,9 @@ void QgsOapifFeatureDownloaderImpl::run( bool serializeFeatures, int maxFeatures
}
}

url = mShared->appendExtraQueryParameters( url );

while ( !url.isEmpty() )
{
url = mShared->appendExtraQueryParameters( url );

if ( maxTotalFeatures > 0 && totalDownloadedFeatureCount >= maxTotalFeatures )
{
Expand Down Expand Up @@ -721,7 +720,6 @@ void QgsOapifFeatureDownloaderImpl::run( bool serializeFeatures, int maxFeatures
break;
}
url = itemsRequest.nextUrl();
url = mShared->appendExtraQueryParameters( url );

// Consider if we should display a progress dialog
// We can only do that if we know how many features will be downloaded
Expand Down
10 changes: 9 additions & 1 deletion tests/src/python/test_provider_oapif.py
Expand Up @@ -20,6 +20,7 @@

from osgeo import gdal
from qgis.PyQt.QtCore import QCoreApplication, Qt, QObject, QDateTime, QVariant
from qgis.PyQt.QtTest import QSignalSpy

from qgis.core import (
QgsWkbTypes,
Expand All @@ -36,7 +37,8 @@
QgsExpressionContextUtils,
QgsExpressionContext,
QgsCoordinateReferenceSystem,
QgsBox3d
QgsBox3d,
QgsMessageLog
)
from qgis.testing import (start_app,
unittest
Expand Down Expand Up @@ -705,10 +707,16 @@ def testApikey(self):
with open(sanitize(endpoint, '/collections/mycollection/items?limit=1000&apikey=mykey&' + ACCEPT_ITEMS), 'wb') as f:
f.write(json.dumps(first_items).encode('UTF-8'))

app_log = QgsApplication.messageLog()

# signals should be emitted by application log
app_spy = QSignalSpy(app_log.messageReceived)

vl = QgsVectorLayer("url='http://" + endpoint + "?apikey=mykey' typename='mycollection'", 'test', 'OAPIF')
self.assertTrue(vl.isValid())
values = [f['id'] for f in vl.getFeatures()]
self.assertEqual(values, ['feat.1'])
self.assertEqual(len(app_spy), 0, list(app_spy))


if __name__ == '__main__':
Expand Down

0 comments on commit a6fd43a

Please sign in to comment.