Skip to content
Permalink
Browse files

Merge pull request #8199 from pblottiere/server_getfeatureinfo_tolerance

[bugfix] Fixes #19383 - GetFeatureInfo tolerance
  • Loading branch information
rldhont committed Oct 16, 2018
2 parents fff0c03 + c3a41bc commit e10736ae7bbfd819fff6ebbca644b2ee77842fc3
@@ -2322,7 +2322,8 @@ namespace QgsWms
double mapUnitTolerance = 0.0;
if ( ml->geometryType() == QgsWkbTypes::PolygonGeometry )
{
if ( ! mWmsParameters.polygonTolerance().isEmpty() )
if ( ! mWmsParameters.polygonTolerance().isEmpty()
&& mWmsParameters.polygonToleranceAsInt() > 0 )
{
mapUnitTolerance = mWmsParameters.polygonToleranceAsInt() * rct.mapToPixel().mapUnitsPerPixel();
}
@@ -2333,7 +2334,8 @@ namespace QgsWms
}
else if ( ml->geometryType() == QgsWkbTypes::LineGeometry )
{
if ( ! mWmsParameters.lineTolerance().isEmpty() )
if ( ! mWmsParameters.lineTolerance().isEmpty()
&& mWmsParameters.lineToleranceAsInt() > 0 )
{
mapUnitTolerance = mWmsParameters.lineToleranceAsInt() * rct.mapToPixel().mapUnitsPerPixel();
}
@@ -2344,7 +2346,8 @@ namespace QgsWms
}
else //points
{
if ( ! mWmsParameters.pointTolerance().isEmpty() )
if ( ! mWmsParameters.pointTolerance().isEmpty()
&& mWmsParameters.pointToleranceAsInt() > 0 )
{
mapUnitTolerance = mWmsParameters.pointToleranceAsInt() * rct.mapToPixel().mapUnitsPerPixel();
}
@@ -322,6 +322,91 @@ def testGetFeatureInfoFilter(self):
'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib.parse.quote(':"NAME" = \'two\''),
'wms_getfeatureinfo_filter_no_width')

def testGetFeatureInfoTolerance(self):
self.wms_request_compare('GetFeatureInfo',
'&layers=layer3&styles=&' +
'VERSION=1.3.0&' +
'info_format=text%2Fxml&' +
'width=400&height=200' +
'&bbox=913119.2,5605988.9,913316.0,5606047.4' +
'&CRS=EPSG:3857' +
'&FEATURE_COUNT=10' +
'&WITH_GEOMETRY=False' +
'&QUERY_LAYERS=layer3&I=193&J=100' +
'&FI_POINT_TOLERANCE=0',
'wms_getfeatureinfo_point_tolerance_0_text_xml',
'test_project_values.qgz')

self.wms_request_compare('GetFeatureInfo',
'&layers=layer3&styles=&' +
'VERSION=1.3.0&' +
'info_format=text%2Fxml&' +
'width=400&height=200' +
'&bbox=913119.2,5605988.9,913316.0,5606047.4' +
'&CRS=EPSG:3857' +
'&FEATURE_COUNT=10' +
'&WITH_GEOMETRY=False' +
'&QUERY_LAYERS=layer3&I=193&J=100' +
'&FI_POINT_TOLERANCE=20',
'wms_getfeatureinfo_point_tolerance_20_text_xml',
'test_project_values.qgz')

self.wms_request_compare('GetFeatureInfo',
'&layers=ls2d&styles=&' +
'VERSION=1.3.0&' +
'info_format=text%2Fxml&' +
'width=400&height=200' +
'&bbox=-50396.4,-2783.0,161715.8,114108.6' +
'&CRS=EPSG:3857' +
'&FEATURE_COUNT=10' +
'&WITH_GEOMETRY=False' +
'&QUERY_LAYERS=ls2d&I=153&J=147' +
'&FI_LINE_TOLERANCE=0',
'wms_getfeatureinfo_line_tolerance_0_text_xml',
'test_project_values.qgz')

self.wms_request_compare('GetFeatureInfo',
'&layers=ls2d&styles=&' +
'VERSION=1.3.0&' +
'info_format=text%2Fxml&' +
'width=400&height=200' +
'&bbox=-50396.4,-2783.0,161715.8,114108.6' +
'&CRS=EPSG:3857' +
'&FEATURE_COUNT=10' +
'&WITH_GEOMETRY=False' +
'&QUERY_LAYERS=ls2d&I=153&J=147' +
'&FI_LINE_TOLERANCE=20',
'wms_getfeatureinfo_line_tolerance_20_text_xml',
'test_project_values.qgz')

self.wms_request_compare('GetFeatureInfo',
'&layers=p2d&styles=&' +
'VERSION=1.3.0&' +
'info_format=text%2Fxml&' +
'width=400&height=200' +
'&bbox=-135832.0,-66482.4,240321.9,167300.4' +
'&CRS=EPSG:3857' +
'&FEATURE_COUNT=10' +
'&WITH_GEOMETRY=False' +
'&QUERY_LAYERS=p2d&I=206&J=144' +
'&FI_POLYGON_TOLERANCE=0',
'wms_getfeatureinfo_polygon_tolerance_0_text_xml',
'test_project_values.qgz')

self.wms_request_compare('GetFeatureInfo',
'&layers=p2d&styles=&' +
'VERSION=1.3.0&' +
'info_format=text%2Fxml&' +
'width=400&height=200' +
'&bbox=-135832.0,-66482.4,240321.9,167300.4' +
'&CRS=EPSG:3857' +
'&FEATURE_COUNT=10' +
'&WITH_GEOMETRY=False' +
'&QUERY_LAYERS=p2d&I=206&J=144' +
'&FI_POLYGON_TOLERANCE=20',
'wms_getfeatureinfo_polygon_tolerance_20_text_xml',
'test_project_values.qgz')


if __name__ == '__main__':
unittest.main()
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
*****
Content-Type: text/xml; charset=utf-8

<GetFeatureInfoResponse>
<Layer name="ls2d">
</GetFeatureInfoResponse>
@@ -0,0 +1,10 @@
*****
Content-Type: text/xml; charset=utf-8

<GetFeatureInfoResponse>
<Layer name="ls2d">
<Feature id="1">
<Attribute value="1" name="id"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>
@@ -0,0 +1,11 @@
*****
Content-Type: text/xml; charset=utf-8

<GetFeatureInfoResponse>
<Layer name="layer3">
<Feature id="2">
<Attribute value="2" name="id"/>
<Attribute value="" name="location"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>
@@ -0,0 +1,15 @@
*****
Content-Type: text/xml; charset=utf-8

<GetFeatureInfoResponse>
<Layer name="layer3">
<Feature id="1">
<Attribute value="1" name="id"/>
<Attribute value="Id no. 1 value, Id no. 2 value, Id número 3 value" name="location"/>
</Feature>
<Feature id="2">
<Attribute value="2" name="id"/>
<Attribute value="" name="location"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>
@@ -0,0 +1,6 @@
*****
Content-Type: text/xml; charset=utf-8

<GetFeatureInfoResponse>
<Layer name="p2d">
</GetFeatureInfoResponse>
@@ -0,0 +1,10 @@
*****
Content-Type: text/xml; charset=utf-8

<GetFeatureInfoResponse>
<Layer name="p2d">
<Feature id="1">
<Attribute value="1" name="id"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>

0 comments on commit e10736a

Please sign in to comment.
You can’t perform that action at this time.