1
1
# -*- coding: utf-8 -*-
2
+ from qgis .core import QgsProject
3
+ from test_qgsserver_wms import TestQgsServerWMSTestBase
4
+ from qgis .PyQt .QtCore import QSize
5
+ from qgis .testing import unittest
6
+ import json
7
+ import xml .etree .ElementTree as ET
8
+ import urllib .error
9
+ import urllib .parse
10
+ import urllib .request
11
+ import re
2
12
"""QGIS Unit tests for QgsServer GetFeatureInfo WMS.
3
13
4
14
From build dir, run: ctest -R PyQgsServerWMSGetFeatureInfo -V
18
28
19
29
import os
20
30
21
- # Needed on Qt 5 so that the serialization of XML is consistent among all executions
31
+ # Needed on Qt 5 so that the serialization of XML is consistent among all
32
+ # executions
22
33
os .environ ['QT_HASH_SEED' ] = '1'
23
34
24
- import re
25
- import urllib .request
26
- import urllib .parse
27
- import urllib .error
28
-
29
- import xml .etree .ElementTree as ET
30
- import json
31
-
32
- from qgis .testing import unittest
33
- from qgis .PyQt .QtCore import QSize
34
35
35
36
import osgeo .gdal # NOQA
36
37
37
- from test_qgsserver_wms import TestQgsServerWMSTestBase
38
- from qgis .core import QgsProject
39
-
40
38
41
39
class TestQgsServerWMSGetFeatureInfo (TestQgsServerWMSTestBase ):
42
40
@@ -45,141 +43,141 @@ class TestQgsServerWMSGetFeatureInfo(TestQgsServerWMSTestBase):
45
43
def testGetFeatureInfo (self ):
46
44
# Test getfeatureinfo response xml
47
45
self .wms_request_compare ('GetFeatureInfo' ,
48
- '&layers=testlayer%20%C3%A8%C3%A9&styles=&'
49
- + 'info_format=text%2Fxml&transparent=true&'
50
- + 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
51
- + '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
52
- + 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320' ,
46
+ '&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
47
+ 'info_format=text%2Fxml&transparent=true&' +
48
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
49
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
50
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320' ,
53
51
'wms_getfeatureinfo-text-xml' )
54
52
55
53
self .wms_request_compare ('GetFeatureInfo' ,
56
- '&layers=&styles=&'
57
- + 'info_format=text%2Fxml&transparent=true&'
58
- + 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
59
- + '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
60
- + 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320' ,
54
+ '&layers=&styles=&' +
55
+ 'info_format=text%2Fxml&transparent=true&' +
56
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
57
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
58
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320' ,
61
59
'wms_getfeatureinfo-text-xml' )
62
60
63
61
# Test getfeatureinfo on non queryable layer
64
62
self .wms_request_compare ('GetFeatureInfo' ,
65
- '&layers=testlayer3&styles=&'
66
- + 'info_format=text%2Fxml&transparent=true&'
67
- + 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
68
- + '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
69
- + 'query_layers=testlayer3&X=190&Y=320' ,
63
+ '&layers=testlayer3&styles=&' +
64
+ 'info_format=text%2Fxml&transparent=true&' +
65
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
66
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
67
+ 'query_layers=testlayer3&X=190&Y=320' ,
70
68
'wms_getfeatureinfo-testlayer3-notqueryable' )
71
69
72
70
# Test getfeatureinfo on group without shortname (no queryable...)
73
71
self .wms_request_compare ('GetFeatureInfo' ,
74
- '&layers=groupwithoutshortname&styles=&'
75
- + 'info_format=text%2Fxml&transparent=true&'
76
- + 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
77
- + '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
78
- + 'query_layers=groupwithoutshortname&X=190&Y=320' ,
72
+ '&layers=groupwithoutshortname&styles=&' +
73
+ 'info_format=text%2Fxml&transparent=true&' +
74
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
75
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
76
+ 'query_layers=groupwithoutshortname&X=190&Y=320' ,
79
77
'wms_getfeatureinfo-groupwithoutshortname-notqueryable' )
80
78
81
79
# Test getfeatureinfo on group with shortname (no queryable...)
82
80
self .wms_request_compare ('GetFeatureInfo' ,
83
- '&layers=group_name&styles=&'
84
- + 'info_format=text%2Fxml&transparent=true&'
85
- + 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
86
- + '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
87
- + 'query_layers=group_name&X=190&Y=320' ,
81
+ '&layers=group_name&styles=&' +
82
+ 'info_format=text%2Fxml&transparent=true&' +
83
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
84
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
85
+ 'query_layers=group_name&X=190&Y=320' ,
88
86
'wms_getfeatureinfo-group_name-notqueryable' )
89
87
90
88
# Test getfeatureinfo response html
91
89
self .wms_request_compare ('GetFeatureInfo' ,
92
- '&layers=testlayer%20%C3%A8%C3%A9&styles=&'
93
- + 'info_format=text%2Fhtml&transparent=true&'
94
- + 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
95
- + '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
96
- + 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320' ,
90
+ '&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
91
+ 'info_format=text%2Fhtml&transparent=true&' +
92
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
93
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
94
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320' ,
97
95
'wms_getfeatureinfo-text-html' )
98
96
99
97
# Test getfeatureinfo response html with geometry
100
98
self .wms_request_compare ('GetFeatureInfo' ,
101
- '&layers=testlayer%20%C3%A8%C3%A9&styles=&'
102
- + 'info_format=text%2Fhtml&transparent=true&'
103
- + 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
104
- + '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
105
- + 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&'
106
- + 'with_geometry=true' ,
99
+ '&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
100
+ 'info_format=text%2Fhtml&transparent=true&' +
101
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
102
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
103
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
104
+ 'with_geometry=true' ,
107
105
'wms_getfeatureinfo-text-html-geometry' )
108
106
109
107
# Test getfeatureinfo response html with maptip
110
108
self .wms_request_compare ('GetFeatureInfo' ,
111
- '&layers=testlayer%20%C3%A8%C3%A9&styles=&'
112
- + 'info_format=text%2Fhtml&transparent=true&'
113
- + 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
114
- + '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
115
- + 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&'
116
- + 'with_maptip=true' ,
109
+ '&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
110
+ 'info_format=text%2Fhtml&transparent=true&' +
111
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
112
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
113
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
114
+ 'with_maptip=true' ,
117
115
'wms_getfeatureinfo-text-html-maptip' )
118
116
119
117
# Test getfeatureinfo response text
120
118
self .wms_request_compare ('GetFeatureInfo' ,
121
- '&layers=testlayer%20%C3%A8%C3%A9&styles=&'
122
- + 'transparent=true&'
123
- + 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
124
- + '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
125
- + 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&'
126
- + 'info_format=text/plain' ,
119
+ '&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
120
+ 'transparent=true&' +
121
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
122
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
123
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
124
+ 'info_format=text/plain' ,
127
125
'wms_getfeatureinfo-text-plain' )
128
126
129
127
# Test getfeatureinfo default info_format
130
128
self .wms_request_compare ('GetFeatureInfo' ,
131
- '&layers=testlayer%20%C3%A8%C3%A9&styles=&'
132
- + 'transparent=true&'
133
- + 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
134
- + '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
135
- + 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320' ,
129
+ '&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
130
+ 'transparent=true&' +
131
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
132
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
133
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320' ,
136
134
'wms_getfeatureinfo-text-plain' )
137
135
138
136
# Test getfeatureinfo invalid info_format
139
137
self .wms_request_compare ('GetFeatureInfo' ,
140
- '&layers=testlayer%20%C3%A8%C3%A9&styles=&'
141
- + 'transparent=true&'
142
- + 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
143
- + '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
144
- + 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&'
145
- + 'info_format=InvalidFormat' ,
138
+ '&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
139
+ 'transparent=true&' +
140
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
141
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
142
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
143
+ 'info_format=InvalidFormat' ,
146
144
'wms_getfeatureinfo-invalid-format' )
147
145
148
146
# Test feature info request with filter geometry
149
147
self .wms_request_compare ('GetFeatureInfo' ,
150
- '&layers=testlayer%20%C3%A8%C3%A9&'
151
- + 'INFO_FORMAT=text%2Fxml&'
152
- + 'width=600&height=400&srs=EPSG%3A4326&'
153
- + 'query_layers=testlayer%20%C3%A8%C3%A9&'
154
- + 'FEATURE_COUNT=10&FILTER_GEOM=POLYGON((8.2035381 44.901459,8.2035562 44.901459,8.2035562 44.901418,8.2035381 44.901418,8.2035381 44.901459))' ,
148
+ '&layers=testlayer%20%C3%A8%C3%A9&' +
149
+ 'INFO_FORMAT=text%2Fxml&' +
150
+ 'width=600&height=400&srs=EPSG%3A4326&' +
151
+ 'query_layers=testlayer%20%C3%A8%C3%A9&' +
152
+ 'FEATURE_COUNT=10&FILTER_GEOM=POLYGON((8.2035381 44.901459,8.2035562 44.901459,8.2035562 44.901418,8.2035381 44.901418,8.2035381 44.901459))' ,
155
153
'wms_getfeatureinfo_geometry_filter' )
156
154
157
155
# Test feature info request with filter geometry in non-layer CRS
158
156
self .wms_request_compare ('GetFeatureInfo' ,
159
- '&layers=testlayer%20%C3%A8%C3%A9&'
160
- + 'INFO_FORMAT=text%2Fxml&'
161
- + 'width=600&height=400&srs=EPSG%3A3857&'
162
- + 'query_layers=testlayer%20%C3%A8%C3%A9&'
163
- + 'FEATURE_COUNT=10&FILTER_GEOM=POLYGON ((913213.6839952 5606021.5399693, 913215.6988780 5606021.5399693, 913215.6988780 5606015.09643322, 913213.6839952 5606015.0964332, 913213.6839952 5606021.5399693))' ,
157
+ '&layers=testlayer%20%C3%A8%C3%A9&' +
158
+ 'INFO_FORMAT=text%2Fxml&' +
159
+ 'width=600&height=400&srs=EPSG%3A3857&' +
160
+ 'query_layers=testlayer%20%C3%A8%C3%A9&' +
161
+ 'FEATURE_COUNT=10&FILTER_GEOM=POLYGON ((913213.6839952 5606021.5399693, 913215.6988780 5606021.5399693, 913215.6988780 5606015.09643322, 913213.6839952 5606015.0964332, 913213.6839952 5606021.5399693))' ,
164
162
'wms_getfeatureinfo_geometry_filter_3857' )
165
163
166
164
# Test feature info request with invalid query_layer
167
165
self .wms_request_compare ('GetFeatureInfo' ,
168
- '&layers=testlayer%20%C3%A8%C3%A9&'
169
- + 'INFO_FORMAT=text%2Fxml&'
170
- + 'width=600&height=400&srs=EPSG%3A3857&'
171
- + 'query_layers=InvalidLayer&'
172
- + 'FEATURE_COUNT=10&FILTER_GEOM=POLYGON((8.2035381 44.901459,8.2035562 44.901459,8.2035562 44.901418,8.2035381 44.901418,8.2035381 44.901459))' ,
166
+ '&layers=testlayer%20%C3%A8%C3%A9&' +
167
+ 'INFO_FORMAT=text%2Fxml&' +
168
+ 'width=600&height=400&srs=EPSG%3A3857&' +
169
+ 'query_layers=InvalidLayer&' +
170
+ 'FEATURE_COUNT=10&FILTER_GEOM=POLYGON((8.2035381 44.901459,8.2035562 44.901459,8.2035562 44.901418,8.2035381 44.901418,8.2035381 44.901459))' ,
173
171
'wms_getfeatureinfo_invalid_query_layers' )
174
172
175
173
# Test feature info request with '+' instead of ' ' in layers and
176
174
# query_layers parameters
177
175
self .wms_request_compare ('GetFeatureInfo' ,
178
- '&layers=testlayer+%C3%A8%C3%A9&styles=&'
179
- + 'info_format=text%2Fxml&transparent=true&'
180
- + 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
181
- + '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
182
- + 'query_layers=testlayer+%C3%A8%C3%A9&X=190&Y=320' ,
176
+ '&layers=testlayer+%C3%A8%C3%A9&styles=&' +
177
+ 'info_format=text%2Fxml&transparent=true&' +
178
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
179
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
180
+ 'query_layers=testlayer+%C3%A8%C3%A9&X=190&Y=320' ,
183
181
'wms_getfeatureinfo-text-xml' )
184
182
185
183
# layer1 is a clone of layer0 but with a scale visibility. Thus,
@@ -188,76 +186,78 @@ def testGetFeatureInfo(self):
188
186
# the feature for layer1 would have been in the response too.
189
187
mypath = self .testdata_path + "test_project_scalevisibility.qgs"
190
188
self .wms_request_compare ('GetFeatureInfo' ,
191
- '&layers=layer0,layer1&styles=&'
192
- + 'VERSION=1.1.0&'
193
- + 'info_format=text%2Fxml&'
194
- + 'width=500&height=500&srs=EPSG%3A4326'
195
- + '&bbox=8.1976,44.8998,8.2100,44.9027&'
196
- + 'query_layers=layer0,layer1&X=235&Y=243' ,
189
+ '&layers=layer0,layer1&styles=&' +
190
+ 'VERSION=1.1.0&' +
191
+ 'info_format=text%2Fxml&' +
192
+ 'width=500&height=500&srs=EPSG%3A4326' +
193
+ '&bbox=8.1976,44.8998,8.2100,44.9027&' +
194
+ 'query_layers=layer0,layer1&X=235&Y=243' ,
197
195
'wms_getfeatureinfo_notvisible' ,
198
196
'test_project_scalevisibility.qgs' )
199
197
200
- # Test GetFeatureInfo resolves "value map" widget values but also Server usage of qgs and gpkg file
198
+ # Test GetFeatureInfo resolves "value map" widget values but also
199
+ # Server usage of qgs and gpkg file
201
200
mypath = self .testdata_path + "test_project_values.qgz"
202
201
self .wms_request_compare ('GetFeatureInfo' ,
203
- '&layers=layer0&styles=&'
204
- + 'VERSION=1.3.0&'
205
- + 'info_format=text%2Fxml&'
206
- + 'width=926&height=787&srs=EPSG%3A4326'
207
- + '&bbox=912217,5605059,914099,5606652'
208
- + '&CRS=EPSG:3857'
209
- + '&FEATURE_COUNT=10'
210
- + '&QUERY_LAYERS=layer0&I=487&J=308' ,
202
+ '&layers=layer0&styles=&' +
203
+ 'VERSION=1.3.0&' +
204
+ 'info_format=text%2Fxml&' +
205
+ 'width=926&height=787&srs=EPSG%3A4326' +
206
+ '&bbox=912217,5605059,914099,5606652' +
207
+ '&CRS=EPSG:3857' +
208
+ '&FEATURE_COUNT=10' +
209
+ '&QUERY_LAYERS=layer0&I=487&J=308' ,
211
210
'wms_getfeatureinfo-values0-text-xml' ,
212
211
'test_project_values.qgz' )
213
212
214
213
def testGetFeatureInfoValueRelation (self ):
215
214
"""Test GetFeatureInfo resolves "value relation" widget values. regression 18518"""
216
215
mypath = self .testdata_path + "test_project_values.qgz"
217
216
self .wms_request_compare ('GetFeatureInfo' ,
218
- '&layers=layer1&styles=&'
219
- + 'VERSION=1.3.0&'
220
- + 'info_format=text%2Fxml&'
221
- + 'width=926&height=787&srs=EPSG%3A4326'
222
- + '&bbox=912217,5605059,914099,5606652'
223
- + '&CRS=EPSG:3857'
224
- + '&FEATURE_COUNT=10'
225
- + '&WITH_GEOMETRY=True'
226
- + '&QUERY_LAYERS=layer1&I=487&J=308' ,
217
+ '&layers=layer1&styles=&' +
218
+ 'VERSION=1.3.0&' +
219
+ 'info_format=text%2Fxml&' +
220
+ 'width=926&height=787&srs=EPSG%3A4326' +
221
+ '&bbox=912217,5605059,914099,5606652' +
222
+ '&CRS=EPSG:3857' +
223
+ '&FEATURE_COUNT=10' +
224
+ '&WITH_GEOMETRY=True' +
225
+ '&QUERY_LAYERS=layer1&I=487&J=308' ,
227
226
'wms_getfeatureinfo-values1-text-xml' ,
228
227
'test_project_values.qgz' )
229
228
230
229
def testGetFeatureInfoValueRelationArray (self ):
231
230
"""Test GetFeatureInfo on "value relation" widget with array field (multiple selections)"""
232
231
mypath = self .testdata_path + "test_project_values.qgz"
233
232
self .wms_request_compare ('GetFeatureInfo' ,
234
- '&layers=layer3&styles=&'
235
- + 'VERSION=1.3.0&'
236
- + 'info_format=text%2Fxml&'
237
- + 'width=926&height=787&srs=EPSG%3A4326'
238
- + '&bbox=912217,5605059,914099,5606652'
239
- + '&CRS=EPSG:3857'
240
- + '&FEATURE_COUNT=10'
241
- + '&WITH_GEOMETRY=True'
242
- + '&QUERY_LAYERS=layer3&I=487&J=308' ,
233
+ '&layers=layer3&styles=&' +
234
+ 'VERSION=1.3.0&' +
235
+ 'info_format=text%2Fxml&' +
236
+ 'width=926&height=787&srs=EPSG%3A4326' +
237
+ '&bbox=912217,5605059,914099,5606652' +
238
+ '&CRS=EPSG:3857' +
239
+ '&FEATURE_COUNT=10' +
240
+ '&WITH_GEOMETRY=True' +
241
+ '&QUERY_LAYERS=layer3&I=487&J=308' ,
243
242
'wms_getfeatureinfo-values3-text-xml' ,
244
243
'test_project_values.qgz' )
245
244
246
- # TODO make GetFeatureInfo show what's in the display expression and enable test
245
+ # TODO make GetFeatureInfo show what's in the display expression and
246
+ # enable test
247
247
@unittest .expectedFailure
248
248
def testGetFeatureInfoRelationReference (self ):
249
249
"""Test GetFeatureInfo solves "relation reference" widget "display expression" values"""
250
250
mypath = self .testdata_path + "test_project_values.qgz"
251
251
self .wms_request_compare ('GetFeatureInfo' ,
252
- '&layers=layer2&styles=&'
253
- + 'VERSION=1.3.0&'
254
- + 'info_format=text%2Fxml&'
255
- + 'width=926&height=787&srs=EPSG%3A4326'
256
- + '&bbox=912217,5605059,914099,5606652'
257
- + '&CRS=EPSG:3857'
258
- + '&FEATURE_COUNT=10'
259
- + '&WITH_GEOMETRY=True'
260
- + '&QUERY_LAYERS=layer2&I=487&J=308' ,
252
+ '&layers=layer2&styles=&' +
253
+ 'VERSION=1.3.0&' +
254
+ 'info_format=text%2Fxml&' +
255
+ 'width=926&height=787&srs=EPSG%3A4326' +
256
+ '&bbox=912217,5605059,914099,5606652' +
257
+ '&CRS=EPSG:3857' +
258
+ '&FEATURE_COUNT=10' +
259
+ '&WITH_GEOMETRY=True' +
260
+ '&QUERY_LAYERS=layer2&I=487&J=308' ,
261
261
'wms_getfeatureinfo-values2-text-xml' ,
262
262
'test_project_values.qgz' )
263
263
@@ -266,11 +266,12 @@ def testGetFeatureInfoFilterGPKG(self):
266
266
# Regression for #8656 Test getfeatureinfo response xml with gpkg datasource
267
267
# Mind the gap! (the space in the FILTER expression)
268
268
self .wms_request_compare ('GetFeatureInfo' ,
269
- '&layers=testlayer%20%C3%A8%C3%A9&'
270
- + 'INFO_FORMAT=text%2Fxml&'
271
- + 'width=600&height=400&srs=EPSG%3A3857&'
272
- + 'query_layers=testlayer%20%C3%A8%C3%A9&'
273
- + 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib .parse .quote (':"NAME" = \' two\' ' ),
269
+ '&layers=testlayer%20%C3%A8%C3%A9&' +
270
+ 'INFO_FORMAT=text%2Fxml&' +
271
+ 'width=600&height=400&srs=EPSG%3A3857&' +
272
+ 'query_layers=testlayer%20%C3%A8%C3%A9&' +
273
+ 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
274
+ urllib .parse .quote (':"NAME" = \' two\' ' ),
274
275
'wms_getfeatureinfo_filter_gpkg' ,
275
276
'test_project.qgz' )
276
277
@@ -280,194 +281,228 @@ def testGetFeatureInfoFilter(self):
280
281
# Regression for #8656
281
282
# Mind the gap! (the space in the FILTER expression)
282
283
self .wms_request_compare ('GetFeatureInfo' ,
283
- '&layers=testlayer%20%C3%A8%C3%A9&'
284
- + 'INFO_FORMAT=text%2Fxml&'
285
- + 'width=600&height=400&srs=EPSG%3A3857&'
286
- + 'query_layers=testlayer%20%C3%A8%C3%A9&'
287
- + 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib .parse .quote (':"NAME" = \' two\' ' ),
284
+ '&layers=testlayer%20%C3%A8%C3%A9&' +
285
+ 'INFO_FORMAT=text%2Fxml&' +
286
+ 'width=600&height=400&srs=EPSG%3A3857&' +
287
+ 'query_layers=testlayer%20%C3%A8%C3%A9&' +
288
+ 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
289
+ urllib .parse .quote (':"NAME" = \' two\' ' ),
288
290
'wms_getfeatureinfo_filter' )
289
291
290
292
# Test a filter with NO condition results
291
293
self .wms_request_compare ('GetFeatureInfo' ,
292
- '&layers=testlayer%20%C3%A8%C3%A9&'
293
- + 'INFO_FORMAT=text%2Fxml&'
294
- + 'width=600&height=400&srs=EPSG%3A3857&'
295
- + 'query_layers=testlayer%20%C3%A8%C3%A9&'
296
- + 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib .parse .quote (':"NAME" = \' two\' AND "utf8nameè" = \' no-results\' ' ),
294
+ '&layers=testlayer%20%C3%A8%C3%A9&' +
295
+ 'INFO_FORMAT=text%2Fxml&' +
296
+ 'width=600&height=400&srs=EPSG%3A3857&' +
297
+ 'query_layers=testlayer%20%C3%A8%C3%A9&' +
298
+ 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
299
+ urllib .parse .quote (
300
+ ':"NAME" = \' two\' AND "utf8nameè" = \' no-results\' ' ),
297
301
'wms_getfeatureinfo_filter_no_results' )
298
302
299
303
# Test a filter with OR condition results
300
304
self .wms_request_compare ('GetFeatureInfo' ,
301
- '&layers=testlayer%20%C3%A8%C3%A9&'
302
- + 'INFO_FORMAT=text%2Fxml&'
303
- + 'width=600&height=400&srs=EPSG%3A3857&'
304
- + 'query_layers=testlayer%20%C3%A8%C3%A9&'
305
- + 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib .parse .quote (':"NAME" = \' two\' OR "NAME" = \' three\' ' ),
305
+ '&layers=testlayer%20%C3%A8%C3%A9&' +
306
+ 'INFO_FORMAT=text%2Fxml&' +
307
+ 'width=600&height=400&srs=EPSG%3A3857&' +
308
+ 'query_layers=testlayer%20%C3%A8%C3%A9&' +
309
+ 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
310
+ urllib .parse .quote (
311
+ ':"NAME" = \' two\' OR "NAME" = \' three\' ' ),
306
312
'wms_getfeatureinfo_filter_or' )
307
313
308
314
# Test a filter with OR condition and UTF results
309
315
# Note that the layer name that contains utf-8 chars cannot be
310
316
# to upper case.
311
317
self .wms_request_compare ('GetFeatureInfo' ,
312
- '&layers=testlayer%20%C3%A8%C3%A9&'
313
- + 'INFO_FORMAT=text%2Fxml&'
314
- + 'width=600&height=400&srs=EPSG%3A3857&'
315
- + 'query_layers=testlayer%20%C3%A8%C3%A9&'
316
- + 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib .parse .quote (':"NAME" = \' two\' OR "utf8nameè" = \' three èé↓\' ' ),
318
+ '&layers=testlayer%20%C3%A8%C3%A9&' +
319
+ 'INFO_FORMAT=text%2Fxml&' +
320
+ 'width=600&height=400&srs=EPSG%3A3857&' +
321
+ 'query_layers=testlayer%20%C3%A8%C3%A9&' +
322
+ 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
323
+ urllib .parse .quote (
324
+ ':"NAME" = \' two\' OR "utf8nameè" = \' three èé↓\' ' ),
317
325
'wms_getfeatureinfo_filter_or_utf8' )
318
326
319
- # Regression #18292 Server GetFeatureInfo FILTER search fails when WIDTH, HEIGHT are not specified
327
+ # Regression #18292 Server GetFeatureInfo FILTER search fails when
328
+ # WIDTH, HEIGHT are not specified
320
329
self .wms_request_compare ('GetFeatureInfo' ,
321
- '&layers=testlayer%20%C3%A8%C3%A9&'
322
- + 'INFO_FORMAT=text%2Fxml&'
323
- + 'srs=EPSG%3A3857&'
324
- + 'query_layers=testlayer%20%C3%A8%C3%A9&'
325
- + 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib .parse .quote (':"NAME" = \' two\' ' ),
330
+ '&layers=testlayer%20%C3%A8%C3%A9&' +
331
+ 'INFO_FORMAT=text%2Fxml&' +
332
+ 'srs=EPSG%3A3857&' +
333
+ 'query_layers=testlayer%20%C3%A8%C3%A9&' +
334
+ 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
335
+ urllib .parse .quote (':"NAME" = \' two\' ' ),
326
336
'wms_getfeatureinfo_filter_no_width' )
327
337
328
338
def testGetFeatureInfoTolerance (self ):
329
339
self .wms_request_compare ('GetFeatureInfo' ,
330
- '&layers=layer3&styles=&'
331
- + 'VERSION=1.3.0&'
332
- + 'info_format=text%2Fxml&'
333
- + 'width=400&height=200'
334
- + '&bbox=913119.2,5605988.9,913316.0,5606047.4'
335
- + '&CRS=EPSG:3857'
336
- + '&FEATURE_COUNT=10'
337
- + '&WITH_GEOMETRY=False'
338
- + '&QUERY_LAYERS=layer3&I=193&J=100'
339
- + '&FI_POINT_TOLERANCE=0' ,
340
+ '&layers=layer3&styles=&' +
341
+ 'VERSION=1.3.0&' +
342
+ 'info_format=text%2Fxml&' +
343
+ 'width=400&height=200' +
344
+ '&bbox=913119.2,5605988.9,913316.0,5606047.4' +
345
+ '&CRS=EPSG:3857' +
346
+ '&FEATURE_COUNT=10' +
347
+ '&WITH_GEOMETRY=False' +
348
+ '&QUERY_LAYERS=layer3&I=193&J=100' +
349
+ '&FI_POINT_TOLERANCE=0' ,
340
350
'wms_getfeatureinfo_point_tolerance_0_text_xml' ,
341
351
'test_project_values.qgz' )
342
352
343
353
self .wms_request_compare ('GetFeatureInfo' ,
344
- '&layers=layer3&styles=&'
345
- + 'VERSION=1.3.0&'
346
- + 'info_format=text%2Fxml&'
347
- + 'width=400&height=200'
348
- + '&bbox=913119.2,5605988.9,913316.0,5606047.4'
349
- + '&CRS=EPSG:3857'
350
- + '&FEATURE_COUNT=10'
351
- + '&WITH_GEOMETRY=False'
352
- + '&QUERY_LAYERS=layer3&I=193&J=100'
353
- + '&FI_POINT_TOLERANCE=20' ,
354
+ '&layers=layer3&styles=&' +
355
+ 'VERSION=1.3.0&' +
356
+ 'info_format=text%2Fxml&' +
357
+ 'width=400&height=200' +
358
+ '&bbox=913119.2,5605988.9,913316.0,5606047.4' +
359
+ '&CRS=EPSG:3857' +
360
+ '&FEATURE_COUNT=10' +
361
+ '&WITH_GEOMETRY=False' +
362
+ '&QUERY_LAYERS=layer3&I=193&J=100' +
363
+ '&FI_POINT_TOLERANCE=20' ,
354
364
'wms_getfeatureinfo_point_tolerance_20_text_xml' ,
355
365
'test_project_values.qgz' )
356
366
357
367
self .wms_request_compare ('GetFeatureInfo' ,
358
- '&layers=ls2d&styles=&'
359
- + 'VERSION=1.3.0&'
360
- + 'info_format=text%2Fxml&'
361
- + 'width=400&height=200'
362
- + '&bbox=-50396.4,-2783.0,161715.8,114108.6'
363
- + '&CRS=EPSG:3857'
364
- + '&FEATURE_COUNT=10'
365
- + '&WITH_GEOMETRY=False'
366
- + '&QUERY_LAYERS=ls2d&I=153&J=147'
367
- + '&FI_LINE_TOLERANCE=0' ,
368
+ '&layers=ls2d&styles=&' +
369
+ 'VERSION=1.3.0&' +
370
+ 'info_format=text%2Fxml&' +
371
+ 'width=400&height=200' +
372
+ '&bbox=-50396.4,-2783.0,161715.8,114108.6' +
373
+ '&CRS=EPSG:3857' +
374
+ '&FEATURE_COUNT=10' +
375
+ '&WITH_GEOMETRY=False' +
376
+ '&QUERY_LAYERS=ls2d&I=153&J=147' +
377
+ '&FI_LINE_TOLERANCE=0' ,
368
378
'wms_getfeatureinfo_line_tolerance_0_text_xml' ,
369
379
'test_project_values.qgz' )
370
380
371
381
self .wms_request_compare ('GetFeatureInfo' ,
372
- '&layers=ls2d&styles=&'
373
- + 'VERSION=1.3.0&'
374
- + 'info_format=text%2Fxml&'
375
- + 'width=400&height=200'
376
- + '&bbox=-50396.4,-2783.0,161715.8,114108.6'
377
- + '&CRS=EPSG:3857'
378
- + '&FEATURE_COUNT=10'
379
- + '&WITH_GEOMETRY=False'
380
- + '&QUERY_LAYERS=ls2d&I=153&J=147'
381
- + '&FI_LINE_TOLERANCE=20' ,
382
+ '&layers=ls2d&styles=&' +
383
+ 'VERSION=1.3.0&' +
384
+ 'info_format=text%2Fxml&' +
385
+ 'width=400&height=200' +
386
+ '&bbox=-50396.4,-2783.0,161715.8,114108.6' +
387
+ '&CRS=EPSG:3857' +
388
+ '&FEATURE_COUNT=10' +
389
+ '&WITH_GEOMETRY=False' +
390
+ '&QUERY_LAYERS=ls2d&I=153&J=147' +
391
+ '&FI_LINE_TOLERANCE=20' ,
382
392
'wms_getfeatureinfo_line_tolerance_20_text_xml' ,
383
393
'test_project_values.qgz' )
384
394
385
395
self .wms_request_compare ('GetFeatureInfo' ,
386
- '&layers=p2d&styles=&'
387
- + 'VERSION=1.3.0&'
388
- + 'info_format=text%2Fxml&'
389
- + 'width=400&height=200'
390
- + '&bbox=-135832.0,-66482.4,240321.9,167300.4'
391
- + '&CRS=EPSG:3857'
392
- + '&FEATURE_COUNT=10'
393
- + '&WITH_GEOMETRY=False'
394
- + '&QUERY_LAYERS=p2d&I=206&J=144'
395
- + '&FI_POLYGON_TOLERANCE=0' ,
396
+ '&layers=p2d&styles=&' +
397
+ 'VERSION=1.3.0&' +
398
+ 'info_format=text%2Fxml&' +
399
+ 'width=400&height=200' +
400
+ '&bbox=-135832.0,-66482.4,240321.9,167300.4' +
401
+ '&CRS=EPSG:3857' +
402
+ '&FEATURE_COUNT=10' +
403
+ '&WITH_GEOMETRY=False' +
404
+ '&QUERY_LAYERS=p2d&I=206&J=144' +
405
+ '&FI_POLYGON_TOLERANCE=0' ,
396
406
'wms_getfeatureinfo_polygon_tolerance_0_text_xml' ,
397
407
'test_project_values.qgz' )
398
408
399
409
self .wms_request_compare ('GetFeatureInfo' ,
400
- '&layers=p2d&styles=&'
401
- + 'VERSION=1.3.0&'
402
- + 'info_format=text%2Fxml&'
403
- + 'width=400&height=200'
404
- + '&bbox=-135832.0,-66482.4,240321.9,167300.4'
405
- + '&CRS=EPSG:3857'
406
- + '&FEATURE_COUNT=10'
407
- + '&WITH_GEOMETRY=False'
408
- + '&QUERY_LAYERS=p2d&I=206&J=144'
409
- + '&FI_POLYGON_TOLERANCE=20' ,
410
+ '&layers=p2d&styles=&' +
411
+ 'VERSION=1.3.0&' +
412
+ 'info_format=text%2Fxml&' +
413
+ 'width=400&height=200' +
414
+ '&bbox=-135832.0,-66482.4,240321.9,167300.4' +
415
+ '&CRS=EPSG:3857' +
416
+ '&FEATURE_COUNT=10' +
417
+ '&WITH_GEOMETRY=False' +
418
+ '&QUERY_LAYERS=p2d&I=206&J=144' +
419
+ '&FI_POLYGON_TOLERANCE=20' ,
410
420
'wms_getfeatureinfo_polygon_tolerance_20_text_xml' ,
411
421
'test_project_values.qgz' )
412
422
413
423
def testGetFeatureInfoPostgresTypes (self ):
414
- #compare json list output with file
415
- self .wms_request_compare ('GetFeatureInfo' ,
416
- '&layers=json'
417
- + '&info_format=text%2Fxml'
418
- + '&srs=EPSG%3A3857'
419
- + '&QUERY_LAYERS=json'
420
- + '&FILTER=json' + urllib .parse .quote (':"pk" = 1' ),
424
+ # compare json list output with file
425
+ self .wms_request_compare ('GetFeatureInfo' ,
426
+ '&layers=json' +
427
+ '&info_format=text%2Fxml' +
428
+ '&srs=EPSG%3A3857' +
429
+ '&QUERY_LAYERS=json' +
430
+ '&FILTER=json' +
431
+ urllib .parse .quote (':"pk" = 1' ),
421
432
'get_postgres_types_json_list' ,
422
433
'test_project_postgres_types.qgs' )
423
434
424
- #compare dict output with file
435
+ # compare dict output with file
425
436
self .wms_request_compare ('GetFeatureInfo' ,
426
- '&layers=json'
427
- + '&info_format=text%2Fxml'
428
- + '&srs=EPSG%3A3857'
429
- + '&QUERY_LAYERS=json'
430
- + '&FILTER=json' + urllib .parse .quote (':"pk" = 2' ),
437
+ '&layers=json' +
438
+ '&info_format=text%2Fxml' +
439
+ '&srs=EPSG%3A3857' +
440
+ '&QUERY_LAYERS=json' +
441
+ '&FILTER=json' +
442
+ urllib .parse .quote (':"pk" = 2' ),
431
443
'get_postgres_types_json_dict' ,
432
444
'test_project_postgres_types.qgs' )
433
445
434
- #compare decoded json field list
446
+ # compare decoded json field list
435
447
response_header , response_body , query_string = self .wms_request ('GetFeatureInfo' ,
436
- '&layers=json'
437
- + '&info_format=text%2Fxml'
438
- + '&srs=EPSG%3A3857'
439
- + '&QUERY_LAYERS=json'
440
- + '&FILTER=json' + urllib .parse .quote (':"pk" = 1' ),
448
+ '&layers=json' +
449
+ '&info_format=text%2Fxml' +
450
+ '&srs=EPSG%3A3857' +
451
+ '&QUERY_LAYERS=json' +
452
+ '&FILTER=json' +
453
+ urllib .parse .quote (
454
+ ':"pk" = 1' ),
441
455
'test_project_postgres_types.qgs' )
442
456
root = ET .fromstring (response_body )
443
457
for attribute in root .iter ('Attribute' ):
444
458
if attribute .get ('name' ) == 'jvalue' :
445
459
self .assertIsInstance (json .loads (attribute .get ('value' )), list )
446
460
self .assertEqual (json .loads (attribute .get ('value' )), [1 , 2 , 3 ])
447
- self .assertEqual (json .loads (attribute .get ('value' )), [1.0 , 2.0 , 3.0 ])
461
+ self .assertEqual (
462
+ json .loads (
463
+ attribute .get ('value' )), [
464
+ 1.0 , 2.0 , 3.0 ])
448
465
if attribute .get ('name' ) == 'jbvalue' :
449
466
self .assertIsInstance (json .loads (attribute .get ('value' )), list )
450
467
self .assertEqual (json .loads (attribute .get ('value' )), [4 , 5 , 6 ])
451
- self .assertEqual (json .loads (attribute .get ('value' )), [4.0 , 5.0 , 6.0 ])
468
+ self .assertEqual (
469
+ json .loads (
470
+ attribute .get ('value' )), [
471
+ 4.0 , 5.0 , 6.0 ])
452
472
453
- #compare decoded json field dict
473
+ # compare decoded json field dict
454
474
response_header , response_body , query_string = self .wms_request ('GetFeatureInfo' ,
455
- '&layers=json'
456
- + '&info_format=text%2Fxml'
457
- + '&srs=EPSG%3A3857'
458
- + '&QUERY_LAYERS=json'
459
- + '&FILTER=json' + urllib .parse .quote (':"pk" = 2' ),
475
+ '&layers=json' +
476
+ '&info_format=text%2Fxml' +
477
+ '&srs=EPSG%3A3857' +
478
+ '&QUERY_LAYERS=json' +
479
+ '&FILTER=json' +
480
+ urllib .parse .quote (
481
+ ':"pk" = 2' ),
460
482
'test_project_postgres_types.qgs' )
461
483
root = ET .fromstring (response_body )
462
484
for attribute in root .iter ('Attribute' ):
463
485
if attribute .get ('name' ) == 'jvalue' :
464
486
self .assertIsInstance (json .loads (attribute .get ('value' )), dict )
465
- self .assertEqual (json .loads (attribute .get ('value' )), {'a' : 1 , 'b' : 2 })
466
- self .assertEqual (json .loads (attribute .get ('value' )), {'a' : 1.0 , 'b' : 2.0 })
487
+ self .assertEqual (
488
+ json .loads (
489
+ attribute .get ('value' )), {
490
+ 'a' : 1 , 'b' : 2 })
491
+ self .assertEqual (
492
+ json .loads (
493
+ attribute .get ('value' )), {
494
+ 'a' : 1.0 , 'b' : 2.0 })
467
495
if attribute .get ('name' ) == 'jbvalue' :
468
496
self .assertIsInstance (json .loads (attribute .get ('value' )), dict )
469
- self .assertEqual (json .loads (attribute .get ('value' )), {'c' : 4 , 'd' : 5 })
470
- self .assertEqual (json .loads (attribute .get ('value' )), {'c' : 4.0 , 'd' : 5.0 })
497
+ self .assertEqual (
498
+ json .loads (
499
+ attribute .get ('value' )), {
500
+ 'c' : 4 , 'd' : 5 })
501
+ self .assertEqual (
502
+ json .loads (
503
+ attribute .get ('value' )), {
504
+ 'c' : 4.0 , 'd' : 5.0 })
505
+
471
506
472
507
if __name__ == '__main__' :
473
508
unittest .main ()
0 commit comments