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 8f4405f commit e63973076aca254cbf90ee16e23e4873443f509b
Showing with 30 additions and 15 deletions.
  1. +30 −15 src/server/qgswmsserver.cpp
@@ -2221,35 +2221,46 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
#endif

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

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

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

QgsFeatureRendererV2* r2 = layer->rendererV2();
if ( !r2 )
if ( layer->wkbType() != QGis::WKBNoGeometry && ! 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 renderV2 = r2->willRenderFeature( feature, renderContext );
r2->stopRender( renderContext );
if ( !renderV2 )
{
continue;

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

QgsRectangle box;
if ( hasGeometry )
if ( layer->wkbType() != QGis::WKBNoGeometry && hasGeometry )
{
box = mapRender->layerExtentToOutputExtent( layer, feature.constGeometry()->boundingBox() );
if ( featureBBox ) //extend feature info bounding box if requested
@@ -2343,7 +2354,7 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
}

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

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

return 0;
}

0 comments on commit e639730

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