Skip to content
Permalink
Browse files

Add the possibility to publish the url of WMS/WMTS layers and to adve…

…rtize them as background layers for the webmap in GetProjectSettings
  • Loading branch information
mhugent committed Oct 23, 2017
1 parent 9ce7361 commit 97ad01b3cf63049be7bc9a5e331e372621347349
@@ -793,6 +793,12 @@ void QgsRasterLayerProperties::sync()
mWMSPrintLayerLineEdit->setText( wmsPrintLayer.toString() );
}

QVariant wmsPublishDataSourceUrl = mRasterLayer->customProperty( QStringLiteral( "WMSPublishDataSourceUrl" ), false );
mPublishDataSourceUrlCheckBox->setChecked( wmsPublishDataSourceUrl.toBool() );

QVariant wmsBackgroundLayer = mRasterLayer->customProperty( QStringLiteral( "WMSBackgroundLayer" ), false );
mBackgroundLayerCheckBox->setChecked( wmsBackgroundLayer.toBool() );

/*
* Legend Tab
*/
@@ -1026,6 +1032,9 @@ void QgsRasterLayerProperties::apply()
mRasterLayer->setCustomProperty( QStringLiteral( "WMSPrintLayer" ), mWMSPrintLayerLineEdit->text() );
}

mRasterLayer->setCustomProperty( "WMSPublishDataSourceUrl", mPublishDataSourceUrlCheckBox->isChecked() );
mRasterLayer->setCustomProperty( "WMSBackgroundLayer", mBackgroundLayerCheckBox->isChecked() );

// update symbology
emit refreshLegend( mRasterLayer->id(), false );

@@ -1694,6 +1694,30 @@ namespace QgsWms
}
else if ( currentLayer->type() == QgsMapLayer::RasterLayer )
{
const QgsDataProvider *provider = currentLayer->dataProvider();
if ( provider && provider->name() == "wms" )
{
//advertise as web map background layer
QVariant wmsBackgroundLayer = currentLayer->customProperty( QStringLiteral( "WMSBackgroundLayer" ), false );
QDomElement wmsBackgroundLayerElem = doc.createElement( "WMSBackgroundLayer" );
QDomText wmsBackgroundLayerText = doc.createTextNode( wmsBackgroundLayer.toBool() ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
wmsBackgroundLayerElem.appendChild( wmsBackgroundLayerText );
layerElem.appendChild( wmsBackgroundLayerElem );

//publish datasource
QVariant wmsPublishDataSourceUrl = currentLayer->customProperty( QStringLiteral( "WMSPublishDataSourceUrl" ), false );
if ( wmsPublishDataSourceUrl.toBool() )
{
QList< QVariant > resolutionList = provider->property( "resolutions" ).toList();
bool tiled = resolutionList.size() > 0;

QDomElement dataSourceElem = doc.createElement( tiled ? QStringLiteral( "WMTSDataSource" ) : QStringLiteral( "WMSDataSource" ) );
QDomText dataSourceUri = doc.createTextNode( provider->dataSourceUri() );
dataSourceElem.appendChild( dataSourceUri );
layerElem.appendChild( dataSourceElem );
}
}

QVariant wmsPrintLayer = currentLayer->customProperty( QStringLiteral( "WMSPrintLayer" ) );
if ( wmsPrintLayer.isValid() )
{
@@ -1722,7 +1722,7 @@ p, li { white-space: pre-wrap; }
<x>0</x>
<y>0</y>
<width>630</width>
<height>724</height>
<height>788</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_12">
@@ -2084,6 +2084,20 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="mPublishDataSourceUrlCheckBox">
<property name="text">
<string>Publish WMS/WMTS data source uri</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="mBackgroundLayerCheckBox">
<property name="text">
<string>Advertise as background layer</string>
</property>
</widget>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>

0 comments on commit 97ad01b

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