QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
QgsServerMetadataUrlProperties::MetadataUrl::MetadataUrl
MetadataUrl(const QString &url=QString(), const QString &type=QString(), const QString &format=QString())
Constructor for MetadataUrl.
Definition: qgsmaplayerserverproperties.h:55
QgsServerWmsDimensionProperties::WmsDimensionInfo
Setting to define QGIS Server WMS Dimension.
Definition: qgsmaplayerserverproperties.h:156
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:425
QgsServerMetadataUrlProperties
Manages QGIS Server properties for a map layer.
Definition: qgsmaplayerserverproperties.h:38
QgsServerWmsDimensionProperties::WmsDimensionInfo::units
QString units
Definition: qgsmaplayerserverproperties.h:192
QgsServerWmsDimensionProperties::WmsDimensionInfo::unitSymbol
QString unitSymbol
Definition: qgsmaplayerserverproperties.h:193
QgsServerWmsDimensionProperties::WmsDimensionInfo::fieldName
QString fieldName
Definition: qgsmaplayerserverproperties.h:190
QgsVectorLayerServerProperties
Convenient class for API compatibility.
Definition: qgsmaplayerserverproperties.h:325
QgsServerMetadataUrlProperties::MetadataUrl::url
QString url
URL of the link.
Definition: qgsmaplayerserverproperties.h:64
QgsServerMetadataUrlProperties::MetadataUrl::type
QString type
Link type.
Definition: qgsmaplayerserverproperties.h:69
QgsServerWmsDimensionProperties::WmsDimensionInfo::DefaultDisplay
DefaultDisplay
Selection behavior for QGIS Server WMS Dimension default display.
Definition: qgsmaplayerserverproperties.h:163
QgsServerMetadataUrlProperties::setMetadataUrls
void setMetadataUrls(const QList< QgsServerMetadataUrlProperties::MetadataUrl > &metaUrls)
Sets a the list of metadata URL for the layer.
Definition: qgsmaplayerserverproperties.h:96
QgsServerMetadataUrlProperties::addMetadataUrl
void addMetadataUrl(const QgsServerMetadataUrlProperties::MetadataUrl &metaUrl)
Add a metadataUrl for the layer.
Definition: qgsmaplayerserverproperties.h:102
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsServerWmsDimensionProperties::WmsDimensionInfo::defaultDisplayType
int defaultDisplayType
Definition: qgsmaplayerserverproperties.h:194
QgsServerWmsDimensionProperties::PredefinedWmsDimensionName
PredefinedWmsDimensionName
Predefined/Restricted WMS Dimension name.
Definition: qgsmaplayerserverproperties.h:144
QgsServerMetadataUrlProperties::MetadataUrl::format
QString format
Format specification of online resource.
Definition: qgsmaplayerserverproperties.h:74
qgis_sip.h
QgsMapLayerServerProperties
Manages QGIS Server properties for a map layer.
Definition: qgsmaplayerserverproperties.h:272
QgsServerMetadataUrlProperties::metadataUrls
QList< QgsServerMetadataUrlProperties::MetadataUrl > metadataUrls() const
Returns a list of metadataUrl resources associated for the layer.
Definition: qgsmaplayerserverproperties.h:89
QgsServerMetadataUrlProperties::MetadataUrl
MetadataUrl structure.
Definition: qgsmaplayerserverproperties.h:49
QgsServerWmsDimensionProperties::WmsDimensionInfo::WmsDimensionInfo
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.
Definition: qgsmaplayerserverproperties.h:174
QgsMapLayerServerProperties::layer
const QgsMapLayer * layer() const override
Gets the parent layer.
Definition: qgsmaplayerserverproperties.h:311
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
QgsServerWmsDimensionProperties::WmsDimensionInfo::endFieldName
QString endFieldName
Definition: qgsmaplayerserverproperties.h:191
QgsServerWmsDimensionProperties::WmsDimensionInfo::name
QString name
Definition: qgsmaplayerserverproperties.h:189
QgsServerWmsDimensionProperties::WmsDimensionInfo::AllValues
@ AllValues
Display all values of the dimension.
Definition: qgsmaplayerserverproperties.h:165
QgsServerWmsDimensionProperties::DATE
@ DATE
Definition: qgsmaplayerserverproperties.h:147
QgsServerWmsDimensionProperties::TIME
@ TIME
Definition: qgsmaplayerserverproperties.h:146
QgsServerWmsDimensionProperties::WmsDimensionInfo::referenceValue
QVariant referenceValue
Definition: qgsmaplayerserverproperties.h:195
QgsServerWmsDimensionProperties
Manages QGIS Server properties for Wms dimensions.
Definition: qgsmaplayerserverproperties.h:135