Skip to content

Commit

Permalink
Fix case where several WMS layers have the same feature info alias
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Oct 26, 2012
1 parent 4c271f2 commit 59e9942
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/mapserver/qgswmsserver.cpp
Expand Up @@ -764,10 +764,10 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
renderContext.setPainter( 0 );
}

bool sia2045 = mConfigParser->featureInfoFormatSIA2045();

//layers can have assigned a different name for GetCapabilities
QHash<QString, QString> layerAliasMap = mConfigParser->featureInfoLayerAliasMap();
//collect layer name / maplayer for potential later modifications of the xml
QMap< QString, QgsMapLayer* > layerNameMap;

QList<QgsMapLayer*> layerList;
QgsMapLayer* currentLayer = 0;
Expand Down Expand Up @@ -807,7 +807,10 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
}
layerElement.setAttribute( "name", layerName );
getFeatureInfoElement.appendChild( layerElement );
layerNameMap.insert( layerName, currentLayer );
if ( sia2045 ) //the name might not be unique after alias replacement
{
layerElement.setAttribute( "id", currentLayer->id() );
}

//switch depending on vector or raster
QgsVectorLayer* vectorLayer = dynamic_cast<QgsVectorLayer*>( currentLayer );
Expand Down Expand Up @@ -848,11 +851,9 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
getFeatureInfoElement.insertBefore( bBoxElem, QDomNode() ); //insert as first child
}

if ( mConfigParser->featureInfoFormatSIA2045()
&& mParameterMap.value( "INFO_FORMAT" ).compare( "text/xml", Qt::CaseInsensitive ) == 0 )
if ( sia2045 && mParameterMap.value( "INFO_FORMAT" ).compare( "text/xml", Qt::CaseInsensitive ) == 0 )
{

convertFeatureInfoToSIA2045( result, layerNameMap );
convertFeatureInfoToSIA2045( result );
}

restoreLayerFilters( originalLayerFilters );
Expand Down Expand Up @@ -2069,7 +2070,7 @@ void QgsWMSServer::addXMLDeclaration( QDomDocument& doc ) const
doc.appendChild( xmlDeclaration );
}

void QgsWMSServer::convertFeatureInfoToSIA2045( QDomDocument& doc, const QMap< QString, QgsMapLayer* >& layerNameMap )
void QgsWMSServer::convertFeatureInfoToSIA2045( QDomDocument& doc )
{
QDomDocument SIAInfoDoc;
QDomElement infoDocElement = doc.documentElement();
Expand Down Expand Up @@ -2116,13 +2117,12 @@ void QgsWMSServer::convertFeatureInfoToSIA2045( QDomDocument& doc, const QMap< Q
}
else //vector
{

//property attributes
QSet<QString> layerPropertyAttributes;
QMap< QString, QgsMapLayer* >::const_iterator layerNameMapIt = layerNameMap.find( currentLayerName );
if ( layerNameMapIt != layerNameMap.constEnd() )
QString currentLayerId = currentLayerElem.attribute( "id" );
if ( !currentLayerId.isEmpty() )
{
QgsMapLayer* currentLayer = layerNameMapIt.value();
QgsMapLayer* currentLayer = QgsMapLayerRegistry::instance()->mapLayer( currentLayerId );
if ( currentLayer )
{
QString WMSPropertyAttributesString = currentLayer->customProperty( "WMSPropertyAttributes" ).toString();
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgswmsserver.h
Expand Up @@ -177,7 +177,7 @@ class QgsWMSServer
void addXMLDeclaration( QDomDocument& doc ) const;

/**Converts a feature info xml document to SIA2045 norm*/
void convertFeatureInfoToSIA2045( QDomDocument& doc, const QMap< QString, QgsMapLayer* >& layerNameMap );
void convertFeatureInfoToSIA2045( QDomDocument& doc );

/**Map containing the WMS parameters*/
QMap<QString, QString> mParameterMap;
Expand Down

0 comments on commit 59e9942

Please sign in to comment.