Skip to content

Commit e10736a

Browse files
authored
Merge pull request #8199 from pblottiere/server_getfeatureinfo_tolerance
[bugfix] Fixes #19383 - GetFeatureInfo tolerance
2 parents fff0c03 + c3a41bc commit e10736a

10 files changed

+149
-3
lines changed

src/server/services/wms/qgswmsrenderer.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,8 @@ namespace QgsWms
23222322
double mapUnitTolerance = 0.0;
23232323
if ( ml->geometryType() == QgsWkbTypes::PolygonGeometry )
23242324
{
2325-
if ( ! mWmsParameters.polygonTolerance().isEmpty() )
2325+
if ( ! mWmsParameters.polygonTolerance().isEmpty()
2326+
&& mWmsParameters.polygonToleranceAsInt() > 0 )
23262327
{
23272328
mapUnitTolerance = mWmsParameters.polygonToleranceAsInt() * rct.mapToPixel().mapUnitsPerPixel();
23282329
}
@@ -2333,7 +2334,8 @@ namespace QgsWms
23332334
}
23342335
else if ( ml->geometryType() == QgsWkbTypes::LineGeometry )
23352336
{
2336-
if ( ! mWmsParameters.lineTolerance().isEmpty() )
2337+
if ( ! mWmsParameters.lineTolerance().isEmpty()
2338+
&& mWmsParameters.lineToleranceAsInt() > 0 )
23372339
{
23382340
mapUnitTolerance = mWmsParameters.lineToleranceAsInt() * rct.mapToPixel().mapUnitsPerPixel();
23392341
}
@@ -2344,7 +2346,8 @@ namespace QgsWms
23442346
}
23452347
else //points
23462348
{
2347-
if ( ! mWmsParameters.pointTolerance().isEmpty() )
2349+
if ( ! mWmsParameters.pointTolerance().isEmpty()
2350+
&& mWmsParameters.pointToleranceAsInt() > 0 )
23482351
{
23492352
mapUnitTolerance = mWmsParameters.pointToleranceAsInt() * rct.mapToPixel().mapUnitsPerPixel();
23502353
}

tests/src/python/test_qgsserver_wms_getfeatureinfo.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,91 @@ def testGetFeatureInfoFilter(self):
322322
'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib.parse.quote(':"NAME" = \'two\''),
323323
'wms_getfeatureinfo_filter_no_width')
324324

