Skip to content

Commit

Permalink
Fox offset calculation for prev link
Browse files Browse the repository at this point in the history
test added
  • Loading branch information
pathmapper authored and nyalldawson committed Apr 1, 2023
1 parent 9fb1cc4 commit 6ef6414
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/server/services/wfs3/qgswfs3handlers.cpp
Expand Up @@ -1399,7 +1399,7 @@ void QgsWfs3CollectionsItemsHandler::handleRequest( const QgsServerApiContext &c
if ( offset != 0 )
{
json prevLink = selfLink;
prevLink["href"] = QStringLiteral( "%1&offset=%2&limit=%3" ).arg( cleanedUrlAsString ).arg( std::max<long>( 0, limit - offset ) ).arg( limit ).toStdString();
prevLink["href"] = QStringLiteral( "%1&offset=%2&limit=%3" ).arg( cleanedUrlAsString ).arg( std::max<long>( 0, offset - limit ) ).arg( limit ).toStdString();
prevLink["rel"] = "prev";
prevLink["title"] = "Previous page";
data["links"].push_back( prevLink );
Expand Down
9 changes: 9 additions & 0 deletions tests/src/python/test_qgsserver_api.py
Expand Up @@ -630,6 +630,15 @@ def test_wfs3_collection_items_limit_offset(self):
self.assertEqual(response.body(),
b'[{"code":"Bad request error","description":"Argument \'limit\' is not valid. Number of features to retrieve [0-10000]"}]') # Bad request

def test_wfs3_collection_items_limit_offset_2(self):
"""Test WFS3 API offset 2"""
project = QgsProject()
project.read(os.path.join(self.temporary_path, 'qgis_server', 'test_project_api.qgs'))
request = QgsBufferServerRequest(
'http://server.qgis.org/wfs3/collections/testlayer%20èé/items?limit=1&offset=2')
self.compareApi(
request, project, 'test_wfs3_collections_items_testlayer_èé_limit_1_offset_2.json')

def test_wfs3_collection_items_bbox(self):
"""Test WFS3 API bbox"""
project = QgsProject()
Expand Down
@@ -0,0 +1,46 @@
Content-Type: application/geo+json

{
"features": [
{
"geometry": {
"coordinates": [
8.203459,
44.901395
],
"type": "Point"
},
"id": "2",
"properties": {
"id": 3,
"name": "three",
"utf8nameè": "three èé↓"
},
"type": "Feature"
}
],
"links": [
{
"href": "http://server.qgis.org/wfs3/collections/testlayer%20%C3%A8%C3%A9/items.geojson?limit=1&offset=2",
"rel": "self",
"title": "Retrieve the features of the collection as GEOJSON",
"type": "application/geo+json"
},
{
"href": "http://server.qgis.org/wfs3/collections/testlayer%20%C3%A8%C3%A9/items.html?limit=1&offset=2",
"rel": "alternate",
"title": "Retrieve the features of the collection as HTML",
"type": "text/html"
},
{
"href": "http://server.qgis.org/wfs3/collections/testlayer èé/items?&offset=1&limit=1",
"rel": "prev",
"title": "Previous page",
"type": "application/geo+json"
}
],
"numberMatched": 3,
"numberReturned": 1,
"timeStamp": "2019-07-05T12:27:07Z",
"type": "FeatureCollection"
}

0 comments on commit 6ef6414

Please sign in to comment.