Skip to content
Permalink
Browse files

Merge pull request #34802 from rldhont/backport-34697-release-3_10

[Backport Release-3_10][Bugfix][Server] WMS GetFeatureInfo provides bounding box when configured
  • Loading branch information
rldhont committed Mar 1, 2020
2 parents 9c284e1 + bcffd46 commit a1a5ed3f6c15dc3062f39e6f4e3ab7e5cf397ed6
@@ -1395,7 +1395,7 @@ namespace QgsWms
bool segmentizeWktGeometry = QgsServerProjectUtils::wmsFeatureInfoSegmentizeWktGeometry( *mProject );
const QSet<QString> &excludedAttributes = layer->excludeAttributesWms();

bool hasGeometry = addWktGeometry || featureBBox || layerFilterGeom;
bool hasGeometry = QgsServerProjectUtils::wmsFeatureInfoAddWktGeometry( *mProject ) || addWktGeometry || featureBBox || layerFilterGeom;
fReq.setFlags( ( ( hasGeometry ) ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry ) | QgsFeatureRequest::ExactIntersect );

if ( ! searchRect.isEmpty() )
@@ -1553,7 +1553,8 @@ namespace QgsWms
}

//append feature bounding box to feature info xml
if ( layer->wkbType() != QgsWkbTypes::NoGeometry && hasGeometry )
if ( QgsServerProjectUtils::wmsFeatureInfoAddWktGeometry( *mProject ) &&
layer->wkbType() != QgsWkbTypes::NoGeometry && hasGeometry )
{
QDomElement bBoxElem = infoDocument.createElement( QStringLiteral( "BoundingBox" ) );
bBoxElem.setAttribute( version == QLatin1String( "1.1.1" ) ? "SRS" : "CRS", outputCrs.authid() );
@@ -2285,8 +2286,11 @@ namespace QgsWms
expressionContext << QgsExpressionContextUtils::layerScope( layer );
expressionContext.setFeature( *feat );

// always add bounding box info if feature contains geometry
if ( !geom.isNull() && geom.type() != QgsWkbTypes::UnknownGeometry && geom.type() != QgsWkbTypes::NullGeometry )
// always add bounding box info if feature contains geometry and has been
// explicitly configured in the project
if ( QgsServerProjectUtils::wmsFeatureInfoAddWktGeometry( *mProject ) &&
!geom.isNull() && geom.type() != QgsWkbTypes::UnknownGeometry &&
geom.type() != QgsWkbTypes::NullGeometry )
{
QgsRectangle box = feat->geometry().boundingBox();
if ( transform.isValid() )
@@ -7,6 +7,7 @@ Content-Type: text/xml; charset=utf-8
<Attribute value="3" name="id"/>
<Attribute value="three" name="name"/>
<Attribute value="three èé↓" name="utf8nameè"/>
<BoundingBox maxy="5606011.4565" maxx="913204.9128" miny="5606011.4565" CRS="EPSG:3857" minx="913204.9128"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>
@@ -7,6 +7,7 @@ Content-Type: text/xml; charset=utf-8
<Attribute value="3" name="id"/>
<Attribute value="three" name="name"/>
<Attribute value="three èé↓" name="utf8nameè"/>
<BoundingBox maxy="5606011.4565" maxx="913204.9128" miny="5606011.4565" CRS="EPSG:3857" minx="913204.9128"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>
@@ -9,6 +9,7 @@ Content-Type: text/xml; charset=utf-8
<Attribute value="three èé↓" name="utf8nameè"/>
<Attribute value="123456" name="long_int"/>
<Attribute value="123456.8900" name="long_float"/>
<BoundingBox maxy="5606011.4565" maxx="913204.9128" miny="5606011.4565" CRS="EPSG:3857" minx="913204.9128"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>
@@ -7,16 +7,19 @@ Content-Type: text/xml; charset=utf-8
<Attribute value="1" name="id"/>
<Attribute value="one" name="name"/>
<Attribute value="First Value" name="utf8nameè"/>
<BoundingBox maxy="5606025.2373" maxx="913209.0358" miny="5606025.2373" CRS="EPSG:3857" minx="913209.0358"/>
</Feature>
<Feature id="2">
<Attribute value="2" name="id"/>
<Attribute value="two" name="name"/>
<Attribute value="Second Value" name="utf8nameè"/>
<BoundingBox maxy="5606017.8743" maxx="913214.6741" miny="5606017.8743" CRS="EPSG:3857" minx="913214.6741"/>
</Feature>
<Feature id="3">
<Attribute value="3" name="id"/>
<Attribute value="three" name="name"/>
<Attribute value="Third èé↓" name="utf8nameè"/>
<BoundingBox maxy="5606011.4565" maxx="913204.9128" miny="5606011.4565" CRS="EPSG:3857" minx="913204.9128"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>
@@ -5,6 +5,7 @@ Content-Type: text/xml; charset=utf-8
<Layer name="ls2d">
<Feature id="1">
<Attribute value="1" name="id"/>
<BoundingBox maxy="111325.1429" maxx="111319.4908" miny="-0" CRS="EPSG:3857" minx="0"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>
@@ -7,6 +7,7 @@ Content-Type: text/xml; charset=utf-8
<Attribute value="3" name="id"/>
<Attribute value="three" name="name"/>
<Attribute value="three èé↓" name="utf8nameè"/>
<BoundingBox maxy="44.9014" maxx="8.2035" miny="44.9014" CRS="EPSG:4326" minx="8.2035"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>
@@ -6,6 +6,7 @@ Content-Type: text/xml; charset=utf-8
<Feature id="2">
<Attribute value="2" name="id"/>
<Attribute value="" name="location"/>
<BoundingBox maxy="5606017.8743" maxx="913214.6741" miny="5606017.8743" CRS="EPSG:3857" minx="913214.6741"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>
@@ -6,10 +6,12 @@ Content-Type: text/xml; charset=utf-8
<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"/>
<BoundingBox maxy="5606025.2373" maxx="913209.0358" miny="5606025.2373" CRS="EPSG:3857" minx="913209.0358"/>
</Feature>
<Feature id="2">
<Attribute value="2" name="id"/>
<Attribute value="" name="location"/>
<BoundingBox maxy="5606017.8743" maxx="913214.6741" miny="5606017.8743" CRS="EPSG:3857" minx="913214.6741"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>
@@ -5,6 +5,7 @@ Content-Type: text/xml; charset=utf-8
<Layer name="p2d">
<Feature id="1">
<Attribute value="1" name="id"/>
<BoundingBox maxy="111325.1429" maxx="111319.4908" miny="-0" CRS="EPSG:3857" minx="0"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>

0 comments on commit a1a5ed3

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