mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
parent
8a85cae92c
commit
cdbe502bdb
@ -1466,6 +1466,8 @@ namespace QgsWms
|
||||
fReq.setFilterExpression( QString( "intersects( $geometry, geom_from_wkt('%1') )" ).arg( layerFilterGeom->asWkt() ) );
|
||||
}
|
||||
|
||||
mFeatureFilter.filterFeatures( layer, fReq );
|
||||
|
||||
#ifdef HAVE_SERVER_PYTHON_PLUGINS
|
||||
mContext.accessControl()->filterFeatures( layer, fReq );
|
||||
|
||||
|
@ -356,6 +356,87 @@ class TestQgsServerWMSGetFeatureInfo(TestQgsServerWMSTestBase):
|
||||
urllib.parse.quote(':"NAME" = \'two\''),
|
||||
'wms_getfeatureinfo_filter_no_crs')
|
||||
|
||||
def testGetFeatureInfoOGCfilterJSON(self):
|
||||
# OGC Filter test with info_format=application/json
|
||||
|
||||
# Test OGC filter with I/J and BBOX
|
||||
self.wms_request_compare('GetFeatureInfo',
|
||||
'&LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'INFO_FORMAT=application%2Fjson&' +
|
||||
'WIDTH=1266&HEIGHT=531&' +
|
||||
'QUERY_LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'FEATURE_COUNT=10&' +
|
||||
'CRS=EPSG:4326&' +
|
||||
'BBOX=44.90139177500000045,8.20339159915254967,44.90148522499999473,8.20361440084745297&' +
|
||||
'I=882&J=282&'
|
||||
'FILTER=<Filter><PropertyIsEqualTo><PropertyName>id</PropertyName><Literal>2</Literal></PropertyIsEqualTo></Filter>', 'wms_getfeatureinfo_filter_ogc')
|
||||
|
||||
# Test OGC filter with I/J and BBOX, filter id 3: empty result
|
||||
self.wms_request_compare('GetFeatureInfo',
|
||||
'&LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'INFO_FORMAT=application%2Fjson&' +
|
||||
'WIDTH=1266&HEIGHT=531&' +
|
||||
'QUERY_LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'FEATURE_COUNT=10&' +
|
||||
'CRS=EPSG:4326&' +
|
||||
'BBOX=44.90139177500000045,8.20339159915254967,44.90148522499999473,8.20361440084745297&' +
|
||||
'I=882&J=282&'
|
||||
'FILTER=<Filter><PropertyIsEqualTo><PropertyName>id</PropertyName><Literal>3</Literal></PropertyIsEqualTo></Filter>', 'wms_getfeatureinfo_filter_ogc_empty')
|
||||
|
||||
# Test OGC filter with no I/J and BBOX
|
||||
self.wms_request_compare('GetFeatureInfo',
|
||||
'&LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'INFO_FORMAT=application%2Fjson&' +
|
||||
'WIDTH=1266&HEIGHT=531&' +
|
||||
'QUERY_LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'FEATURE_COUNT=10&' +
|
||||
'CRS=EPSG:4326&' +
|
||||
'FILTER=<Filter><PropertyIsEqualTo><PropertyName>id</PropertyName><Literal>2</Literal></PropertyIsEqualTo></Filter>', 'wms_getfeatureinfo_filter_ogc')
|
||||
|
||||
# Test OGC filter with no I/J and wrong BBOX
|
||||
self.wms_request_compare('GetFeatureInfo',
|
||||
'&LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'INFO_FORMAT=application%2Fjson&' +
|
||||
'WIDTH=1266&HEIGHT=531&' +
|
||||
'QUERY_LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'FEATURE_COUNT=10&' +
|
||||
'CRS=EPSG:4326&' +
|
||||
'BBOX=46,9,47,10&' +
|
||||
'FILTER=<Filter><PropertyIsEqualTo><PropertyName>id</PropertyName><Literal>2</Literal></PropertyIsEqualTo></Filter>', 'wms_getfeatureinfo_filter_ogc_empty')
|
||||
|
||||
# Test OGC filter with no I/J and BBOX plus complex OR filter
|
||||
self.wms_request_compare('GetFeatureInfo',
|
||||
'&LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'INFO_FORMAT=application%2Fjson&' +
|
||||
'WIDTH=1266&HEIGHT=531&' +
|
||||
'QUERY_LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'FEATURE_COUNT=10&' +
|
||||
'CRS=EPSG:4326&' +
|
||||
'FILTER=<Filter><Or><PropertyIsEqualTo><PropertyName>id</PropertyName><Literal>2</Literal></PropertyIsEqualTo>' +
|
||||
'<PropertyIsEqualTo><PropertyName>id</PropertyName><Literal>3</Literal></PropertyIsEqualTo></Or></Filter>', 'wms_getfeatureinfo_filter_ogc_complex')
|
||||
|
||||
# Test OGC filter with no I/J and BBOX plus complex AND filter
|
||||
self.wms_request_compare('GetFeatureInfo',
|
||||
'&LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'INFO_FORMAT=application%2Fjson&' +
|
||||
'WIDTH=1266&HEIGHT=531&' +
|
||||
'QUERY_LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'FEATURE_COUNT=10&' +
|
||||
'CRS=EPSG:4326&' +
|
||||
'FILTER=<Filter><And><PropertyIsEqualTo><PropertyName>id</PropertyName><Literal>2</Literal></PropertyIsEqualTo>' +
|
||||
'<PropertyIsEqualTo><PropertyName>id</PropertyName><Literal>3</Literal></PropertyIsEqualTo></And></Filter>', 'wms_getfeatureinfo_filter_ogc_empty')
|
||||
|
||||
# Test OGC filter with no I/J and BBOX plus complex AND filter
|
||||
self.wms_request_compare('GetFeatureInfo',
|
||||
'&LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'INFO_FORMAT=application%2Fjson&' +
|
||||
'WIDTH=1266&HEIGHT=531&' +
|
||||
'QUERY_LAYERS=testlayer%20%C3%A8%C3%A9&' +
|
||||
'FEATURE_COUNT=10&' +
|
||||
'CRS=EPSG:4326&' +
|
||||
'FILTER=<Filter><And><PropertyIsEqualTo><PropertyName>id</PropertyName><Literal>2</Literal></PropertyIsEqualTo>' +
|
||||
'<PropertyIsEqualTo><PropertyName>name</PropertyName><Literal>two</Literal></PropertyIsEqualTo></And></Filter>', 'wms_getfeatureinfo_filter_ogc')
|
||||
|
||||
def testGetFeatureInfoTolerance(self):
|
||||
self.wms_request_compare('GetFeatureInfo',
|
||||
'&layers=layer3&styles=&' +
|
||||
|
18
tests/testdata/qgis_server/wms_getfeatureinfo_filter_ogc.txt
vendored
Normal file
18
tests/testdata/qgis_server/wms_getfeatureinfo_filter_ogc.txt
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
Content-Length: 250
|
||||
Content-Type: application/json; charset=utf-8
|
||||
|
||||
{
|
||||
"features": [
|
||||
{
|
||||
"geometry": null,
|
||||
"id": "testlayer èé.1",
|
||||
"properties": {
|
||||
"id": 2,
|
||||
"name": "two",
|
||||
"utf8nameè": "two àò"
|
||||
},
|
||||
"type": "Feature"
|
||||
}
|
||||
],
|
||||
"type": "FeatureCollection"
|
||||
}
|
28
tests/testdata/qgis_server/wms_getfeatureinfo_filter_ogc_complex.txt
vendored
Normal file
28
tests/testdata/qgis_server/wms_getfeatureinfo_filter_ogc_complex.txt
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
Content-Length: 454
|
||||
Content-Type: application/json; charset=utf-8
|
||||
|
||||
{
|
||||
"features": [
|
||||
{
|
||||
"geometry": null,
|
||||
"id": "testlayer èé.1",
|
||||
"properties": {
|
||||
"id": 2,
|
||||
"name": "two",
|
||||
"utf8nameè": "two àò"
|
||||
},
|
||||
"type": "Feature"
|
||||
},
|
||||
{
|
||||
"geometry": null,
|
||||
"id": "testlayer èé.2",
|
||||
"properties": {
|
||||
"id": 3,
|
||||
"name": "three",
|
||||
"utf8nameè": "three èé↓"
|
||||
},
|
||||
"type": "Feature"
|
||||
}
|
||||
],
|
||||
"type": "FeatureCollection"
|
||||
}
|
7
tests/testdata/qgis_server/wms_getfeatureinfo_filter_ogc_empty.txt
vendored
Normal file
7
tests/testdata/qgis_server/wms_getfeatureinfo_filter_ogc_empty.txt
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
Content-Length: 51
|
||||
Content-Type: application/json; charset=utf-8
|
||||
|
||||
{
|
||||
"features": [],
|
||||
"type": "FeatureCollection"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user