Skip to content
Permalink
Browse files

Merge pull request #33891 from mhugent/opacity_project_settings

Add layer opacity to GetProjectSettings
  • Loading branch information
mhugent committed Jan 21, 2020
2 parents ccc7ad5 + 9fca498 commit 07b64aaa188cd2c47f8bf5b04fb868a6d7984aff
@@ -37,7 +37,8 @@
#include "qgsexpressionnodeimpl.h"
#include "qgsvectorlayer.h"
#include "qgsrasterdataprovider.h"

#include "qgsrasterlayer.h"
#include "qgsrasterrenderer.h"
#include "qgsvectorlayerserverproperties.h"


@@ -1901,6 +1902,9 @@ namespace QgsWms
//geometry type
layerElem.setAttribute( QStringLiteral( "geometryType" ), QgsWkbTypes::displayString( vLayer->wkbType() ) );

//opacity
layerElem.setAttribute( QStringLiteral( "opacity" ), QString::number( vLayer->opacity() ) );

layerElem.appendChild( attributesElem );
break;
}
@@ -1940,6 +1944,14 @@ namespace QgsWms
wmsPrintLayerElem.appendChild( wmsPrintLayerText );
layerElem.appendChild( wmsPrintLayerElem );
}

//opacity
QgsRasterLayer *rl = static_cast<QgsRasterLayer *>( currentLayer );
QgsRasterRenderer *rasterRenderer = rl->renderer();
if ( rasterRenderer )
{
layerElem.setAttribute( QStringLiteral( "opacity" ), QString::number( rasterRenderer->opacity() ) );
}
break;
}

@@ -102,6 +102,9 @@ def test_getcapabilities_case_insensitive(self):
def test_getprojectsettings(self):
self.wms_request_compare('GetProjectSettings')

def test_getprojectsettings_opacity(self):
self.wms_request_compare('GetProjectSettings', None, 'getprojectsettings_opacity', 'test_opacity_project.qgs')

def test_getcontext(self):
self.wms_request_compare('GetContext')

@@ -141,7 +141,7 @@ Content-Type: text/xml; charset=utf-8
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
</KeywordList>
<TreeName>QGIS Test Project</TreeName>
<Layer geometryType="Point" queryable="1" displayField="id" visible="1">
<Layer geometryType="Point" queryable="1" displayField="id" visible="1" opacity="1">
<Name>layer_with_short_name</Name>
<Title>A Layer with a short name</Title>
<Abstract>A Layer with an abstract</Abstract>
@@ -171,7 +171,7 @@ Content-Type: text/xml; charset=utf-8
<Attribute precision="0" type="QString" editType="TextEdit" typeName="String" name="utf8nameè" comment="" length="13"/>
</Attributes>
</Layer>
<Layer queryable="1" visible="1">
<Layer queryable="1" visible="1" opacity="1">
<Name>landsat</Name>
<Title>landsat</Title>
<CRS>CRS:84</CRS>
@@ -195,7 +195,7 @@ Content-Type: text/xml; charset=utf-8
</Style>
<TreeName>landsat</TreeName>
</Layer>
<Layer geometryType="Point" queryable="1" displayField="name" visible="1">
<Layer geometryType="Point" queryable="1" displayField="name" visible="1" opacity="1">
<Name>testlayer èé</Name>
<Title>A test vector layer</Title>
<Abstract>A test vector layer with unicode òà</Abstract>
@@ -225,7 +225,7 @@ Content-Type: text/xml; charset=utf-8
<Attribute precision="0" type="QString" editType="TextEdit" typeName="String" name="utf8nameè" comment="" length="13"/>
</Attributes>
</Layer>
<Layer geometryType="Point" queryable="1" displayField="alias_name" visible="1">
<Layer geometryType="Point" queryable="1" displayField="alias_name" visible="1" opacity="1">
<Name>fields_alias</Name>
<Title>A test vector layer</Title>
<Abstract>A test vector layer with unicode òà</Abstract>
@@ -255,7 +255,7 @@ Content-Type: text/xml; charset=utf-8
<Attribute precision="0" type="QString" editType="TextEdit" typeName="String" name="utf8nameè" comment="" length="13"/>
</Attributes>
</Layer>
<Layer geometryType="Point" queryable="1" displayField="name" visible="1">
<Layer geometryType="Point" queryable="1" displayField="name" visible="1" opacity="1">
<Name>exclude_attribute</Name>
<Title>A test vector layer</Title>
<Abstract>A test vector layer with unicode òà</Abstract>
@@ -300,7 +300,7 @@ Content-Type: text/xml; charset=utf-8
<BoundingBox maxy="5606025.239" maxx="913214.676" miny="5606011.456" CRS="EPSG:3857" minx="913204.911"/>
<BoundingBox maxy="8.203548" maxx="44.901483" miny="8.203459" CRS="EPSG:4326" minx="44.901394"/>
<TreeName>groupwithshortname</TreeName>
<Layer geometryType="Point" queryable="1" displayField="id" visible="1">
<Layer geometryType="Point" queryable="1" displayField="id" visible="1" opacity="1">
<Name>testlayer2</Name>
<Title>testlayer2</Title>
<CRS>CRS:84</CRS>
@@ -345,7 +345,7 @@ Content-Type: text/xml; charset=utf-8
<BoundingBox maxy="5606025.239" maxx="913214.676" miny="5606011.456" CRS="EPSG:3857" minx="913204.911"/>
<BoundingBox maxy="8.203548" maxx="44.901483" miny="8.203459" CRS="EPSG:4326" minx="44.901394"/>
<TreeName>groupwithoutshortname</TreeName>
<Layer geometryType="Point" queryable="0" displayField="name" visible="1">
<Layer geometryType="Point" queryable="0" displayField="name" visible="1" opacity="1">
<Name>testlayer3</Name>
<Title>testlayer3</Title>
<CRS>CRS:84</CRS>

0 comments on commit 07b64aa

Please sign in to comment.
You can’t perform that action at this time.