25#include "moc_qgsmaplayerserverproperties.cpp"
38 return mMetadataUrls == other.mMetadataUrls;
43 return !( *
this == other );
59 return !( *
this == other );
69 mMetadataUrls.clear();
74 QDomElement element = layer_node.namedItem( QStringLiteral(
"metadataUrls" ) ).toElement();
75 mMetadataUrls.clear();
76 const QDomNodeList el = element.elementsByTagName( QStringLiteral(
"metadataUrl" ) );
77 for (
int i = 0; i < el.size(); i++ )
79 element = el.at( i ).toElement();
81 oneUrl.
type = element.attribute( QStringLiteral(
"type" ) );
82 oneUrl.
format = element.attribute( QStringLiteral(
"format" ) );
83 oneUrl.
url = element.text();
90 if ( !mMetadataUrls.empty() )
92 QDomElement urls = document.createElement( QStringLiteral(
"metadataUrls" ) );
95 QDomElement urlElement = document.createElement( QStringLiteral(
"metadataUrl" ) );
96 urlElement.setAttribute( QStringLiteral(
"type" ), url.type );
97 urlElement.setAttribute( QStringLiteral(
"format" ), url.format );
98 urlElement.appendChild( document.createTextNode( url.url ) );
99 urls.appendChild( urlElement );
101 layer_node.appendChild( urls );
109 return mWmsDimensions == other.mWmsDimensions;
114 return !( *
this == other );
124 mWmsDimensions.clear();
129 mWmsDimensions = dimensions;
134 QMap<int, QString> labels;
146 if ( dim.name == wmsDimInfo.
name )
151 mWmsDimensions.append( wmsDimInfo );
157 for (
int i = 0; i < mWmsDimensions.size(); ++i )
159 if ( mWmsDimensions[ i ].name == wmsDimName )
161 mWmsDimensions.removeAt( i );
170 return mWmsDimensions;
183 const QDomNode wmsDimsNode = layer_node.namedItem( QStringLiteral(
"wmsDimensions" ) );
184 if ( wmsDimsNode.isNull() )
188 const QDomElement wmsDimsElem = wmsDimsNode.toElement();
189 const QDomNodeList wmsDimsList = wmsDimsElem.elementsByTagName( QStringLiteral(
"dimension" ) );
190 for (
int i = 0; i < wmsDimsList.size(); ++i )
192 const QDomElement dimElem = wmsDimsList.at( i ).toElement();
193 const QString dimName = dimElem.attribute( QStringLiteral(
"name" ) );
194 const QString dimFieldName = dimElem.attribute( QStringLiteral(
"fieldName" ) );
196 const int dimFieldNameIndex = fields.
indexOf( dimFieldName );
197 if ( dimFieldNameIndex == -1 )
201 QVariant dimRefValue;
202 const int dimDefaultDisplayType = dimElem.attribute( QStringLiteral(
"defaultDisplayType" ) ).toInt();
205 const QString dimRefValueStr = dimElem.attribute( QStringLiteral(
"referenceValue" ) );
206 if ( !dimRefValueStr.isEmpty() )
208 const QgsField dimField = fields.
at( dimFieldNameIndex );
209 dimRefValue = QVariant( dimRefValueStr );
217 dimElem.attribute( QStringLiteral(
"endFieldName" ) ),
218 dimElem.attribute( QStringLiteral(
"units" ) ),
219 dimElem.attribute( QStringLiteral(
"unitSymbol" ) ),
220 dimDefaultDisplayType, dimRefValue );
224 mWmsDimensions.append( dim );
231 if ( ! mWmsDimensions.isEmpty() )
233 QDomElement wmsDimsElem = document.createElement( QStringLiteral(
"wmsDimensions" ) );
236 QDomElement dimElem = document.createElement( QStringLiteral(
"dimension" ) );
237 dimElem.setAttribute( QStringLiteral(
"name" ), dim.name );
238 dimElem.setAttribute( QStringLiteral(
"fieldName" ), dim.fieldName );
239 dimElem.setAttribute( QStringLiteral(
"endFieldName" ), dim.endFieldName );
240 dimElem.setAttribute( QStringLiteral(
"units" ), dim.units );
241 dimElem.setAttribute( QStringLiteral(
"unitSymbol" ), dim.unitSymbol );
242 dimElem.setAttribute( QStringLiteral(
"defaultDisplayType" ), dim.defaultDisplayType );
243 dimElem.setAttribute( QStringLiteral(
"referenceValue" ), dim.referenceValue.toString() );
244 wmsDimsElem.appendChild( dimElem );
246 layer_node.appendChild( wmsDimsElem );
279 && mShortName == other.mShortName
280 && mTitle == other.mTitle
281 && mAbstract == other.mAbstract
282 && mKeywordList == other.mKeywordList
283 && mDataUrl == other.mDataUrl
284 && mDataUrlFormat == other.mDataUrlFormat
285 && mAttribution == other.mAttribution
286 && mAttributionUrl == other.mAttributionUrl
287 && mLegendUrl == other.mLegendUrl
288 && mLegendUrlFormat == other.mLegendUrlFormat;
293 return !( *
this == other );
304 QString name = mLayer ? mLayer->name() : QString();
305 if ( !mShortName.isEmpty() )
308 name.replace(
' ',
'_' ).replace(
':',
'-' ).replace( QChar( 0x2014 ) ,
'-' );
310 return name.toLocal8Bit();
320 const QDomElement metaUrlElem = layerNode.firstChildElement( QStringLiteral(
"metadataUrl" ) );
321 if ( !metaUrlElem.isNull() )
323 const QString url = metaUrlElem.text();
324 const QString type = metaUrlElem.attribute( QStringLiteral(
"type" ), QString() );
325 const QString format = metaUrlElem.attribute( QStringLiteral(
"format" ), QString() );
327 setMetadataUrls( QList<QgsMapLayerServerProperties::MetadataUrl>() << newItem );
334 const QDomElement shortNameElem = layerNode.firstChildElement( QStringLiteral(
"shortname" ) );
335 if ( !shortNameElem.isNull() )
337 mShortName = shortNameElem.text();
341 const QDomElement titleElem = layerNode.firstChildElement( QStringLiteral(
"title" ) );
342 if ( !titleElem.isNull() )
344 mTitle = titleElem.text();
345 mWfsTitle = titleElem.attribute( QStringLiteral(
"wfs" ) );
349 const QDomElement abstractElem = layerNode.firstChildElement( QStringLiteral(
"abstract" ) );
350 if ( !abstractElem.isNull() )
352 mAbstract = abstractElem.text();
356 const QDomElement keywordListElem = layerNode.firstChildElement( QStringLiteral(
"keywordList" ) );
357 if ( !keywordListElem.isNull() )
360 for ( QDomNode n = keywordListElem.firstChild(); !n.isNull(); n = n.nextSibling() )
362 const QString keyword = n.toElement().text();
363 if ( !keyword.isEmpty() )
366 mKeywordList = kwdList.join( QLatin1String(
", " ) );
370 const QDomElement dataUrlElem = layerNode.firstChildElement( QStringLiteral(
"dataUrl" ) );
371 if ( !dataUrlElem.isNull() )
373 mDataUrl = dataUrlElem.text();
374 mDataUrlFormat = dataUrlElem.attribute( QStringLiteral(
"format" ), QString() );
378 const QDomElement attribElem = layerNode.firstChildElement( QStringLiteral(
"attribution" ) );
379 if ( !attribElem.isNull() )
381 mAttribution = attribElem.text();
382 mAttributionUrl = attribElem.attribute( QStringLiteral(
"href" ), QString() );
386 const QDomElement legendUrlElem = layerNode.firstChildElement( QStringLiteral(
"legendUrl" ) );
387 if ( !legendUrlElem.isNull() )
389 mLegendUrl = legendUrlElem.text();
390 mLegendUrlFormat = legendUrlElem.attribute( QStringLiteral(
"format" ), QString() );
400 if ( !mShortName.isEmpty() )
402 QDomElement layerShortName = document.createElement( QStringLiteral(
"shortname" ) );
403 const QDomText layerShortNameText = document.createTextNode( mShortName );
404 layerShortName.appendChild( layerShortNameText );
405 layerNode.appendChild( layerShortName );
409 if ( !mTitle.isEmpty() )
411 QDomElement layerTitle = document.createElement( QStringLiteral(
"title" ) );
412 const QDomText layerTitleText = document.createTextNode( mTitle );
413 layerTitle.appendChild( layerTitleText );
415 if ( mTitle != mWfsTitle )
417 layerTitle.setAttribute(
"wfs", mWfsTitle );
420 layerNode.appendChild( layerTitle );
424 if ( !mAbstract.isEmpty() )
426 QDomElement layerAbstract = document.createElement( QStringLiteral(
"abstract" ) );
427 const QDomText layerAbstractText = document.createTextNode( mAbstract );
428 layerAbstract.appendChild( layerAbstractText );
429 layerNode.appendChild( layerAbstract );
433 const QStringList keywordStringList = mKeywordList.split(
',', Qt::SkipEmptyParts );
434 if ( !keywordStringList.isEmpty() )
436 QDomElement layerKeywordList = document.createElement( QStringLiteral(
"keywordList" ) );
437 for (
int i = 0; i < keywordStringList.size(); ++i )
439 QDomElement layerKeywordValue = document.createElement( QStringLiteral(
"value" ) );
440 const QDomText layerKeywordText = document.createTextNode( keywordStringList.at( i ).trimmed() );
441 layerKeywordValue.appendChild( layerKeywordText );
442 layerKeywordList.appendChild( layerKeywordValue );
444 layerNode.appendChild( layerKeywordList );
448 if ( !mDataUrl.isEmpty() )
450 QDomElement layerDataUrl = document.createElement( QStringLiteral(
"dataUrl" ) );
451 const QDomText layerDataUrlText = document.createTextNode( mDataUrl );
452 layerDataUrl.appendChild( layerDataUrlText );
453 layerDataUrl.setAttribute( QStringLiteral(
"format" ), mDataUrlFormat );
454 layerNode.appendChild( layerDataUrl );
458 if ( !mLegendUrl.isEmpty() )
460 QDomElement layerLegendUrl = document.createElement( QStringLiteral(
"legendUrl" ) );
461 const QDomText layerLegendUrlText = document.createTextNode( mLegendUrl );
462 layerLegendUrl.appendChild( layerLegendUrlText );
463 layerLegendUrl.setAttribute( QStringLiteral(
"format" ), mLegendUrlFormat );
464 layerNode.appendChild( layerLegendUrl );
468 if ( !mAttribution.isEmpty() )
470 QDomElement layerAttribution = document.createElement( QStringLiteral(
"attribution" ) );
471 const QDomText layerAttributionText = document.createTextNode( mAttribution );
472 layerAttribution.appendChild( layerAttributionText );
473 layerAttribution.setAttribute( QStringLiteral(
"href" ), mAttributionUrl );
474 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).
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.
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
WmsDimensionInfo(const QString &dimName, const QString &dimFieldName, const QString &dimEndFieldName=QString(), const QString &dimUnits=QString(), const QString &dimUnitSymbol=QString(), const int &dimDefaultDisplayType=QgsServerWmsDimensionProperties::WmsDimensionInfo::AllValues, const QVariant &dimReferenceValue=QVariant())
Constructor for WmsDimensionInfo.
@ 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.