Skip to content

Commit

Permalink
[BUGFIX][QGIS Server] GetFeatureInfo: Feature with no geometry is not…
Browse files Browse the repository at this point in the history
… returned even if FILTER param is set
  • Loading branch information
rldhont committed Oct 17, 2016
1 parent 8f4405f commit e639730
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions src/server/qgswmsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() );
Expand All @@ -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 )
Expand Down Expand Up @@ -2388,6 +2399,10 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
}
}
}
if ( r2 )
{
r2->stopRender( renderContext );
}

return 0;
}
Expand Down

0 comments on commit e639730

Please sign in to comment.