Skip to content
Permalink
Browse files

[Server][Feature][needs-docs] Create WMTS service UI

The user can config the WMTS for Server by selecting: project, group or layer
published through WMTS.
  • Loading branch information
rldhont committed Jul 27, 2018
1 parent 6d1a45b commit 912effaaf9d974f8d725a76a12311a1c409b1236
Showing with 119 additions and 0 deletions.
  1. +81 −0 src/app/qgsprojectproperties.cpp
  2. +3 −0 src/app/qgsprojectproperties.h
  3. +35 −0 src/ui/qgsprojectpropertiesbase.ui
@@ -55,6 +55,7 @@
#include "qgslayertreemodel.h"
#include "qgsunittypes.h"
#include "qgstablewidgetitem.h"
#include "qgstreewidgetitem.h"
#include "qgslayertree.h"
#include "qgsprintlayout.h"
#include "qgsmetadatawidget.h"
@@ -661,6 +662,22 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
mWMSImageQualitySpinBox->setValue( imageQuality );
}

bool wmtsProject = QgsProject::instance()->readBoolEntry( QStringLiteral( "WMTSLayers" ), QStringLiteral( "Project" ) );
QStringList wmtsGroupNameList = QgsProject::instance()->readListEntry( QStringLiteral( "WMTSLayers" ), QStringLiteral( "Group" ) );
QStringList wmtsLayerIdList = QgsProject::instance()->readListEntry( QStringLiteral( "WMTSLayers" ), QStringLiteral( "Layer" ) );

QgsTreeWidgetItem *projItem = new QgsTreeWidgetItem( QStringList() << QStringLiteral( "Project" ) << QLatin1String( "" ) );
projItem->setFlags( projItem->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable );
if ( wmtsProject )
projItem->setCheckState( 1, Qt::Checked );
else
projItem->setCheckState( 1, Qt::Unchecked );
projItem->setData( 0, Qt::UserRole, "project" );
twWmtsLayers->addTopLevelItem( projItem );
popupulateWmtsTree( QgsProject::instance()->layerTreeRoot(), projItem, wmtsGroupNameList, wmtsLayerIdList );
projItem->setExpanded( true );
twWmtsLayers->header()->resizeSections( QHeaderView::ResizeToContents );

mWFSUrlLineEdit->setText( QgsProject::instance()->readEntry( QStringLiteral( "WFSUrl" ), QStringLiteral( "/" ), QLatin1String( "" ) ) );
QStringList wfsLayerIdList = QgsProject::instance()->readListEntry( QStringLiteral( "WFSLayers" ), QStringLiteral( "/" ) );
QStringList wfstUpdateLayerIdList = QgsProject::instance()->readListEntry( QStringLiteral( "WFSTLayers" ), QStringLiteral( "Update" ) );
@@ -1221,6 +1238,32 @@ void QgsProjectProperties::apply()
QgsProject::instance()->writeEntry( QStringLiteral( "WMSImageQuality" ), QStringLiteral( "/" ), imageQualityValue );
}

bool wmtsProject = false;
QStringList wmtsGroupList;
QStringList wmtsLayerList;
Q_FOREACH ( const QTreeWidgetItem *item, twWmtsLayers->findItems( "", Qt::MatchContains | Qt::MatchRecursive, 1 ) )
{
if ( !item->checkState( 1 ) )
continue;

QString t = item->data( 0, Qt::UserRole ).toString();
if ( t == "project" )
{
wmtsProject = true;
}
else if ( t == "group" )
{
wmtsGroupList << item->data( 0, Qt::UserRole + 1 ).toString();
}
else if ( t == "layer" )
{
wmtsLayerList << item->data( 0, Qt::UserRole + 1 ).toString();
}
}
QgsProject::instance()->writeEntry( QStringLiteral( "WMTSLayers" ), QStringLiteral( "Project" ), wmtsProject );
QgsProject::instance()->writeEntry( QStringLiteral( "WMTSLayers" ), QStringLiteral( "Group" ), wmtsGroupList );
QgsProject::instance()->writeEntry( QStringLiteral( "WMTSLayers" ), QStringLiteral( "Layer" ), wmtsLayerList );

