QGIS API Documentation  3.21.0-Master (5b68dc587e)
qgsmaplayerserverproperties.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaplayerserverproperties.h
3  ------------------
4  begin : June 21, 2021
5  copyright : (C) 2021 by Etienne Trimaille
6  email : etrimaille at 3liz dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSMAPLAYERSERVERPROPERTIES_H
19 #define QGSMAPLAYERSERVERPROPERTIES_H
20 
21 #include "qgis_sip.h"
22 #include "qgis_core.h"
23 #include <QMap>
24 #include <QString>
25 #include <QMetaType>
26 #include <QVariant>
27 
28 class QgsMapLayer;
29 
30 class QDomNode;
31 class QDomDocument;
32 
39 {
40  Q_GADGET
41 
42  public:
43 
49  struct CORE_EXPORT MetadataUrl
50  {
51 
55  MetadataUrl( const QString &url = QString(), const QString &type = QString(), const QString &format = QString() )
56  : url( url )
57  , type( type )
58  , format( format )
59  {}
60 
64  QString url;
65 
69  QString type;
70 
74  QString format;
75 
76  // TODO c++20 - replace with = default
77 
80  };
81 
82  virtual ~QgsServerMetadataUrlProperties() = default;
83 
89  QList<QgsServerMetadataUrlProperties::MetadataUrl> metadataUrls() const { return mMetadataUrls; };
90 
96  void setMetadataUrls( const QList<QgsServerMetadataUrlProperties::MetadataUrl> &metaUrls ) { mMetadataUrls = metaUrls; };
97 
102  void addMetadataUrl( const QgsServerMetadataUrlProperties::MetadataUrl &metaUrl ) { mMetadataUrls << metaUrl; };
103 
105  virtual const QgsMapLayer *layer() const = 0;
106 
107  protected:
109  void writeXml( QDomNode &layer_node, QDomDocument &document ) const SIP_SKIP;
110 
112  void readXml( const QDomNode &layer_node ) SIP_SKIP;
113 
119  void copyTo( QgsServerMetadataUrlProperties *properties ) const SIP_SKIP;
120 
122  void reset() SIP_SKIP;
123 
124  private:
125  QList<MetadataUrl> mMetadataUrls;
126 
127 };
128 
129 
136 {
137  Q_GADGET
138 
139  public:
140 
145  {
148  ELEVATION
149  };
150  Q_ENUM( PredefinedWmsDimensionName )
151 
152 
156  struct CORE_EXPORT WmsDimensionInfo
157  {
158 
164  {
165  AllValues = 0,
166  MinValue = 1,
167  MaxValue = 2,
168  ReferenceValue = 3,
169  };
170 
174  explicit WmsDimensionInfo( const QString &dimName,
175  const QString &dimFieldName,
176  const QString &dimEndFieldName = QString(),
177  const QString &dimUnits = QString(),
178  const QString &dimUnitSymbol = QString(),
179  const int &dimDefaultDisplayType = QgsServerWmsDimensionProperties::WmsDimensionInfo::AllValues,
180  const QVariant &dimReferenceValue = QVariant() )
181  : name( dimName )
182  , fieldName( dimFieldName )
183  , endFieldName( dimEndFieldName )
184  , units( dimUnits )
185  , unitSymbol( dimUnitSymbol )
186  , defaultDisplayType( dimDefaultDisplayType )
187  , referenceValue( dimReferenceValue )
188  {}
189  QString name;
190  QString fieldName;
191  QString endFieldName;
192  QString units;
193  QString unitSymbol;
195  QVariant referenceValue;
196  };
197 
198  virtual ~QgsServerWmsDimensionProperties() = default;
199 
204  static QMap<int, QString> wmsDimensionDefaultDisplayLabels();
205 
212  bool addWmsDimension( const QgsServerWmsDimensionProperties::WmsDimensionInfo &wmsDimInfo );
213 
219  bool removeWmsDimension( const QString &wmsDimName );
220 
226  void setWmsDimensions( const QList<QgsServerWmsDimensionProperties::WmsDimensionInfo> &dimensions );
227 
232  const QList<QgsServerWmsDimensionProperties::WmsDimensionInfo> wmsDimensions() const;
233 
235  virtual const QgsMapLayer *layer() const = 0;
236 
237  protected:
238 
242  void writeXml( QDomNode &layer_node, QDomDocument &document ) const SIP_SKIP;
243 
247  void readXml( const QDomNode &layer_node ) SIP_SKIP;
248 
254  void copyTo( QgsServerWmsDimensionProperties *properties ) const SIP_SKIP;
255 
259  void reset() SIP_SKIP;
260 
261  private: // Private attributes
263  QList<WmsDimensionInfo> mWmsDimensions;
264 };
265 
266 
273 {
274  Q_GADGET
275 
276  public:
277 
283  QgsMapLayerServerProperties( QgsMapLayer *layer = nullptr );
284 
290  void copyTo( QgsMapLayerServerProperties *properties ) const;
291 
296  void writeXml( QDomNode &layer_node, QDomDocument &document ) const;
297 
302  void readXml( const QDomNode &layer_node );
303 
308  void reset();
309 
311  const QgsMapLayer *layer() const override { return mLayer; };
312 
313  private:
314  QgsMapLayer *mLayer = nullptr;
315 };
316 
323 // XXX How to make a proper SIP type alias ?
324 //using QgsVectorLayerServerProperties = QgsMapLayerServerProperties;
326 {
327  Q_GADGET
328 };
329 
330 #endif // QGSMAPLAYERSERVERPROPERTIES_H
331 
Manages QGIS Server properties for a map layer.
const QgsMapLayer * layer() const override
Gets the parent layer.
Base class for all map layer types.
Definition: qgsmaplayer.h:73
Manages QGIS Server properties for a map layer.
virtual ~QgsServerMetadataUrlProperties()=default
void addMetadataUrl(const QgsServerMetadataUrlProperties::MetadataUrl &metaUrl)
Add a metadataUrl for the layer.
void setMetadataUrls(const QList< QgsServerMetadataUrlProperties::MetadataUrl > &metaUrls)
Sets a the list of metadata URL for the layer.
QList< QgsServerMetadataUrlProperties::MetadataUrl > metadataUrls() const
Returns a list of metadataUrl resources associated for the layer.
virtual const QgsMapLayer * layer() const =0
Gets the parent layer.
Manages QGIS Server properties for Wms dimensions.
PredefinedWmsDimensionName
Predefined/Restricted WMS Dimension name.
virtual ~QgsServerWmsDimensionProperties()=default
virtual const QgsMapLayer * layer() const =0
Gets the parent layer.
Convenient class for API compatibility.
#define SIP_SKIP
Definition: qgis_sip.h:126
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
MetadataUrl(const QString &url=QString(), const QString &type=QString(), const QString &format=QString())
Constructor for MetadataUrl.
QString format
Format specification of online resource.
Setting to define QGIS Server WMS Dimension.
WmsDimensionInfo(const QString &dimName, const QString &dimFieldName, const QString &dimEndFieldName=QString(), const QString &dimUnits=QString(), const QString &dimUnitSymbol=QString(), const int &dimDefaultDisplayType=QgsServerWmsDimensionProperties::WmsDimensionInfo::AllValues, const QVariant &dimReferenceValue=QVariant())
Constructor for WmsDimensionInfo.
DefaultDisplay
Selection behavior for QGIS Server WMS Dimension default display.