Skip to content
Permalink
Browse files
Don't show invisible layers and features in wms server feature info
  • Loading branch information
marco committed Nov 13, 2011
1 parent 41de1a0 commit 9adb57ebae32136b77743e02100ea0536ab00800
Showing with 27 additions and 1 deletion.
  1. +27 −1 src/mapserver/qgswmsserver.cpp
@@ -36,6 +36,7 @@
#include "qgssymbol.h"
#include "qgssymbolv2.h"
#include "qgsrenderer.h"
#include "qgsrendererv2.h"
#include "qgslegendmodel.h"
#include "qgscomposerlegenditem.h"
#include "qgslogger.h"
@@ -624,7 +625,8 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result )
//find out the current scale denominater and set it to the SLD parser
QgsScaleCalculator scaleCalc(( outputImage->logicalDpiX() + outputImage->logicalDpiY() ) / 2 , mMapRenderer->destinationCrs().mapUnits() );
QgsRectangle mapExtent = mMapRenderer->extent();
mConfigParser->setScaleDenominator( scaleCalc.calculate( mapExtent, outputImage->width() ) );
double scaleDenominator = scaleCalc.calculate( mapExtent, outputImage->width() );
mConfigParser->setScaleDenominator( scaleDenominator );
delete outputImage; //no longer needed for feature info

//read FEATURE_COUNT
@@ -742,6 +744,12 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result )
continue;
}

//skip layer if not visible at current map scale
if ( currentLayer->hasScaleBasedVisibility() && ( currentLayer->minimumScale() > scaleDenominator || currentLayer->maximumScale() < scaleDenominator ) )
{
continue;
}

if ( infoPoint && infoPointToLayerCoordinates( i, j, infoPoint, mMapRenderer, currentLayer ) != 0 )
{
continue;
@@ -1216,6 +1224,24 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
break;
}

//check if feature is rendered at all
if ( layer->isUsingRendererV2() )
{
QgsFeatureRendererV2* r2 = layer->rendererV2();
if ( !r2 || !r2->symbolForFeature( feature ) )
{
continue;
}
}
else
{
QgsRenderer* r = const_cast<QgsRenderer*>( layer->renderer() ); //bad, 'willRenderFeature' should be const
if ( !r || !r->willRenderFeature( &feature ) )
{
continue;
}
}

QDomElement featureElement = infoDocument.createElement( "Feature" );
featureElement.setAttribute( "id", FID_TO_STRING( feature.id() ) );
layerElement.appendChild( featureElement );

0 comments on commit 9adb57e

Please sign in to comment.