[SCM] qgis branch, master, updated. a2ee769957385f4e084c5e8b6ba178a8c877d1db
Marco Hugentobler
marco.hugentobler at sourcepole.ch
Tue Mar 20 13:42:38 UTC 2012
The following commit has been merged in the master branch:
commit 203cb9b75d63990a0da5195dd2ea20b6a7ecb8fd
Author: Marco Hugentobler <marco.hugentobler at sourcepole.ch>
Date: Fri Mar 2 13:52:52 2012 +0100
WMS server: create rendercontext to find out visible features
diff --git a/src/mapserver/qgswmsserver.cpp b/src/mapserver/qgswmsserver.cpp
index b9ca981..61ca3d7 100644
--- a/src/mapserver/qgswmsserver.cpp
+++ b/src/mapserver/qgswmsserver.cpp
@@ -810,6 +810,18 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
QMap< QString, QMap< int, QString > > aliasInfo = mConfigParser->layerAliasInfo();
QMap< QString, QSet<QString> > hiddenAttributes = mConfigParser->hiddenAttributes();
+ //Render context is needed to determine feature visibility for vector layers
+ QgsRenderContext renderContext;
+ if ( mMapRenderer )
+ {
+ renderContext.setExtent( mMapRenderer->extent() );
+ renderContext.setRasterScaleFactor( 1.0 );
+ renderContext.setMapToPixel( *( mMapRenderer->coordinateTransform() ) );
+ renderContext.setRendererScale( mMapRenderer->scale() );
+ renderContext.setScaleFactor( mMapRenderer->outputDpi() / 25.4 );
+ renderContext.setPainter( 0 );
+ }
+
QList<QgsMapLayer*> layerList;
QgsMapLayer* currentLayer = 0;
QStringList::const_iterator layerIt;
@@ -861,7 +873,8 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
layerHiddenAttributes = hiddenIt.value();
}
- if ( featureInfoFromVectorLayer( vectorLayer, infoPoint, featureCount, result, layerElement, mMapRenderer, layerAliasInfo, layerHiddenAttributes, version, featuresRect ) != 0 )
+ if ( featureInfoFromVectorLayer( vectorLayer, infoPoint, featureCount, result, layerElement, mMapRenderer, renderContext,
+ layerAliasInfo, layerHiddenAttributes, version, featuresRect ) != 0 )
{
continue;
}
@@ -1207,6 +1220,7 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
QDomDocument& infoDocument,
QDomElement& layerElement,
QgsMapRenderer* mapRender,
+ QgsRenderContext& renderContext,
QMap<int, QString>& aliasMap,
QSet<QString>& hiddenAttributes,
QString version,
@@ -1226,7 +1240,7 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
//info point could be 0 in case there is only an attribute filter
if ( infoPoint )
{
- double searchRadius = ( layerRect.xMaximum() - layerRect.xMinimum() ) / 200;
+ double searchRadius = ( layerRect.xMaximum() - layerRect.xMinimum() ) / 100;
searchRect.set( infoPoint->x() - searchRadius, infoPoint->y() - searchRadius,
infoPoint->x() + searchRadius, infoPoint->y() + searchRadius );
}
@@ -1262,10 +1276,9 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
continue;
}
- QgsRenderContext c;
- r2->startRender( c, layer );
+ r2->startRender( renderContext, layer );
bool renderV2 = r2->willRenderFeature( feature );
- r2->stopRender( c );
+ r2->stopRender( renderContext );
if ( !renderV2 )
{
continue;
diff --git a/src/mapserver/qgswmsserver.h b/src/mapserver/qgswmsserver.h
index f89b1ba..79ef589 100644
--- a/src/mapserver/qgswmsserver.h
+++ b/src/mapserver/qgswmsserver.h
@@ -33,6 +33,7 @@ class QgsMapRenderer;
class QgsPoint;
class QgsRasterLayer;
class QgsRectangle;
+class QgsRenderContext;
class QgsVectorLayer;
class QgsSymbol;
class QColor;
@@ -114,7 +115,7 @@ class QgsWMSServer
@param featureBBox the bounding box of the selected features in output CRS
@return 0 in case of success*/
int featureInfoFromVectorLayer( QgsVectorLayer* layer, const QgsPoint* infoPoint, int nFeatures, QDomDocument& infoDocument, QDomElement& layerElement, QgsMapRenderer* mapRender,
- QMap<int, QString>& aliasMap, QSet<QString>& hiddenAttributes, QString version, QgsRectangle* featureBBox = 0 ) const;
+ QgsRenderContext& renderContext, QMap<int, QString>& aliasMap, QSet<QString>& hiddenAttributes, QString version, QgsRectangle* featureBBox = 0 ) const;
/**Appends feature info xml for the layer to the layer element of the dom document*/
int featureInfoFromRasterLayer( QgsRasterLayer* layer, const QgsPoint* infoPoint, QDomDocument& infoDocument, QDomElement& layerElement, QString version ) const;
--
The Quantum GIS in Debian project
More information about the Pkg-grass-devel
mailing list