Skip to content

Commit

Permalink
Fix server OAPIF bbox reprojection
Browse files Browse the repository at this point in the history
Fix #47302
  • Loading branch information
elpaso committed Feb 12, 2022
1 parent 4ff41e7 commit c18f76e
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/server/services/wfs3/qgswfs3handlers.cpp
Expand Up @@ -1231,8 +1231,7 @@ void QgsWfs3CollectionsItemsHandler::handleRequest( const QgsServerApiContext &c

if ( ! filterRect.isNull() )
{
const QgsCoordinateTransform ct( bboxCrs, mapLayer->crs(), context.project()->transformContext() );
ct.transform( filterRect );
const QgsCoordinateTransform ct( bboxCrs, crs, context.project()->transformContext() );
featureRequest.setFilterRect( ct.transform( filterRect ) );
}

Expand Down
34 changes: 33 additions & 1 deletion tests/src/python/test_qgsserver_api.py
Expand Up @@ -36,7 +36,17 @@
QgsServerApiUtils,
QgsServiceRegistry
)
from qgis.core import QgsProject, QgsRectangle, QgsVectorLayerServerProperties, QgsFeatureRequest

from qgis.core import (
QgsProject,
QgsRectangle,
QgsVectorLayerServerProperties,
QgsFeatureRequest,
QgsVectorLayer,
QgsFeature,
QgsGeometry,
)

from qgis.PyQt import QtCore

from qgis.testing import unittest
Expand Down Expand Up @@ -642,6 +652,28 @@ def test_wfs3_collection_items_bbox(self):
self.compareApi(
request, project, 'test_wfs3_collections_items_testlayer_èé_bbox_3857.json')

def test_wfs3_collection_items_bbox_25832(self):
"""Test WFS3 API bbox with reprojection"""

project = QgsProject()
vl = QgsVectorLayer("Point?crs=EPSG:25832&field=fldint:integer",
"testlayer25832", "memory")

f = QgsFeature(vl.fields())
f.setAttribute(0, 1)
f.setGeometry(QgsGeometry.fromWkt('point(361774 4963545)'))
vl.dataProvider().addFeatures((f,))
project.addMapLayers([vl])

project.writeEntry("WFSLayers", "/", (vl.id(),))
project.writeEntry("WMSCrsList", "/", ("EPSG:25832", "EPSG:4326",))

request = QgsBufferServerRequest(
'http://server.qgis.org/wfs3/collections/testlayer25832/items?bbox=7.16305252070271603,44.75906320523620963,7.3418755610416051,44.87555723151492515')

self.compareApi(request, project,
'test_wfs3_collections_items_testlayer25832_bbox.json')

def test_wfs3_static_handler(self):
"""Test static handler"""
request = QgsBufferServerRequest(
Expand Down
@@ -0,0 +1,38 @@
Content-Type: application/geo+json

{
"features": [
{
"geometry": {
"coordinates": [
7.251915,
44.811931
],
"type": "Point"
},
"id": "1",
"properties": {
"fldint": 1
},
"type": "Feature"
}
],
"links": [
{
"href": "http://server.qgis.org/wfs3/collections/testlayer25832/items.geojson?bbox=7.16305252070271603,44.75906320523620963,7.3418755610416051,44.87555723151492515",
"rel": "self",
"title": "Retrieve the features of the collection as GEOJSON",
"type": "application/geo+json"
},
{
"href": "http://server.qgis.org/wfs3/collections/testlayer25832/items.html?bbox=7.16305252070271603,44.75906320523620963,7.3418755610416051,44.87555723151492515",
"rel": "alternate",
"title": "Retrieve the features of the collection as HTML",
"type": "text/html"
}
],
"numberMatched": 1,
"numberReturned": 1,
"timeStamp": "2019-07-05T12:27:07Z",
"type": "FeatureCollection"
}

0 comments on commit c18f76e

Please sign in to comment.