Skip to content
Permalink
Browse files

[FEATURE]: Fetch geometry and maptip in feature info only if requeste…

…d by the client
  • Loading branch information
mhugent committed Oct 24, 2017
1 parent 5261a9a commit 5bd63b7e1789a72c2692d8d61fab267ec2258eb5
@@ -462,6 +462,20 @@ namespace QgsWms
QVariant()
};
save( pGridY );

const Parameter pWithGeometry = { ParameterName::WITH_GEOMETRY,
QVariant::Bool,
QVariant( false ),
QVariant()
};
save( pWithGeometry );

const Parameter pWithMapTip = { ParameterName::WITH_MAPTIP,
QVariant::Bool,
QVariant( false ),
QVariant()
};
save( pWithMapTip );
}

QgsWmsParameters::QgsWmsParameters( const QgsServerRequest::Parameters &parameters )
@@ -1908,6 +1922,16 @@ namespace QgsWms
return wmsUri.encodedUri();
}

bool QgsWmsParameters::withGeometry() const
{
return toBool( ParameterName::WITH_GEOMETRY );
}

bool QgsWmsParameters::withMapTip() const
{
return toBool( ParameterName::WITH_MAPTIP );
}

QString QgsWmsParameters::name( ParameterName name ) const
{
const QMetaEnum metaEnum( QMetaEnum::fromType<ParameterName>() );
@@ -141,7 +141,9 @@ namespace QgsWms
EXTENT,
ROTATION,
GRID_INTERVAL_X,
GRID_INTERVAL_Y
GRID_INTERVAL_Y,
WITH_GEOMETRY,
WITH_MAPTIP
};
Q_ENUM( ParameterName )

@@ -916,6 +918,18 @@ namespace QgsWms
*/
QString externalWMSUri( const QString &id ) const;

/**
* @brief Returns if the client wants the feature info response with geometry information
* @return true if geometry information is requested for feature info response
*/
bool withGeometry() const;

/**
* @brief withMapTip
* @return true if maptip information is requested for feature info response
*/
bool withMapTip() const;

private:
QString name( ParameterName name ) const;
void raiseError( ParameterName name ) const;
@@ -1426,7 +1426,7 @@ namespace QgsWms
int featureCounter = 0;
layer->updateFields();
const QgsFields &fields = layer->pendingFields();
bool addWktGeometry = QgsServerProjectUtils::wmsFeatureInfoAddWktGeometry( *mProject );
bool addWktGeometry = ( QgsServerProjectUtils::wmsFeatureInfoAddWktGeometry( *mProject ) && mWmsParameters.withGeometry() );
bool segmentizeWktGeometry = QgsServerProjectUtils::wmsFeatureInfoSegmentizeWktGeometry( *mProject );
const QSet<QString> &excludedAttributes = layer->excludeAttributesWms();

@@ -1578,7 +1578,7 @@ namespace QgsWms

//add maptip attribute based on html/expression (in case there is no maptip attribute)
QString mapTip = layer->mapTipTemplate();
if ( !mapTip.isEmpty() )
if ( !mapTip.isEmpty() && mWmsParameters.withMapTip() )
{
QDomElement maptipElem = infoDocument.createElement( QStringLiteral( "Attribute" ) );
maptipElem.setAttribute( QStringLiteral( "name" ), QStringLiteral( "maptip" ) );
@@ -2226,7 +2226,7 @@ namespace QgsWms
{
QString mapTip = layer->mapTipTemplate();

if ( !mapTip.isEmpty() )
if ( !mapTip.isEmpty() && mWmsParameters.withMapTip() )
{
QString fieldTextString = QgsExpression::replaceExpressionText( mapTip, &expressionContext );
QDomElement fieldElem = doc.createElement( QStringLiteral( "qgs:maptip" ) );

0 comments on commit 5bd63b7

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