Skip to content

Commit 016d3a2

Browse files
author
marco
committed
Enable feature info on layer groups in wms server
1 parent a8a90fe commit 016d3a2

File tree

1 file changed

+54
-50
lines changed

1 file changed

+54
-50
lines changed

src/mapserver/qgswmsserver.cpp

Lines changed: 54 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -685,62 +685,66 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result )
685685
QStringList::const_iterator layerIt;
686686
for ( layerIt = queryLayerList.constBegin(); layerIt != queryLayerList.constEnd(); ++layerIt )
687687
{
688-
//create maplayer from sld parser
688+
//create maplayers from sld parser (several layers are possible in case of feature info on a group)
689689
layerList = mConfigParser->mapLayerFromStyle( *layerIt, "" );
690-
currentLayer = layerList.at( 0 );
691-
if ( !currentLayer || nonIdentifiableLayers.contains( currentLayer->id() ) )
690+
QList<QgsMapLayer*>::iterator layerListIt = layerList.begin();
691+
for(; layerListIt != layerList.end(); ++layerListIt )
692692
{
693-
continue;
694-
}
695-
if ( infoPointToLayerCoordinates( i, j, infoPoint, mMapRenderer, currentLayer ) != 0 )
696-
{
697-
continue;
698-
}
699-
QgsDebugMsg( "Info point in layer crs: " + QString::number( infoPoint.x() ) + "//" + QString::number( infoPoint.y() ) );
700-
701-
QDomElement layerElement = result.createElement( "Layer" );
702-
layerElement.setAttribute( "name", currentLayer->name() );
703-
getFeatureInfoElement.appendChild( layerElement );
704-
705-
//switch depending on vector or raster
706-
QgsVectorLayer* vectorLayer = dynamic_cast<QgsVectorLayer*>( currentLayer );
707-
if ( vectorLayer )
708-
{
709-
//is there alias info for this vector layer?
710-
QMap< int, QString > layerAliasInfo;
711-
QMap< QString, QMap< int, QString > >::const_iterator aliasIt = aliasInfo.find( currentLayer->id() );
712-
if ( aliasIt != aliasInfo.constEnd() )
713-
{
714-
layerAliasInfo = aliasIt.value();
715-
}
693+
currentLayer = *layerListIt;
694+
if ( !currentLayer || nonIdentifiableLayers.contains( currentLayer->id() ) )
695+
{
696+
continue;
697+
}
698+
if ( infoPointToLayerCoordinates( i, j, infoPoint, mMapRenderer, currentLayer ) != 0 )
699+
{
700+
continue;
701+
}
702+
QgsDebugMsg( "Info point in layer crs: " + QString::number( infoPoint.x() ) + "//" + QString::number( infoPoint.y() ) );
716703

717-
//hidden attributes for this layer
718-
QSet<QString> layerHiddenAttributes;
719-
QMap< QString, QSet<QString> >::const_iterator hiddenIt = hiddenAttributes.find( currentLayer->id() );
720-
if ( hiddenIt != hiddenAttributes.constEnd() )
721-
{
722-
layerHiddenAttributes = hiddenIt.value();
723-
}
704+
QDomElement layerElement = result.createElement( "Layer" );
705+
layerElement.setAttribute( "name", currentLayer->name() );
706+
getFeatureInfoElement.appendChild( layerElement );
724707

725-
if ( featureInfoFromVectorLayer( vectorLayer, infoPoint, featureCount, result, layerElement, mMapRenderer, layerAliasInfo, layerHiddenAttributes ) != 0 )
726-
{
727-
return 9;
728-
}
729-
}
730-
else //raster layer
731-
{
732-
QgsRasterLayer* rasterLayer = dynamic_cast<QgsRasterLayer*>( currentLayer );
733-
if ( rasterLayer )
734-
{
735-
if ( featureInfoFromRasterLayer( rasterLayer, infoPoint, result, layerElement ) != 0 )
708+
//switch depending on vector or raster
709+
QgsVectorLayer* vectorLayer = dynamic_cast<QgsVectorLayer*>( currentLayer );
710+
if ( vectorLayer )
736711
{
737-
return 10;
712+
//is there alias info for this vector layer?
713+
QMap< int, QString > layerAliasInfo;
714+
QMap< QString, QMap< int, QString > >::const_iterator aliasIt = aliasInfo.find( currentLayer->id() );
715+
if ( aliasIt != aliasInfo.constEnd() )
716+
{
717+
layerAliasInfo = aliasIt.value();
718+
}
719+
720+
//hidden attributes for this layer
721+
QSet<QString> layerHiddenAttributes;
722+
QMap< QString, QSet<QString> >::const_iterator hiddenIt = hiddenAttributes.find( currentLayer->id() );
723+
if ( hiddenIt != hiddenAttributes.constEnd() )
724+
{
725+
layerHiddenAttributes = hiddenIt.value();
726+
}
727+
728+
if ( featureInfoFromVectorLayer( vectorLayer, infoPoint, featureCount, result, layerElement, mMapRenderer, layerAliasInfo, layerHiddenAttributes ) != 0 )
729+
{
730+
continue;
731+
}
732+
}
733+
else //raster layer
734+
{
735+
QgsRasterLayer* rasterLayer = dynamic_cast<QgsRasterLayer*>( currentLayer );
736+
if ( rasterLayer )
737+
{
738+
if ( featureInfoFromRasterLayer( rasterLayer, infoPoint, result, layerElement ) != 0 )
739+
{
740+
continue;
741+
}
742+
}
743+
else
744+
{
745+
continue;
746+
}
738747
}
739-
}
740-
else
741-
{
742-
return 11;
743-
}
744748
}
745749
}
746750
return 0;

0 commit comments

Comments
 (0)