QGIS API Documentation 4.3.0-Master (0cfde48c85b)
Loading...
Searching...
No Matches
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.h"
22#include "qgis_core.h"
23#include "qgis_sip.h"
24
25#include <QMap>
26#include <QMetaType>
27#include <QString>
28#include <QVariant>
29
30class QgsMapLayer;
31
32class QDomNode;
33class QDomDocument;
34
41{
42 Q_GADGET
43
44 public:
50 struct CORE_EXPORT MetadataUrl
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
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 // TODO c++20 - replace with = default
108
109 bool operator==( const QgsServerMetadataUrlProperties &other ) const;
110 bool operator!=( const QgsServerMetadataUrlProperties &other ) const;
111
112 protected:
114 void writeXml( QDomNode &layerNode, QDomDocument &document ) const SIP_SKIP;
115
117 void readXml( const QDomNode &layerNode ) SIP_SKIP;
118
124 void copyTo( QgsServerMetadataUrlProperties *properties ) const SIP_SKIP;
125
127 void reset() SIP_SKIP;
128
129 private:
130 QList<MetadataUrl> mMetadataUrls;
131};
132
133
140{
141 Q_GADGET
142
143 public:
153 Q_ENUM( PredefinedWmsDimensionName )
154
155 SIP_SKIP static constexpr const char *TIME_DIMENSION_NAME = "TIME";
156
161 struct CORE_EXPORT WmsDimensionInfo
162 {
167 const QString &dimName,
168 const QString &dimFieldName,
169 const QString &dimEndFieldName = QString(),
170 const QString &dimUnits = QString(),
171 const QString &dimUnitSymbol = QString(),
173 const QVariant &dimReferenceValue = QVariant()
174 )
175 : name( dimName )
176 , fieldName( dimFieldName )
177 , endFieldName( dimEndFieldName )
178 , units( dimUnits )
179 , unitSymbol( dimUnitSymbol )
180 , defaultDisplayType( dimDefaultDisplayType )
181 , mReferenceValue( dimReferenceValue )
182 {}
183
191 const QString &dimName, Qgis::WmsDimensionDefaultDisplay dimDefaultDisplayType = Qgis::WmsDimensionDefaultDisplay::AllValues, const QVariant &dimReferenceValue = QVariant()
192 )
193 : name( dimName )
194 , defaultDisplayType( dimDefaultDisplayType )
195 , mReferenceValue( dimReferenceValue )
196 {}
197
198 bool operator==( const WmsDimensionInfo &other ) const;
199 bool operator!=( const WmsDimensionInfo &other ) const;
200
206 QVariant referenceValue() const SIP_PYNAME( _referenceValue ) { return mReferenceValue; }
207
213 void setReferenceValue( const QVariant &referenceValue ) { mReferenceValue = referenceValue; }
214
215
216 QString name;
217 QString fieldName;
219 QString units;
220 QString unitSymbol;
222
223 private:
224 QVariant mReferenceValue;
225 };
226
228
229 // TODO c++20 - replace with = default
230
231 bool operator==( const QgsServerWmsDimensionProperties &other ) const;
232 bool operator!=( const QgsServerWmsDimensionProperties &other ) const;
233
238 static QMap<int, QString> wmsDimensionDefaultDisplayLabels();
239
246 static QMap<Qgis::WmsDimensionDefaultDisplay, QString> wmsDimensionDefaultDisplayDescriptions() SIP_SKIP;
247
255
261 bool removeWmsDimension( const QString &wmsDimName );
262
268 void setWmsDimensions( const QList<QgsServerWmsDimensionProperties::WmsDimensionInfo> &dimensions );
269
275
277 virtual const QgsMapLayer *layer() const = 0;
278
279 protected:
283 void writeXml( QDomNode &layer_node, QDomDocument &document ) const SIP_SKIP;
284
288 void readXml( const QDomNode &layer_node ) SIP_SKIP;
289
295 void copyTo( QgsServerWmsDimensionProperties *properties ) const SIP_SKIP;
296
300 void reset() SIP_SKIP;
301
302 private: // Private attributes
304 QList<WmsDimensionInfo> mWmsDimensions;
305};
306
307
314{
315 Q_GADGET
316
317 public:
324
325 // TODO c++20 - replace with = default
326
327 bool operator==( const QgsMapLayerServerProperties &other ) const;
328 bool operator!=( const QgsMapLayerServerProperties &other ) const;
329
335 void copyTo( QgsMapLayerServerProperties *properties ) const;
336
341 void writeXml( QDomNode &layer_node, QDomDocument &document ) const; // cppcheck-suppress duplInheritedMember
342
347 void readXml( const QDomNode &layer_node ); // cppcheck-suppress duplInheritedMember
348
353 void reset(); // cppcheck-suppress duplInheritedMember
354
362 void setShortName( const QString &name ) { mShortName = name; }
363
371 QString shortName() const { return mShortName; }
372
377 QString wfsTypeName() const;
378
386 void setTitle( const QString &title ) { mTitle = title; }
387
395 void setWfsTitle( const QString &title ) { mWfsTitle = title; }
396
404 QString title() const { return mTitle; }
405
414 QString wfsTitle() const { return mWfsTitle.isEmpty() ? mTitle : mWfsTitle; }
415
423 void setAbstract( const QString &abstract ) { mAbstract = abstract; }
424
432 QString abstract() const { return mAbstract; }
433
441 void setKeywordList( const QString &keywords ) { mKeywordList = keywords; }
442
450 QString keywordList() const { return mKeywordList; }
451
461 void setDataUrl( const QString &dataUrl ) { mDataUrl = dataUrl; }
462
472 QString dataUrl() const { return mDataUrl; }
473
483 void setDataUrlFormat( const QString &dataUrlFormat ) { mDataUrlFormat = dataUrlFormat; }
484
494 QString dataUrlFormat() const { return mDataUrlFormat; }
495
505 void setAttribution( const QString &attrib ) { mAttribution = attrib; }
506
516 QString attribution() const { return mAttribution; }
517
527 void setAttributionUrl( const QString &url ) { mAttributionUrl = url; }
528
538 QString attributionUrl() const { return mAttributionUrl; }
539
545 void setLegendUrl( const QString &legendUrl ) { mLegendUrl = legendUrl; }
546
552 QString legendUrl() const { return mLegendUrl; }
553
559 void setLegendUrlFormat( const QString &legendUrlFormat ) { mLegendUrlFormat = legendUrlFormat; }
560
566 QString legendUrlFormat() const { return mLegendUrlFormat; }
567
569 const QgsMapLayer *layer() const override { return mLayer; };
570
571 private:
572 QgsMapLayer *mLayer = nullptr;
573
574 QString mShortName;
575 QString mTitle;
576 QString mWfsTitle; // optional WFS title
577
578 QString mAttribution;
579 QString mAttributionUrl;
580
581 QString mDataUrl;
582 QString mDataUrlFormat;
583
584 QString mAbstract;
585 QString mKeywordList;
586
588 QString mLegendUrl;
589 QString mLegendUrlFormat;
590};
591
592// XXX How to make a proper SIP type alias ?
593//using QgsVectorLayerServerProperties = QgsMapLayerServerProperties;
594
602{
603 Q_GADGET
604};
605
606#endif // QGSMAPLAYERSERVERPROPERTIES_H
WmsDimensionDefaultDisplay
QGIS Server WMS Dimension default display types.
Definition qgis.h:7152
@ AllValues
Display all values of the dimension.
Definition qgis.h:7153
void setLegendUrl(const QString &legendUrl)
Sets the URL for the layer's legend.
void readXml(const QDomNode &layer_node)
Reads server properties from project file.
void setDataUrl(const QString &dataUrl)
Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request.
void setAbstract(const QString &abstract)
Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
void setDataUrlFormat(const QString &dataUrlFormat)
Sets the DataUrl format of the layerused by QGIS Server in GetCapabilities request.
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
void setAttributionUrl(const QString &url)
Sets the attribution url of the layer used by QGIS Server in GetCapabilities request.
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
void setAttribution(const QString &attrib)
Sets the attribution of the layer used by QGIS Server in GetCapabilities request.
void setShortName(const QString &name)
Sets the short name of the layer used by QGIS Server to identify the layer.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
void setLegendUrlFormat(const QString &legendUrlFormat)
Sets the format for a URL based layer legend.
QString legendUrlFormat() const
Returns the format for a URL based layer legend.
void copyTo(QgsMapLayerServerProperties *properties) const
Copy properties to another instance.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
QgsMapLayerServerProperties(QgsMapLayer *layer=nullptr)
Constructor - Creates a Map Layer QGIS Server Properties.
QString keywordList() const
Returns the keyword list of the layerused by QGIS Server in GetCapabilities request.
QString wfsTitle() const
Returns the optional WFS title if set or the title of the layer used by QGIS WFS in GetCapabilities r...
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
const QgsMapLayer * layer() const override
Gets the parent layer.
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves server properties to xml under the layer node.
void setTitle(const QString &title)
Sets the title of the layer used by QGIS Server in GetCapabilities request.
void setKeywordList(const QString &keywords)
Sets the keywords list of the layerused by QGIS Server in GetCapabilities request.
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
void reset()
Reset properties to default.
void setWfsTitle(const QString &title)
Sets the title of the layer used by QGIS Server in WFS GetCapabilities request.
QString legendUrl() const
Returns the URL for the layer's legend.
QString abstract() const
Returns the abstract of the layerused by QGIS Server in GetCapabilities request.
Base class for all map layer types.
Definition qgsmaplayer.h:83
Manages QGIS Server properties for a map layer.
virtual ~QgsServerMetadataUrlProperties()=default
virtual const QgsMapLayer * layer() const =0
Gets the parent layer.
void addMetadataUrl(const QgsServerMetadataUrlProperties::MetadataUrl &metaUrl)
Add a metadataUrl for the layer.
void writeXml(QDomNode &layerNode, QDomDocument &document) const
Saves server properties to xml under the layer node.
void reset()
Reset properties to default.
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.
void copyTo(QgsServerMetadataUrlProperties *properties) const
Copy properties to another instance.
void readXml(const QDomNode &layerNode)
Reads server properties from project file.
Manages QGIS Server properties for WMS dimensions.
void readXml(const QDomNode &layer_node)
Reads server properties from project file.
PredefinedWmsDimensionName
Predefined/Restricted WMS Dimension name.
static QMap< int, QString > wmsDimensionDefaultDisplayLabels()
Returns WMS Dimension default display labels.
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves server properties to xml under the layer node.
void reset()
Reset properties to default.
bool addWmsDimension(const QgsServerWmsDimensionProperties::WmsDimensionInfo &wmsDimInfo)
Adds a QGIS Server WMS Dimension.
virtual const QgsMapLayer * layer() const =0
Gets the parent layer.
void copyTo(QgsServerWmsDimensionProperties *properties) const
Copy properties to another instance.
static QMap< Qgis::WmsDimensionDefaultDisplay, QString > wmsDimensionDefaultDisplayDescriptions()
Returns WMS Dimension default display descriptions.
virtual ~QgsServerWmsDimensionProperties()=default
static constexpr const char * TIME_DIMENSION_NAME
bool removeWmsDimension(const QString &wmsDimName)
Removes a QGIS Server WMS Dimension.
const QList< QgsServerWmsDimensionProperties::WmsDimensionInfo > wmsDimensions() const
Returns the QGIS Server WMS Dimension list.
void setWmsDimensions(const QList< QgsServerWmsDimensionProperties::WmsDimensionInfo > &dimensions)
Set WMS Dimensions.
Convenient class for API compatibility.
#define SIP_SKIP
Definition qgis_sip.h:138
#define SIP_PYNAME(name)
Definition qgis_sip.h:88
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
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(), Qgis::WmsDimensionDefaultDisplay dimDefaultDisplayType=Qgis::WmsDimensionDefaultDisplay::AllValues, const QVariant &dimReferenceValue=QVariant())
Constructor for WmsDimensionInfo.
WmsDimensionInfo(const QString &dimName, Qgis::WmsDimensionDefaultDisplay dimDefaultDisplayType=Qgis::WmsDimensionDefaultDisplay::AllValues, const QVariant &dimReferenceValue=QVariant())
Constructor for layer tree group TIME WmsDimensionInfo which doesn't require field and unit informati...
void setReferenceValue(const QVariant &referenceValue)
Set referenceValue used when default display type is Qgis::WmsDimensionDefaultDisplay::ReferenceValue...
QVariant referenceValue() const
Returns reference value used when default display type is Qgis::WmsDimensionDefaultDisplay::Reference...