Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 97ad01b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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 );

Expand Down
24 changes: 24 additions & 0 deletions src/server/services/wms/qgswmsgetcapabilities.cpp
Expand Up @@ -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() )
{
Expand Down
16 changes: 15 additions & 1 deletion src/ui/qgsrasterlayerpropertiesbase.ui
Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 97ad01b

Please sign in to comment.