19#include "moc_qgsmaplayerserverproperties.cpp"
36 return mMetadataUrls == other.mMetadataUrls;
41 return !( *
this == other );
46 return name == other.
name
49 && units == other.
units
57 return !( *
this == other );
67 mMetadataUrls.clear();
72 QDomElement element = layer_node.namedItem( QStringLiteral(
"metadataUrls" ) ).toElement();
73 mMetadataUrls.clear();
74 const QDomNodeList el = element.elementsByTagName( QStringLiteral(
"metadataUrl" ) );
75 for (
int i = 0; i < el.size(); i++ )
77 element = el.at( i ).toElement();
79 oneUrl.
type = element.attribute( QStringLiteral(
"type" ) );
80 oneUrl.
format = element.attribute( QStringLiteral(
"format" ) );
81 oneUrl.
url = element.text();
88 if ( !mMetadataUrls.empty() )
90 QDomElement urls = document.createElement( QStringLiteral(
"metadataUrls" ) );
93 QDomElement urlElement = document.createElement( QStringLiteral(
"metadataUrl" ) );
94 urlElement.setAttribute( QStringLiteral(
"type" ), url.type );
95 urlElement.setAttribute( QStringLiteral(
"format" ), url.format );
96 urlElement.appendChild( document.createTextNode( url.url ) );
97 urls.appendChild( urlElement );
99 layer_node.appendChild( urls );
107 return mWmsDimensions == other.mWmsDimensions;
112 return !( *
this == other );
122 mWmsDimensions.clear();
127 mWmsDimensions = dimensions;
132 QMap<int, QString> labels;
144 if ( dim.name == wmsDimInfo.
name )
149 mWmsDimensions.append( wmsDimInfo );
155 for (
int i = 0; i < mWmsDimensions.size(); ++i )
157 if ( mWmsDimensions[ i ].name == wmsDimName )
159 mWmsDimensions.removeAt( i );
168 return mWmsDimensions;
181 const QDomNode wmsDimsNode = layer_node.namedItem( QStringLiteral(
"wmsDimensions" ) );
182 if ( wmsDimsNode.isNull() )
186 const QDomElement wmsDimsElem = wmsDimsNode.toElement();
187 const QDomNodeList wmsDimsList = wmsDimsElem.elementsByTagName( QStringLiteral(
"dimension" ) );
188 for (
int i = 0; i < wmsDimsList.size(); ++i )
190 const QDomElement dimElem = wmsDimsList.
at( i ).toElement();
191 const QString dimName = dimElem.attribute( QStringLiteral(
"name" ) );
192 const QString dimFieldName = dimElem.attribute( QStringLiteral(
"fieldName" ) );
194 const int dimFieldNameIndex = fields.
indexOf( dimFieldName );
195 if ( dimFieldNameIndex == -1 )
199 QVariant dimRefValue;
200 const int dimDefaultDisplayType = dimElem.attribute( QStringLiteral(
"defaultDisplayType" ) ).toInt();
203 const QString dimRefValueStr = dimElem.attribute( QStringLiteral(
"referenceValue" ) );
204 if ( !dimRefValueStr.isEmpty() )
206 const QgsField dimField = fields.
at( dimFieldNameIndex );
207 dimRefValue = QVariant( dimRefValueStr );
215 dimElem.attribute( QStringLiteral(
"endFieldName" ) ),
216 dimElem.attribute( QStringLiteral(
"units" ) ),
217 dimElem.attribute( QStringLiteral(
"unitSymbol" ) ),
218 dimDefaultDisplayType, dimRefValue );
222 mWmsDimensions.append( dim );
229 if ( ! mWmsDimensions.isEmpty() )
231 QDomElement wmsDimsElem = document.createElement( QStringLiteral(
"wmsDimensions" ) );
234 QDomElement dimElem = document.createElement( QStringLiteral(
"dimension" ) );
235 dimElem.setAttribute( QStringLiteral(
"name" ), dim.name );
236 dimElem.setAttribute( QStringLiteral(
"fieldName" ), dim.fieldName );
237 dimElem.setAttribute( QStringLiteral(
"endFieldName" ), dim.endFieldName );
238 dimElem.setAttribute( QStringLiteral(
"units" ), dim.units );
239 dimElem.setAttribute( QStringLiteral(
"unitSymbol" ), dim.unitSymbol );
240 dimElem.setAttribute( QStringLiteral(
"defaultDisplayType" ), dim.defaultDisplayType );
241 dimElem.setAttribute( QStringLiteral(
"referenceValue" ), dim.referenceValue.toString() );
242 wmsDimsElem.appendChild( dimElem );
244 layer_node.appendChild( wmsDimsElem );
277 && mShortName == other.mShortName
278 && mTitle == other.mTitle
279 && mAbstract == other.mAbstract
280 && mKeywordList == other.mKeywordList
281 && mDataUrl == other.mDataUrl
282 && mDataUrlFormat == other.mDataUrlFormat
283 && mAttribution == other.mAttribution
284 && mAttributionUrl == other.mAttributionUrl
285 && mLegendUrl == other.mLegendUrl
286 && mLegendUrlFormat == other.mLegendUrlFormat;
291 return !( *
this == other );
307 const QDomElement metaUrlElem = layerNode.firstChildElement( QStringLiteral(
"metadataUrl" ) );
308 if ( !metaUrlElem.isNull() )
310 const QString url = metaUrlElem.text();
311 const QString type = metaUrlElem.attribute( QStringLiteral(
"type" ), QString() );
312 const QString format = metaUrlElem.attribute( QStringLiteral(
"format" ), QString() );
314 setMetadataUrls( QList<QgsMapLayerServerProperties::MetadataUrl>() << newItem );
321 const QDomElement shortNameElem = layerNode.firstChildElement( QStringLiteral(
"shortname" ) );
322 if ( !shortNameElem.isNull() )
324 mShortName = shortNameElem.text();
328 const QDomElement titleElem = layerNode.firstChildElement( QStringLiteral(
"title" ) );
329 if ( !titleElem.isNull() )
331 mTitle = titleElem.text();
332 mWfsTitle = titleElem.attribute( QStringLiteral(
"wfs" ) );
336 const QDomElement abstractElem = layerNode.firstChildElement( QStringLiteral(
"abstract" ) );
337 if ( !abstractElem.isNull() )
339 mAbstract = abstractElem.text();
343 const QDomElement keywordListElem = layerNode.firstChildElement( QStringLiteral(
"keywordList" ) );
344 if ( !keywordListElem.isNull() )
347 for ( QDomNode n = keywordListElem.firstChild(); !n.isNull(); n = n.nextSibling() )
349 const QString keyword = n.toElement().text();
350 if ( !keyword.isEmpty() )
353 mKeywordList = kwdList.join( QLatin1String(
", " ) );
357 const QDomElement dataUrlElem = layerNode.firstChildElement( QStringLiteral(
"dataUrl" ) );
358 if ( !dataUrlElem.isNull() )
360 mDataUrl = dataUrlElem.text();
361 mDataUrlFormat = dataUrlElem.attribute( QStringLiteral(
"format" ), QString() );
365 const QDomElement attribElem = layerNode.firstChildElement( QStringLiteral(
"attribution" ) );
366 if ( !attribElem.isNull() )
368 mAttribution = attribElem.text();
369 mAttributionUrl = attribElem.attribute( QStringLiteral(
"href" ), QString() );
373 const QDomElement legendUrlElem = layerNode.firstChildElement( QStringLiteral(
"legendUrl" ) );
374 if ( !legendUrlElem.isNull() )
376 mLegendUrl = legendUrlElem.text();
377 mLegendUrlFormat = legendUrlElem.attribute( QStringLiteral(
"format" ), QString() );
387 if ( !mShortName.isEmpty() )
389 QDomElement layerShortName = document.createElement( QStringLiteral(
"shortname" ) );
390 const QDomText layerShortNameText = document.createTextNode( mShortName );
391 layerShortName.appendChild( layerShortNameText );
392 layerNode.appendChild( layerShortName );
396 if ( !mTitle.isEmpty() )
398 QDomElement layerTitle = document.createElement( QStringLiteral(
"title" ) );
399 const QDomText layerTitleText = document.createTextNode( mTitle );
400 layerTitle.appendChild( layerTitleText );
402 if ( mTitle != mWfsTitle )
404 layerTitle.setAttribute(
"wfs", mWfsTitle );
407 layerNode.appendChild( layerTitle );
411 if ( !mAbstract.isEmpty() )
413 QDomElement layerAbstract = document.createElement( QStringLiteral(
"abstract" ) );
414 const QDomText layerAbstractText = document.createTextNode( mAbstract );
415 layerAbstract.appendChild( layerAbstractText );
416 layerNode.appendChild( layerAbstract );
420 const QStringList keywordStringList = mKeywordList.split(
',', Qt::SkipEmptyParts );
421 if ( !keywordStringList.isEmpty() )
423 QDomElement layerKeywordList = document.createElement( QStringLiteral(
"keywordList" ) );
424 for (
int i = 0; i < keywordStringList.size(); ++i )
426 QDomElement layerKeywordValue = document.createElement( QStringLiteral(
"value" ) );
427 const QDomText layerKeywordText = document.createTextNode( keywordStringList.at( i ).trimmed() );
428 layerKeywordValue.appendChild( layerKeywordText );
429 layerKeywordList.appendChild( layerKeywordValue );
431 layerNode.appendChild( layerKeywordList );
435 if ( !mDataUrl.isEmpty() )
437 QDomElement layerDataUrl = document.createElement( QStringLiteral(
"dataUrl" ) );
438 const QDomText layerDataUrlText = document.createTextNode( mDataUrl );
439 layerDataUrl.appendChild( layerDataUrlText );
440 layerDataUrl.setAttribute( QStringLiteral(
"format" ), mDataUrlFormat );
441 layerNode.appendChild( layerDataUrl );
445 if ( !mLegendUrl.isEmpty() )
447 QDomElement layerLegendUrl = document.createElement( QStringLiteral(
"legendUrl" ) );
448 const QDomText layerLegendUrlText = document.createTextNode( mLegendUrl );
449 layerLegendUrl.appendChild( layerLegendUrlText );
450 layerLegendUrl.setAttribute( QStringLiteral(
"format" ), mLegendUrlFormat );
451 layerNode.appendChild( layerLegendUrl );
455 if ( !mAttribution.isEmpty() )
457 QDomElement layerAttribution = document.createElement( QStringLiteral(
"attribution" ) );
458 const QDomText layerAttributionText = document.createTextNode( mAttribution );
459 layerAttribution.appendChild( layerAttributionText );
460 layerAttribution.setAttribute( QStringLiteral(
"href" ), mAttributionUrl );
461 layerNode.appendChild( layerAttribution );
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).
Manages QGIS Server properties for a map layer.
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.
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.
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.
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
bool operator==(const WmsDimensionInfo &other) const
@ MinValue
Add selection to current selection.
@ MaxValue
Modify current selection to include only select features which match.
@ AllValues
Display all values of the dimension.
@ ReferenceValue
Remove from current selection.