|
36 | 36 | #include "qgssymbol.h"
|
37 | 37 | #include "qgssymbolv2.h"
|
38 | 38 | #include "qgsrenderer.h"
|
| 39 | +#include "qgsrendererv2.h" |
39 | 40 | #include "qgslegendmodel.h"
|
40 | 41 | #include "qgscomposerlegenditem.h"
|
41 | 42 | #include "qgslogger.h"
|
@@ -624,7 +625,8 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result )
|
624 | 625 | //find out the current scale denominater and set it to the SLD parser
|
625 | 626 | QgsScaleCalculator scaleCalc(( outputImage->logicalDpiX() + outputImage->logicalDpiY() ) / 2 , mMapRenderer->destinationCrs().mapUnits() );
|
626 | 627 | QgsRectangle mapExtent = mMapRenderer->extent();
|
627 |
| - mConfigParser->setScaleDenominator( scaleCalc.calculate( mapExtent, outputImage->width() ) ); |
| 628 | + double scaleDenominator = scaleCalc.calculate( mapExtent, outputImage->width() ); |
| 629 | + mConfigParser->setScaleDenominator( scaleDenominator ); |
628 | 630 | delete outputImage; //no longer needed for feature info
|
629 | 631 |
|
630 | 632 | //read FEATURE_COUNT
|
@@ -742,6 +744,12 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result )
|
742 | 744 | continue;
|
743 | 745 | }
|
744 | 746 |
|
| 747 | + //skip layer if not visible at current map scale |
| 748 | + if ( currentLayer->hasScaleBasedVisibility() && ( currentLayer->minimumScale() > scaleDenominator || currentLayer->maximumScale() < scaleDenominator ) ) |
| 749 | + { |
| 750 | + continue; |
| 751 | + } |
| 752 | + |
745 | 753 | if ( infoPoint && infoPointToLayerCoordinates( i, j, infoPoint, mMapRenderer, currentLayer ) != 0 )
|
746 | 754 | {
|
747 | 755 | continue;
|
@@ -1216,6 +1224,24 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
|
1216 | 1224 | break;
|
1217 | 1225 | }
|
1218 | 1226 |
|
| 1227 | + //check if feature is rendered at all |
| 1228 | + if ( layer->isUsingRendererV2() ) |
| 1229 | + { |
| 1230 | + QgsFeatureRendererV2* r2 = layer->rendererV2(); |
| 1231 | + if ( !r2 || !r2->symbolForFeature( feature ) ) |
| 1232 | + { |
| 1233 | + continue; |
| 1234 | + } |
| 1235 | + } |
| 1236 | + else |
| 1237 | + { |
| 1238 | + QgsRenderer* r = const_cast<QgsRenderer*>( layer->renderer() ); //bad, 'willRenderFeature' should be const |
| 1239 | + if ( !r || !r->willRenderFeature( &feature ) ) |
| 1240 | + { |
| 1241 | + continue; |
| 1242 | + } |
| 1243 | + } |
| 1244 | + |
1219 | 1245 | QDomElement featureElement = infoDocument.createElement( "Feature" );
|
1220 | 1246 | featureElement.setAttribute( "id", FID_TO_STRING( feature.id() ) );
|
1221 | 1247 | layerElement.appendChild( featureElement );
|
|
0 commit comments