Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add json export for raster layers
  • Loading branch information
pblottiere committed Jan 28, 2019
1 parent 9eed93b commit 2d8f3d1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -2343,12 +2343,29 @@ namespace QgsWms
exporter.setIncludeLayerName( true );

if ( i > 0 )
json.append( "," );
json.append( QStringLiteral( "," ) );

json.append( exporter.exportFeatures( features ) );
}
else // raster layer
{
json.append( QStringLiteral( "{" ) );
json.append( QStringLiteral( "\n \"name\": \"%1\",\n" ).arg( layer->name() ) );

const QDomNodeList attributesNode = layerElem.elementsByTagName( QStringLiteral( "Attribute" ) );
for ( int j = 0; j < attributesNode.size(); ++j )
{
const QDomElement attrElmt = attributesNode.at( j ).toElement();
const QString name = attrElmt.attribute( QStringLiteral( "name" ) );
const QString value = attrElmt.attribute( QStringLiteral( "value" ) );

if ( j > 0 )
json.append( QStringLiteral( ",\n" ) );

json.append( QStringLiteral( "\"%1\": \"%2\"" ).arg( name, value ) );
}

json.append( QStringLiteral( "\n}" ) );
}
}

Expand Down

0 comments on commit 2d8f3d1

Please sign in to comment.