QgsProject::instance()->writeEntry( QStringLiteral( "WFSUrl" ), QStringLiteral( "/" ), mWFSUrlLineEdit->text() );
QStringList wfsLayerList;
QStringList wfstUpdateLayerList;
@@ -1912,6 +1955,44 @@ void QgsProjectProperties::resetPythonMacros()
"def closeProject():\n pass\n" );
}

void QgsProjectProperties::popupulateWmtsTree( QgsLayerTreeGroup *treeGroup, QgsTreeWidgetItem *treeItem, const QStringList &groupNames, const QStringList &layerIds )
{
QList< QgsLayerTreeNode * > treeGroupChildren = treeGroup->children();
for ( int i = 0; i < treeGroupChildren.size(); ++i )
{
QgsTreeWidgetItem *childItem;
childItem->setFlags( childItem->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable );
QgsLayerTreeNode *treeNode = treeGroupChildren.at( i );
if ( treeNode->nodeType() == QgsLayerTreeNode::NodeGroup )
{
QgsLayerTreeGroup *treeGroupChild = static_cast<QgsLayerTreeGroup *>( treeNode );
childItem = new QgsTreeWidgetItem( QStringList() << treeGroupChild->name() << QLatin1String( "" ) );
if ( groupNames.contains( treeGroupChild->name() ) )
childItem->setCheckState( 1, Qt::Checked );
else
childItem->setCheckState( 1, Qt::Unchecked );
childItem->setData( 0, Qt::UserRole, "group" );
childItem->setData( 0, Qt::UserRole + 1, treeGroupChild->name() );
treeItem->addChild( childItem );
popupulateWmtsTree( treeGroupChild, childItem, groupNames, layerIds );
treeItem->setExpanded( true );
}
else
{
QgsLayerTreeLayer *treeLayer = static_cast<QgsLayerTreeLayer *>( treeNode );
QgsMapLayer *l = treeLayer->layer();
childItem = new QgsTreeWidgetItem( QStringList() << l->name() << QLatin1String( "" ) );
if ( layerIds.contains( l->id() ) )
childItem->setCheckState( 1, Qt::Checked );
else
childItem->setCheckState( 1, Qt::Unchecked );
childItem->setData( 0, Qt::UserRole, "layer" );
childItem->setData( 0, Qt::UserRole + 1, l->id() );
treeItem->addChild( childItem );
}
}
}

void QgsProjectProperties::checkOWS( QgsLayerTreeGroup *treeGroup, QStringList &owsNames, QStringList &encodingMessages )
{
QList< QgsLayerTreeNode * > treeGroupChildren = treeGroup->children();
@@ -31,6 +31,7 @@ class QgsStyle;
class QgsExpressionContext;
class QgsLayerTreeGroup;
class QgsMetadataWidget;
class QgsTreeWidgetItem;

/**
* Dialog to set project level properties
@@ -213,6 +214,8 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
QList<EllipsoidDefs> mEllipsoidList;
int mEllipsoidIndex;

//! populate WMTS tree
void popupulateWmtsTree( QgsLayerTreeGroup *treeGroup, QgsTreeWidgetItem *treeItem, const QStringList &groupNames, const QStringList &layerIds );
//! Check OWS configuration
void checkOWS( QgsLayerTreeGroup *treeGroup, QStringList &owsNames, QStringList &encodingMessages );

@@ -2460,6 +2460,41 @@
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="grpWmtsCapabilities">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>3</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>WMTS capabilities</string>
</property>
<layout class="QGridLayout" name="gridLayout_20">
<item row="0" column="0">
<widget class="QTreeWidget" name="twWmtsLayers">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<column>
<property name="text">
<string>Layer</string>
</property>
</column>
<column>
<property name="text">
<string>Published</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="grpWFSCapabilities">
<property name="sizePolicy">

0 comments on commit 912effa

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