26#include "moc_qgsmaplayerserverproperties.cpp"
28using namespace Qt::StringLiterals;
39 return mMetadataUrls == other.mMetadataUrls;
44 return !( *
this == other );
55 && mReferenceValue == other.mReferenceValue;
60 return !( *
this == other );
70 mMetadataUrls.clear();
75 QDomElement element = layer_node.namedItem( u
"metadataUrls"_s ).toElement();
76 mMetadataUrls.clear();
77 const QDomNodeList el = element.elementsByTagName( u
"metadataUrl"_s );
78 for (
int i = 0; i < el.size(); i++ )
80 element = el.at( i ).toElement();
82 oneUrl.
type = element.attribute( u
"type"_s );
83 oneUrl.
format = element.attribute( u
"format"_s );
84 oneUrl.
url = element.text();
91 if ( !mMetadataUrls.empty() )
93 QDomElement urls = document.createElement( u
"metadataUrls"_s );
96 QDomElement urlElement = document.createElement( u
"metadataUrl"_s );
97 urlElement.setAttribute( u
"type"_s, url.type );
98 urlElement.setAttribute( u
"format"_s, url.format );
99 urlElement.appendChild( document.createTextNode( url.url ) );
100 urls.appendChild( urlElement );
102 layer_node.appendChild( urls );
110 return mWmsDimensions == other.mWmsDimensions;
115 return !( *
this == other );
125 mWmsDimensions.clear();
130 mWmsDimensions = dimensions;
135 QMap<int, QString> labels;
137 for (
auto it = descriptions.cbegin(); it != descriptions.cend(); it++ )
139 labels[
static_cast<int>( it.key() )] = descriptions[it.key()];
147 QMap<Qgis::WmsDimensionDefaultDisplay, QString> labels;
159 if ( dim.name == wmsDimInfo.
name )
164 mWmsDimensions.append( wmsDimInfo );
170 for (
int i = 0; i < mWmsDimensions.size(); ++i )
172 if ( mWmsDimensions[i].name == wmsDimName )
174 mWmsDimensions.removeAt( i );
183 return mWmsDimensions;
196 const QDomNode wmsDimsNode = layer_node.namedItem( u
"wmsDimensions"_s );
197 if ( wmsDimsNode.isNull() )
201 const QDomElement wmsDimsElem = wmsDimsNode.toElement();
202 const QDomNodeList wmsDimsList = wmsDimsElem.elementsByTagName( u
"dimension"_s );
203 for (
int i = 0; i < wmsDimsList.size(); ++i )
205 const QDomElement dimElem = wmsDimsList.at( i ).toElement();
206 const QString dimName = dimElem.attribute( u
"name"_s );
207 const QString dimFieldName = dimElem.attribute( u
"fieldName"_s );
209 const int dimFieldNameIndex = fields.
indexOf( dimFieldName );
210 if ( dimFieldNameIndex == -1 )
214 QVariant dimRefValue;
218 const QString dimRefValueStr = dimElem.attribute( u
"referenceValue"_s );
219 if ( !dimRefValueStr.isEmpty() )
221 const QgsField dimField = fields.
at( dimFieldNameIndex );
222 dimRefValue = QVariant( dimRefValueStr );
230 dim( dimName, dimFieldName, dimElem.attribute( u
"endFieldName"_s ), dimElem.attribute( u
"units"_s ), dimElem.attribute( u
"unitSymbol"_s ), dimDefaultDisplayType, dimRefValue );
234 mWmsDimensions.append( dim );
241 if ( !mWmsDimensions.isEmpty() )
243 QDomElement wmsDimsElem = document.createElement( u
"wmsDimensions"_s );
246 QDomElement dimElem = document.createElement( u
"dimension"_s );
247 dimElem.setAttribute( u
"name"_s, dim.name );
248 dimElem.setAttribute( u
"fieldName"_s, dim.fieldName );
249 dimElem.setAttribute( u
"endFieldName"_s, dim.endFieldName );
250 dimElem.setAttribute( u
"units"_s, dim.units );
251 dimElem.setAttribute( u
"unitSymbol"_s, dim.unitSymbol );
252 dimElem.setAttribute( u
"defaultDisplayType"_s,
static_cast<int>( dim.defaultDisplayType ) );
253 dimElem.setAttribute( u
"referenceValue"_s, dim.referenceValue().toString() );
254 wmsDimsElem.appendChild( dimElem );
256 layer_node.appendChild( wmsDimsElem );
289 && mShortName == other.mShortName
290 && mTitle == other.mTitle
291 && mWfsTitle == other.mWfsTitle
292 && mAbstract == other.mAbstract
293 && mKeywordList == other.mKeywordList
294 && mDataUrl == other.mDataUrl
295 && mDataUrlFormat == other.mDataUrlFormat
296 && mAttribution == other.mAttribution
297 && mAttributionUrl == other.mAttributionUrl
298 && mLegendUrl == other.mLegendUrl
299 && mLegendUrlFormat == other.mLegendUrlFormat;
304 return !( *
this == other );
315 QString name = mLayer ? mLayer->name() : QString();
316 if ( !mShortName.isEmpty() )
319 name.replace(
' ',
'_' ).replace(
':',
'-' ).replace( QChar( 0x2014 ) ,
'-' );
321 return name.toLocal8Bit();
331 const QDomElement metaUrlElem = layerNode.firstChildElement( u
"metadataUrl"_s );
332 if ( !metaUrlElem.isNull() )
334 const QString url = metaUrlElem.text();
335 const QString type = metaUrlElem.attribute( u
"type"_s, QString() );
336 const QString format = metaUrlElem.attribute( u
"format"_s, QString() );
338 setMetadataUrls( QList<QgsMapLayerServerProperties::MetadataUrl>() << newItem );
345 const QDomElement shortNameElem = layerNode.firstChildElement( u
"shortname"_s );
346 if ( !shortNameElem.isNull() )
348 mShortName = shortNameElem.text();
352 const QDomElement titleElem = layerNode.firstChildElement( u
"title"_s );
353 if ( !titleElem.isNull() )
355 mTitle = titleElem.text();
356 mWfsTitle = titleElem.attribute( u
"wfs"_s );
360 const QDomElement abstractElem = layerNode.firstChildElement( u
"abstract"_s );
361 if ( !abstractElem.isNull() )
363 mAbstract = abstractElem.text();
367 const QDomElement keywordListElem = layerNode.firstChildElement( u
"keywordList"_s );
368 if ( !keywordListElem.isNull() )
371 for ( QDomNode n = keywordListElem.firstChild(); !n.isNull(); n = n.nextSibling() )
373 const QString keyword = n.toElement().text();
374 if ( !keyword.isEmpty() )
377 mKeywordList = kwdList.join(
", "_L1 );
381 const QDomElement dataUrlElem = layerNode.firstChildElement( u
"dataUrl"_s );
382 if ( !dataUrlElem.isNull() )
384 mDataUrl = dataUrlElem.text();
385 mDataUrlFormat = dataUrlElem.attribute( u
"format"_s, QString() );
389 const QDomElement attribElem = layerNode.firstChildElement( u
"attribution"_s );
390 if ( !attribElem.isNull() )
392 mAttribution = attribElem.text();
393 mAttributionUrl = attribElem.attribute( u
"href"_s, QString() );
397 const QDomElement legendUrlElem = layerNode.firstChildElement( u
"legendUrl"_s );
398 if ( !legendUrlElem.isNull() )
400 mLegendUrl = legendUrlElem.text();
401 mLegendUrlFormat = legendUrlElem.attribute( u
"format"_s, QString() );
411 if ( !mShortName.isEmpty() )
413 QDomElement layerShortName = document.createElement( u
"shortname"_s );
414 const QDomText layerShortNameText = document.createTextNode( mShortName );
415 layerShortName.appendChild( layerShortNameText );
416 layerNode.appendChild( layerShortName );
420 if ( !mTitle.isEmpty() )
422 QDomElement layerTitle = document.createElement( u
"title"_s );
423 const QDomText layerTitleText = document.createTextNode( mTitle );
424 layerTitle.appendChild( layerTitleText );
426 if ( mTitle != mWfsTitle )
428 layerTitle.setAttribute(
"wfs", mWfsTitle );
431 layerNode.appendChild( layerTitle );
435 if ( !mAbstract.isEmpty() )
437 QDomElement layerAbstract = document.createElement( u
"abstract"_s );
438 const QDomText layerAbstractText = document.createTextNode( mAbstract );
439 layerAbstract.appendChild( layerAbstractText );
440 layerNode.appendChild( layerAbstract );
444 const QStringList keywordStringList = mKeywordList.split(
',', Qt::SkipEmptyParts );
445 if ( !keywordStringList.isEmpty() )
447 QDomElement layerKeywordList = document.createElement( u
"keywordList"_s );
448 for (
int i = 0; i < keywordStringList.size(); ++i )
450 QDomElement layerKeywordValue = document.createElement( u
"value"_s );
451 const QDomText layerKeywordText = document.createTextNode( keywordStringList.at( i ).trimmed() );
452 layerKeywordValue.appendChild( layerKeywordText );
453 layerKeywordList.appendChild( layerKeywordValue );
455 layerNode.appendChild( layerKeywordList );
459 if ( !mDataUrl.isEmpty() )
461 QDomElement layerDataUrl = document.createElement( u
"dataUrl"_s );
462 const QDomText layerDataUrlText = document.createTextNode( mDataUrl );
463 layerDataUrl.appendChild( layerDataUrlText );
464 layerDataUrl.setAttribute( u
"format"_s, mDataUrlFormat );
465 layerNode.appendChild( layerDataUrl );
469 if ( !mLegendUrl.isEmpty() )
471 QDomElement layerLegendUrl = document.createElement( u
"legendUrl"_s );
472 const QDomText layerLegendUrlText = document.createTextNode( mLegendUrl );
473 layerLegendUrl.appendChild( layerLegendUrlText );
474 layerLegendUrl.setAttribute( u
"format"_s, mLegendUrlFormat );
475 layerNode.appendChild( layerLegendUrl );
479 if ( !mAttribution.isEmpty() )
481 QDomElement layerAttribution = document.createElement( u
"attribution"_s );
482 const QDomText layerAttributionText = document.createTextNode( mAttribution );
483 layerAttribution.appendChild( layerAttributionText );
484 layerAttribution.setAttribute( u
"href"_s, mAttributionUrl );
485 layerNode.appendChild( layerAttribution );
WmsDimensionDefaultDisplay
QGIS Server WMS Dimension default display types.
@ MinValue
Display minimum value of the dimension.
@ AllValues
Display all values of the dimension.
@ MaxValue
Display maximum value of the dimension.
@ ReferenceValue
Display a reference value.
Encapsulate a field in an attribute table or data source.
bool convertCompatible(QVariant &v, QString *errorMessage=nullptr) const
Converts the provided variant to a compatible format.
Container of fields for a vector layer.
Q_INVOKABLE int indexOf(const QString &fieldName) const
Gets the field index from the field name.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
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.
void setAttributionUrl(const QString &url)
Sets the attribution url 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.
void setLegendUrlFormat(const QString &legendUrlFormat)
Sets the format for a URL based layer legend.
void copyTo(QgsMapLayerServerProperties *properties) const
Copy properties to another instance.
bool operator==(const QgsMapLayerServerProperties &other) const
QgsMapLayerServerProperties(QgsMapLayer *layer=nullptr)
Constructor - Creates a Map Layer QGIS Server Properties.
QString wfsTypeName() const
Returns WFS typename for the layer.
const QgsMapLayer * layer() const override
Gets the parent layer.
bool operator!=(const QgsMapLayerServerProperties &other) const
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.
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.
Base class for all map layer types.
Manages QGIS Server properties for WMS dimensions.
void readXml(const QDomNode &layer_node)
Reads server properties from project file.
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.
void copyTo(QgsServerWmsDimensionProperties *properties) const
Copy properties to another instance.
static QMap< Qgis::WmsDimensionDefaultDisplay, QString > wmsDimensionDefaultDisplayDescriptions()
Returns WMS Dimension default display descriptions.
bool operator==(const QgsServerWmsDimensionProperties &other) const
bool operator!=(const QgsServerWmsDimensionProperties &other) const
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.
Represents a vector layer which manages a vector based dataset.
Setting to define QGIS Server WMS Dimension.
bool operator!=(const WmsDimensionInfo &other) const
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.
bool operator==(const WmsDimensionInfo &other) const
Qgis::WmsDimensionDefaultDisplay defaultDisplayType