325+
def testGetFeatureInfoTolerance(self):
326+
self.wms_request_compare('GetFeatureInfo',
327+
'&layers=layer3&styles=&' +
328+
'VERSION=1.3.0&' +
329+
'info_format=text%2Fxml&' +
330+
'width=400&height=200' +
331+
'&bbox=913119.2,5605988.9,913316.0,5606047.4' +
332+
'&CRS=EPSG:3857' +
333+
'&FEATURE_COUNT=10' +
334+
'&WITH_GEOMETRY=False' +
335+
'&QUERY_LAYERS=layer3&I=193&J=100' +
336+
'&FI_POINT_TOLERANCE=0',
337+
'wms_getfeatureinfo_point_tolerance_0_text_xml',
338+
'test_project_values.qgz')
339+
340+
self.wms_request_compare('GetFeatureInfo',
341+
'&layers=layer3&styles=&' +
342+
'VERSION=1.3.0&' +
343+
'info_format=text%2Fxml&' +
344+
'width=400&height=200' +
345+
'&bbox=913119.2,5605988.9,913316.0,5606047.4' +
346+
'&CRS=EPSG:3857' +
347+
'&FEATURE_COUNT=10' +
348+
'&WITH_GEOMETRY=False' +
349+
'&QUERY_LAYERS=layer3&I=193&J=100' +
350+
'&FI_POINT_TOLERANCE=20',
351+
'wms_getfeatureinfo_point_tolerance_20_text_xml',
352+
'test_project_values.qgz')
353+
354+
self.wms_request_compare('GetFeatureInfo',
355+
'&layers=ls2d&styles=&' +
356+
'VERSION=1.3.0&' +
357+
'info_format=text%2Fxml&' +
358+
'width=400&height=200' +
359+
'&bbox=-50396.4,-2783.0,161715.8,114108.6' +
360+
'&CRS=EPSG:3857' +
361+
'&FEATURE_COUNT=10' +
362+
'&WITH_GEOMETRY=False' +
363+
'&QUERY_LAYERS=ls2d&I=153&J=147' +
364+
'&FI_LINE_TOLERANCE=0',
365+
'wms_getfeatureinfo_line_tolerance_0_text_xml',
366+
'test_project_values.qgz')
367+
368+
self.wms_request_compare('GetFeatureInfo',
369+
'&layers=ls2d&styles=&' +
370+
'VERSION=1.3.0&' +
371+
'info_format=text%2Fxml&' +
372+
'width=400&height=200' +
373+
'&bbox=-50396.4,-2783.0,161715.8,114108.6' +
374+
'&CRS=EPSG:3857' +
375+
'&FEATURE_COUNT=10' +
376+
'&WITH_GEOMETRY=False' +
377+
'&QUERY_LAYERS=ls2d&I=153&J=147' +
378+
'&FI_LINE_TOLERANCE=20',
379+
'wms_getfeatureinfo_line_tolerance_20_text_xml',
380+
'test_project_values.qgz')
381+
382+
self.wms_request_compare('GetFeatureInfo',
383+
'&layers=p2d&styles=&' +
384+
'VERSION=1.3.0&' +
385+
'info_format=text%2Fxml&' +
386+
'width=400&height=200' +
387+
'&bbox=-135832.0,-66482.4,240321.9,167300.4' +
388+
'&CRS=EPSG:3857' +
389+
'&FEATURE_COUNT=10' +
390+
'&WITH_GEOMETRY=False' +
391+
'&QUERY_LAYERS=p2d&I=206&J=144' +
392+
'&FI_POLYGON_TOLERANCE=0',
393+
'wms_getfeatureinfo_polygon_tolerance_0_text_xml',
394+
'test_project_values.qgz')
395+
396+
self.wms_request_compare('GetFeatureInfo',
397+
'&layers=p2d&styles=&' +
398+
'VERSION=1.3.0&' +
399+
'info_format=text%2Fxml&' +
400+
'width=400&height=200' +
401+
'&bbox=-135832.0,-66482.4,240321.9,167300.4' +
402+
'&CRS=EPSG:3857' +
403+
'&FEATURE_COUNT=10' +
404+
'&WITH_GEOMETRY=False' +
405+
'&QUERY_LAYERS=p2d&I=206&J=144' +
406+
'&FI_POLYGON_TOLERANCE=20',
407+
'wms_getfeatureinfo_polygon_tolerance_20_text_xml',
408+
'test_project_values.qgz')
409+
325410

326411
if __name__ == '__main__':
327412
unittest.main()

tests/testdata/qgis_server/db.gpkg

0 Bytes
Binary file not shown.
805 Bytes
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*****
2+
Content-Type: text/xml; charset=utf-8
3+
4+
<GetFeatureInfoResponse>
5+
<Layer name="ls2d">
6+
</GetFeatureInfoResponse>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*****
2+
Content-Type: text/xml; charset=utf-8
3+
4+
<GetFeatureInfoResponse>
5+
<Layer name="ls2d">
6+
<Feature id="1">
7+
<Attribute value="1" name="id"/>
8+
</Feature>
9+
</Layer>
10+
</GetFeatureInfoResponse>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*****
2+
Content-Type: text/xml; charset=utf-8
3+
4+
<GetFeatureInfoResponse>
5+
<Layer name="layer3">
6+
<Feature id="2">
7+
<Attribute value="2" name="id"/>
8+
<Attribute value="" name="location"/>
9+
</Feature>
10+
</Layer>
11+
</GetFeatureInfoResponse>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*****
2+
Content-Type: text/xml; charset=utf-8
3+
4+
<GetFeatureInfoResponse>
5+
<Layer name="layer3">
6+
<Feature id="1">
7+
<Attribute value="1" name="id"/>
8+
<Attribute value="Id no. 1 value, Id no. 2 value, Id número 3 value" name="location"/>
9+
</Feature>
10+
<Feature id="2">
11+
<Attribute value="2" name="id"/>
12+
<Attribute value="" name="location"/>
13+
</Feature>
14+
</Layer>
15+
</GetFeatureInfoResponse>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*****
2+
Content-Type: text/xml; charset=utf-8
3+
4+
<GetFeatureInfoResponse>
5+
<Layer name="p2d">
6+
</GetFeatureInfoResponse>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*****
2+
Content-Type: text/xml; charset=utf-8
3+
4+
<GetFeatureInfoResponse>
5+
<Layer name="p2d">
6+
<Feature id="1">
7+
<Attribute value="1" name="id"/>
8+
</Feature>
9+
</Layer>
10+
</GetFeatureInfoResponse>

0 commit comments

Comments
 (0)