Skip to content
Permalink
Browse files

[BUGFIX][QGIS Server] GetFeatureInfo: Feature with no geometry is not…

… returned even if FILTER param is set
  • Loading branch information
rldhont committed Oct 17, 2016
1 parent 52a0082 commit 697cd1bb7d8aaf296ea7342a114645e3e47e695b
Showing with 29 additions and 15 deletions.
  1. +29 −15 src/server/qgswmsserver.cpp
@@ -2225,35 +2225,45 @@ int QgsWmsServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
#endif

QgsFeatureIterator fit = layer->getFeatures( fReq );
QgsFeatureRenderer* r2 = layer->renderer();
if ( r2 )
{
r2->startRender( renderContext, layer->pendingFields() );
}

bool featureBBoxInitialized = false;
while ( fit.nextFeature( feature ) )
{
if ( layer->wkbType() == QgsWkbTypes::NoGeometry && ! searchRect.isEmpty() )
{
break;
}

++featureCounter;
if ( featureCounter > nFeatures )
{
break;
}

QgsFeatureRenderer* r2 = layer->renderer();
if ( !r2 )
if ( layer->wkbType() != QgsWkbTypes::NoGeometry && ! searchRect.isEmpty() )
{
continue;
}
if ( !r2 )
{
continue;
}

renderContext.expressionContext().setFeature( feature );
renderContext.expressionContext().setFeature( feature );

//check if feature is rendered at all
r2->startRender( renderContext, layer->pendingFields() );
bool render = r2->willRenderFeature( feature, renderContext );
r2->stopRender( renderContext );
if ( !render )
{
continue;
//check if feature is rendered at all
bool render = r2->willRenderFeature( feature, renderContext );
if ( !render )
{
continue;
}
}

QgsRectangle box;
if ( hasGeometry )
if ( layer->wkbType() != QgsWkbTypes::NoGeometry && hasGeometry )
{
box = mapRender->layerExtentToOutputExtent( layer, feature.geometry().boundingBox() );
if ( featureBBox ) //extend feature info bounding box if requested
@@ -2344,7 +2354,7 @@ int QgsWmsServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
}

//append feature bounding box to feature info xml
if ( hasGeometry && mapRender && mConfigParser )
if ( layer->wkbType() != QgsWkbTypes::NoGeometry && hasGeometry && mapRender && mConfigParser )
{
QDomElement bBoxElem = infoDocument.createElement( "BoundingBox" );
bBoxElem.setAttribute( version == "1.1.1" ? "SRS" : "CRS", outputCrs.authid() );
@@ -2356,7 +2366,7 @@ int QgsWmsServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
}

//also append the wkt geometry as an attribute
if ( addWktGeometry && hasGeometry )
if ( layer->wkbType() != QgsWkbTypes::NoGeometry && addWktGeometry && hasGeometry )
{
QgsGeometry geom = feature.geometry();
if ( !geom.isEmpty() )
@@ -2389,6 +2399,10 @@ int QgsWmsServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
}
}
}
if ( r2 )
{
r2->stopRender( renderContext );
}

return 0;
}

0 comments on commit 697cd1b

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