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 272a7ae commit ba2dd71bc68998e762ffea3bdd3269d6716f2eeb
Showing with 30 additions and 15 deletions.
  1. +30 −15 src/server/qgswmsserver.cpp
@@ -2220,35 +2220,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
@@ -2342,7 +2353,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() );
@@ -2354,7 +2365,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 )
@@ -2374,6 +2385,10 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
}
}
}
if ( r2 )
{
r2->stopRender( renderContext );
}

return 0;
}

0 comments on commit ba2dd71

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