QGIS API Documentation 4.3.0-Master (f865f0c58a6)
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
159 struct CORE_EXPORT WmsDimensionInfo
160 {
165 const QString &dimName,
166 const QString &dimFieldName,
167 const QString &dimEndFieldName = QString(),
168 const QString &dimUnits = QString(),
169 const QString &dimUnitSymbol = QString(),
171 const QVariant &dimReferenceValue = QVariant()
172 )
173 : name( dimName )
174 , fieldName( dimFieldName )
175 , endFieldName( dimEndFieldName )
176 , units( dimUnits )
177 , unitSymbol( dimUnitSymbol )
178 , defaultDisplayType( dimDefaultDisplayType )
179 , mReferenceValue( dimReferenceValue )
180 {}
181
182 bool operator==( const WmsDimensionInfo &other ) const;
183 bool operator!=( const WmsDimensionInfo &other ) const;
184
190 QVariant referenceValue() const SIP_PYNAME( _referenceValue ) { return mReferenceValue; }
191
197 void setReferenceValue( const QVariant &referenceValue ) { mReferenceValue = referenceValue; }
198
199
200 QString name;
201 QString fieldName;
203 QString units;
204 QString unitSymbol;
206
207 private:
208 QVariant mReferenceValue;
209 };
210
212
213 // TODO c++20 - replace with = default
214
215 bool operator==( const QgsServerWmsDimensionProperties &other ) const;
216 bool operator!=( const QgsServerWmsDimensionProperties &other ) const;
217
222 static QMap<int, QString> wmsDimensionDefaultDisplayLabels();
223
230 static QMap<Qgis::WmsDimensionDefaultDisplay, QString> wmsDimensionDefaultDisplayDescriptions() SIP_SKIP;
231
239
245 bool removeWmsDimension( const QString &wmsDimName );
246
252 void setWmsDimensions( const QList<QgsServerWmsDimensionProperties::WmsDimensionInfo> &dimensions );
253
259
261 virtual const QgsMapLayer *layer() const = 0;
262
263 protected:
267 void writeXml( QDomNode &layer_node, QDomDocument &document ) const SIP_SKIP;
268
272 void readXml( const QDomNode &layer_node ) SIP_SKIP;
273
279 void copyTo( QgsServerWmsDimensionProperties *properties ) const SIP_SKIP;
280
284 void reset() SIP_SKIP;
285
286 private: // Private attributes
288 QList<WmsDimensionInfo> mWmsDimensions;
289};
290
291
298{
299 Q_GADGET
300
301 public:
308
309 // TODO c++20 - replace with = default
310
311 bool operator==( const QgsMapLayerServerProperties &other ) const;
312 bool operator!=( const QgsMapLayerServerProperties &other ) const;
313
319 void copyTo( QgsMapLayerServerProperties *properties ) const;
320
325 void writeXml( QDomNode &layer_node, QDomDocument &document ) const; // cppcheck-suppress duplInheritedMember
326
331 void readXml( const QDomNode &layer_node ); // cppcheck-suppress duplInheritedMember
332
337 void reset(); // cppcheck-suppress duplInheritedMember
338
346 void setShortName( const QString &name ) { mShortName = name; }
347
355 QString shortName() const { return mShortName; }
356
361 QString wfsTypeName() const;
362
370 void setTitle( const QString &title ) { mTitle = title; }
371
379 void setWfsTitle( const QString &title ) { mWfsTitle = title; }
380
388 QString title() const { return mTitle; }
389
398 QString wfsTitle() const { return mWfsTitle.isEmpty() ? mTitle : mWfsTitle; }
399
407 void setAbstract( const QString &abstract ) { mAbstract = abstract; }
408
416 QString abstract() const { return mAbstract; }
417
425 void setKeywordList( const QString &keywords ) { mKeywordList = keywords; }
426
434 QString keywordList() const { return mKeywordList; }
435
445 void setDataUrl( const QString &dataUrl ) { mDataUrl = dataUrl; }
446
456 QString dataUrl() const { return mDataUrl; }
457
467 void setDataUrlFormat( const QString &dataUrlFormat ) { mDataUrlFormat = dataUrlFormat; }
468
478 QString dataUrlFormat() const { return mDataUrlFormat; }
479
489 void setAttribution( const QString &attrib ) { mAttribution = attrib; }
490
500 QString attribution() const { return mAttribution; }
501
511 void setAttributionUrl( const QString &url ) { mAttributionUrl = url; }
512
522 QString attributionUrl() const { return mAttributionUrl; }
523
529 void setLegendUrl( const QString &legendUrl ) { mLegendUrl = legendUrl; }
530
536 QString legendUrl() const { return mLegendUrl; }
537
543 void setLegendUrlFormat( const QString &legendUrlFormat ) { mLegendUrlFormat = legendUrlFormat; }
544
550 QString legendUrlFormat() const { return mLegendUrlFormat; }
551
553 const QgsMapLayer *layer() const override { return mLayer; };
554
555 private:
556 QgsMapLayer *mLayer = nullptr;
557
558 QString mShortName;
559 QString mTitle;
560 QString mWfsTitle; // optional WFS title
561
562 QString mAttribution;
563 QString mAttributionUrl;
564
565 QString mDataUrl;
566 QString mDataUrlFormat;
567
568 QString mAbstract;
569 QString mKeywordList;
570
572 QString mLegendUrl;
573 QString mLegendUrlFormat;
574};
575
576// XXX How to make a proper SIP type alias ?
577//using QgsVectorLayerServerProperties = QgsMapLayerServerProperties;
578
586{
587 Q_GADGET
588};
589
590#endif // QGSMAPLAYERSERVERPROPERTIES_H
WmsDimensionDefaultDisplay
QGIS Server WMS Dimension default display types.
Definition qgis.h:7030
@ AllValues
Display all values of the dimension.
Definition qgis.h:7031
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
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.
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...