Skip to content

Commit 2d8f3d1

Browse files
committed
Add json export for raster layers
1 parent 9eed93b commit 2d8f3d1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/server/services/wms/qgswmsrenderer.cpp

+18-1
Original file line numberDiff line numberDiff line change
@@ -2343,12 +2343,29 @@ namespace QgsWms
23432343
exporter.setIncludeLayerName( true );
23442344

23452345
if ( i > 0 )
2346-
json.append( "," );
2346+
json.append( QStringLiteral( "," ) );
23472347

23482348
json.append( exporter.exportFeatures( features ) );
23492349
}
23502350
else // raster layer
23512351
{
2352+
json.append( QStringLiteral( "{" ) );
2353+
json.append( QStringLiteral( "\n \"name\": \"%1\",\n" ).arg( layer->name() ) );
2354+
2355+
const QDomNodeList attributesNode = layerElem.elementsByTagName( QStringLiteral( "Attribute" ) );
2356+
for ( int j = 0; j < attributesNode.size(); ++j )
2357+
{
2358+
const QDomElement attrElmt = attributesNode.at( j ).toElement();
2359+
const QString name = attrElmt.attribute( QStringLiteral( "name" ) );
2360+
const QString value = attrElmt.attribute( QStringLiteral( "value" ) );
2361+
2362+
if ( j > 0 )
2363+
json.append( QStringLiteral( ",\n" ) );
2364+
2365+
json.append( QStringLiteral( "\"%1\": \"%2\"" ).arg( name, value ) );
2366+
}
2367+
2368+
json.append( QStringLiteral( "\n}" ) );
23522369
}
23532370
}
23542371

0 commit comments

Comments
 (0)