Skip to content

Commit c17957f

Browse files
author
Marcel Dancak
committedSep 30, 2014
Mapserver: fixed GetFeatureInfo request on raster layers
1 parent b044d4d commit c17957f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎src/mapserver/qgswmsserver.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,10 +2030,15 @@ int QgsWMSServer::featureInfoFromRasterLayer( QgsRasterLayer* layer,
20302030
if ( infoFormat == "application/vnd.ogc.gml" )
20312031
{
20322032
QgsFeature feature;
2033+
QgsFields fields;
2034+
feature.initAttributes( attributes.count() );
2035+
int index = 0;
20332036
for ( QMap<int, QVariant>::const_iterator it = attributes.constBegin(); it != attributes.constEnd(); ++it )
20342037
{
2035-
feature.setAttribute( layer->bandName( it.key() ), QString::number( it.value().toDouble() ) );
2038+
fields.append( QgsField( layer->bandName( it.key() ), QVariant::Double ) );
2039+
feature.setAttribute( index++, QString::number( it.value().toDouble() ) );
20362040
}
2041+
feature.setFields( &fields );
20372042

20382043
QgsCoordinateReferenceSystem layerCrs = layer->crs();
20392044
int version = infoFormat.startsWith( "application/vnd.ogc.gml/3" ) ? 3 : 2;
@@ -2830,14 +2835,13 @@ QDomElement QgsWMSServer::createFeatureGML(
28302835
}
28312836

28322837
//read all allowed attribute values from the feature
2833-
const QSet<QString>& excludedAttributes = layer->excludeAttributesWMS();
28342838
QgsAttributes featureAttributes = feat->attributes();
28352839
const QgsFields* fields = feat->fields();
28362840
for ( int i = 0; i < fields->count(); ++i )
28372841
{
28382842
QString attributeName = fields->at( i ).name();
28392843
//skip attribute if it is explicitly excluded from WMS publication
2840-
if ( excludedAttributes.contains( attributeName ) )
2844+
if ( layer && layer->excludeAttributesWMS().contains( attributeName ) )
28412845
{
28422846
continue;
28432847
}

0 commit comments

Comments
 (0)
Please sign in to comment.