Skip to content

Commit

Permalink
Merge pull request #1598 from marcel-dancak/getfeatureinfo-raster
Browse files Browse the repository at this point in the history
Mapserver: fixed GetFeatureInfo request on raster layers (GML format)
  • Loading branch information
mhugent committed Oct 4, 2014
2 parents b8c558c + c17957f commit ec64e1d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/mapserver/qgswmsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2030,10 +2030,15 @@ int QgsWMSServer::featureInfoFromRasterLayer( QgsRasterLayer* layer,
if ( infoFormat == "application/vnd.ogc.gml" )
{
QgsFeature feature;
QgsFields fields;
feature.initAttributes( attributes.count() );
int index = 0;
for ( QMap<int, QVariant>::const_iterator it = attributes.constBegin(); it != attributes.constEnd(); ++it )
{
feature.setAttribute( layer->bandName( it.key() ), QString::number( it.value().toDouble() ) );
fields.append( QgsField( layer->bandName( it.key() ), QVariant::Double ) );
feature.setAttribute( index++, QString::number( it.value().toDouble() ) );
}
feature.setFields( &fields );

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

//read all allowed attribute values from the feature
const QSet<QString>& excludedAttributes = layer->excludeAttributesWMS();
QgsAttributes featureAttributes = feat->attributes();
const QgsFields* fields = feat->fields();
for ( int i = 0; i < fields->count(); ++i )
{
QString attributeName = fields->at( i ).name();
//skip attribute if it is explicitly excluded from WMS publication
if ( excludedAttributes.contains( attributeName ) )
if ( layer && layer->excludeAttributesWMS().contains( attributeName ) )
{
continue;
}
Expand Down

0 comments on commit ec64e1d

Please sign in to comment.