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;
197 const QDomNode wmsDimsNode = layer_node.namedItem( u
"wmsDimensions"_s );
198 if ( wmsDimsNode.isNull() )
202 const QDomElement wmsDimsElem = wmsDimsNode.toElement();
203 const QDomNodeList wmsDimsList = wmsDimsElem.elementsByTagName( u
"dimension"_s );
204 for (
int i = 0; i < wmsDimsList.size(); ++i )
206 const QDomElement dimElem = wmsDimsList.at( i ).toElement();
207 const QString dimName = dimElem.attribute( u
"name"_s );
208 const QString dimFieldName = dimElem.attribute( u
"fieldName"_s );
210 const QString dimRefValueStr = dimElem.attribute( u
"referenceValue"_s );
212 QVariant dimRefValue;
217 const int dimFieldNameIndex = fields.
indexOf( dimFieldName );
218 if ( dimFieldNameIndex == -1 )
221 if ( !dimRefValueStr.isEmpty() )
223 const QgsField dimField = fields.
at( dimFieldNameIndex );
224 dimRefValue = QVariant( dimRefValueStr );
232 dimRefValue = QDateTime::fromString( dimRefValueStr, Qt::ISODate );
236 dim( dimName, dimFieldName, dimElem.attribute( u
"endFieldName"_s ), dimElem.attribute( u
"units"_s ), dimElem.attribute( u
"unitSymbol"_s ), dimDefaultDisplayType, dimRefValue );
240 mWmsDimensions.append( dim );
247 if ( !mWmsDimensions.isEmpty() )
249 QDomElement wmsDimsElem = document.createElement( u
"wmsDimensions"_s );
252 QDomElement dimElem = document.createElement( u
"dimension"_s );
253 dimElem.setAttribute( u
"name"_s, dim.name );
255 if ( !dim.fieldName.isEmpty() )
256 dimElem.setAttribute( u
"fieldName"_s, dim.fieldName );
258 if ( !dim.endFieldName.isEmpty() )
259 dimElem.setAttribute( u
"endFieldName"_s, dim.endFieldName );
261 if ( !dim.units.isEmpty() )
262 dimElem.setAttribute( u
"units"_s, dim.units );
264 if ( !dim.unitSymbol.isEmpty() )
265 dimElem.setAttribute( u
"unitSymbol"_s, dim.unitSymbol );
267 dimElem.setAttribute( u
"defaultDisplayType"_s,
static_cast<int>( dim.defaultDisplayType ) );
269 if ( !dim.referenceValue().isNull() )
270 dimElem.setAttribute( u
"referenceValue"_s, dim.referenceValue().toString() );
272 wmsDimsElem.appendChild( dimElem );
274 layer_node.appendChild( wmsDimsElem );
307 && mShortName == other.mShortName
308 && mTitle == other.mTitle
309 && mWfsTitle == other.mWfsTitle
310 && mAbstract == other.mAbstract
311 && mKeywordList == other.mKeywordList
312 && mDataUrl == other.mDataUrl
313 && mDataUrlFormat == other.mDataUrlFormat
314 && mAttribution == other.mAttribution
315 && mAttributionUrl == other.mAttributionUrl
316 && mLegendUrl == other.mLegendUrl
317 && mLegendUrlFormat == other.mLegendUrlFormat;
322 return !( *
this == other );
333 QString name = mLayer ? mLayer->name() : QString();
334 if ( !mShortName.isEmpty() )
337 name.replace(
' ',
'_' ).replace(
':',
'-' ).replace( QChar( 0x2014 ) ,
'-' );
339 return name.toLocal8Bit();
349 const QDomElement metaUrlElem = layerNode.firstChildElement( u
"metadataUrl"_s );
350 if ( !metaUrlElem.isNull() )
352 const QString url = metaUrlElem.text();
353 const QString type = metaUrlElem.attribute( u
"type"_s, QString() );
354 const QString format = metaUrlElem.attribute( u
"format"_s, QString() );
356 setMetadataUrls( QList<QgsMapLayerServerProperties::MetadataUrl>() << newItem );
363 const QDomElement shortNameElem = layerNode.firstChildElement( u
"shortname"_s );
364 if ( !shortNameElem.isNull() )
366 mShortName = shortNameElem.text();
370 const QDomElement titleElem = layerNode.firstChildElement( u
"title"_s );
371 if ( !titleElem.isNull() )
373 mTitle = titleElem.text();
374 mWfsTitle = titleElem.attribute( u
"wfs"_s );
378 const QDomElement abstractElem = layerNode.firstChildElement( u
"abstract"_s );
379 if ( !abstractElem.isNull() )
381 mAbstract = abstractElem.text();
385 const QDomElement keywordListElem = layerNode.firstChildElement( u
"keywordList"_s );
386 if ( !keywordListElem.isNull() )
389 for ( QDomNode n = keywordListElem.firstChild(); !n.isNull(); n = n.nextSibling() )
391 const QString keyword = n.toElement().text();
392 if ( !keyword.isEmpty() )
395 mKeywordList = kwdList.join(
", "_L1 );
399 const QDomElement dataUrlElem = layerNode.firstChildElement( u
"dataUrl"_s );
400 if ( !dataUrlElem.isNull() )
402 mDataUrl = dataUrlElem.text();
403 mDataUrlFormat = dataUrlElem.attribute( u
"format"_s, QString() );
407 const QDomElement attribElem = layerNode.firstChildElement( u
"attribution"_s );
408 if ( !attribElem.isNull() )
410 mAttribution = attribElem.text();
411 mAttributionUrl = attribElem.attribute( u
"href"_s, QString() );
415 const QDomElement legendUrlElem = layerNode.firstChildElement( u
"legendUrl"_s );
416 if ( !legendUrlElem.isNull() )
418 mLegendUrl = legendUrlElem.text();
419 mLegendUrlFormat = legendUrlElem.attribute( u
"format"_s, QString() );
429 if ( !mShortName.isEmpty() )
431 QDomElement layerShortName = document.createElement( u
"shortname"_s );
432 const QDomText layerShortNameText = document.createTextNode( mShortName );
433 layerShortName.appendChild( layerShortNameText );
434 layerNode.appendChild( layerShortName );
438 if ( !mTitle.isEmpty() )
440 QDomElement layerTitle = document.createElement( u
"title"_s );
441 const QDomText layerTitleText = document.createTextNode( mTitle );
442 layerTitle.appendChild( layerTitleText );
444 if ( mTitle != mWfsTitle )
446 layerTitle.setAttribute(
"wfs", mWfsTitle );
449 layerNode.appendChild( layerTitle );
453 if ( !mAbstract.isEmpty() )
455 QDomElement layerAbstract = document.createElement( u
"abstract"_s );
456 const QDomText layerAbstractText = document.createTextNode( mAbstract );
457 layerAbstract.appendChild( layerAbstractText );
458 layerNode.appendChild( layerAbstract );
462 const QStringList keywordStringList = mKeywordList.split(
',', Qt::SkipEmptyParts );
463 if ( !keywordStringList.isEmpty() )
465 QDomElement layerKeywordList = document.createElement( u
"keywordList"_s );
466 for (
int i = 0; i < keywordStringList.size(); ++i )
468 QDomElement layerKeywordValue = document.createElement( u
"value"_s );
469 const QDomText layerKeywordText = document.createTextNode( keywordStringList.at( i ).trimmed() );
470 layerKeywordValue.appendChild( layerKeywordText );
471 layerKeywordList.appendChild( layerKeywordValue );
473 layerNode.appendChild( layerKeywordList );
477 if ( !mDataUrl.isEmpty() )
479 QDomElement layerDataUrl = document.createElement( u
"dataUrl"_s );
480 const QDomText layerDataUrlText = document.createTextNode( mDataUrl );
481 layerDataUrl.appendChild( layerDataUrlText );
482 layerDataUrl.setAttribute( u
"format"_s, mDataUrlFormat );
483 layerNode.appendChild( layerDataUrl );
487 if ( !mLegendUrl.isEmpty() )
489 QDomElement layerLegendUrl = document.createElement( u
"legendUrl"_s );
490 const QDomText layerLegendUrlText = document.createTextNode( mLegendUrl );
491 layerLegendUrl.appendChild( layerLegendUrlText );
492 layerLegendUrl.setAttribute( u
"format"_s, mLegendUrlFormat );
493 layerNode.appendChild( layerLegendUrl );
497 if ( !mAttribution.isEmpty() )
499 QDomElement layerAttribution = document.createElement( u
"attribution"_s );
500 const QDomText layerAttributionText = document.createTextNode( mAttribution );
501 layerAttribution.appendChild( layerAttributionText );
502 layerAttribution.setAttribute( u
"href"_s, mAttributionUrl );
503 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
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.
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