19#include "moc_qgsmaplayerserverproperties.cpp"
41 mMetadataUrls.clear();
46 QDomElement element = layer_node.namedItem( QStringLiteral(
"metadataUrls" ) ).toElement();
47 mMetadataUrls.clear();
48 const QDomNodeList el = element.elementsByTagName( QStringLiteral(
"metadataUrl" ) );
49 for (
int i = 0; i < el.size(); i++ )
51 element = el.at( i ).toElement();
53 oneUrl.
type = element.attribute( QStringLiteral(
"type" ) );
54 oneUrl.
format = element.attribute( QStringLiteral(
"format" ) );
55 oneUrl.
url = element.text();
62 QDomElement urls = document.createElement( QStringLiteral(
"metadataUrls" ) );
65 QDomElement urlElement = document.createElement( QStringLiteral(
"metadataUrl" ) );
66 urlElement.setAttribute( QStringLiteral(
"type" ), url.type );
67 urlElement.setAttribute( QStringLiteral(
"format" ), url.format );
68 urlElement.appendChild( document.createTextNode( url.url ) );
69 urls.appendChild( urlElement );
71 layer_node.appendChild( urls );
83 mWmsDimensions.clear();
88 mWmsDimensions = dimensions;
93 QMap<int, QString> labels;
105 if ( dim.name == wmsDimInfo.
name )
110 mWmsDimensions.append( wmsDimInfo );
116 for (
int i = 0; i < mWmsDimensions.size(); ++i )
118 if ( mWmsDimensions[ i ].name == wmsDimName )
120 mWmsDimensions.removeAt( i );
129 return mWmsDimensions;
142 const QDomNode wmsDimsNode = layer_node.namedItem( QStringLiteral(
"wmsDimensions" ) );
143 if ( wmsDimsNode.isNull() )
147 const QDomElement wmsDimsElem = wmsDimsNode.toElement();
148 const QDomNodeList wmsDimsList = wmsDimsElem.elementsByTagName( QStringLiteral(
"dimension" ) );
149 for (
int i = 0; i < wmsDimsList.size(); ++i )
151 const QDomElement dimElem = wmsDimsList.
at( i ).toElement();
152 const QString dimName = dimElem.attribute( QStringLiteral(
"name" ) );
153 const QString dimFieldName = dimElem.attribute( QStringLiteral(
"fieldName" ) );
155 const int dimFieldNameIndex = fields.
indexOf( dimFieldName );
156 if ( dimFieldNameIndex == -1 )
160 QVariant dimRefValue;
161 const int dimDefaultDisplayType = dimElem.attribute( QStringLiteral(
"defaultDisplayType" ) ).toInt();
164 const QString dimRefValueStr = dimElem.attribute( QStringLiteral(
"referenceValue" ) );
165 if ( !dimRefValueStr.isEmpty() )
167 const QgsField dimField = fields.
at( dimFieldNameIndex );
168 dimRefValue = QVariant( dimRefValueStr );
176 dimElem.attribute( QStringLiteral(
"endFieldName" ) ),
177 dimElem.attribute( QStringLiteral(
"units" ) ),
178 dimElem.attribute( QStringLiteral(
"unitSymbol" ) ),
179 dimDefaultDisplayType, dimRefValue );
183 mWmsDimensions.append( dim );
190 if ( ! mWmsDimensions.isEmpty() )
192 QDomElement wmsDimsElem = document.createElement( QStringLiteral(
"wmsDimensions" ) );
195 QDomElement dimElem = document.createElement( QStringLiteral(
"dimension" ) );
196 dimElem.setAttribute( QStringLiteral(
"name" ), dim.name );
197 dimElem.setAttribute( QStringLiteral(
"fieldName" ), dim.fieldName );
198 dimElem.setAttribute( QStringLiteral(
"endFieldName" ), dim.endFieldName );
199 dimElem.setAttribute( QStringLiteral(
"units" ), dim.units );
200 dimElem.setAttribute( QStringLiteral(
"unitSymbol" ), dim.unitSymbol );
201 dimElem.setAttribute( QStringLiteral(
"defaultDisplayType" ), dim.defaultDisplayType );
202 dimElem.setAttribute( QStringLiteral(
"referenceValue" ), dim.referenceValue.toString() );
203 wmsDimsElem.appendChild( dimElem );
205 layer_node.appendChild( wmsDimsElem );
247 const QDomElement metaUrlElem = layerNode.firstChildElement( QStringLiteral(
"metadataUrl" ) );
248 if ( !metaUrlElem.isNull() )
250 const QString url = metaUrlElem.text();
251 const QString type = metaUrlElem.attribute( QStringLiteral(
"type" ), QString() );
252 const QString format = metaUrlElem.attribute( QStringLiteral(
"format" ), QString() );
254 setMetadataUrls( QList<QgsMapLayerServerProperties::MetadataUrl>() << newItem );
261 const QDomElement shortNameElem = layerNode.firstChildElement( QStringLiteral(
"shortname" ) );
262 if ( !shortNameElem.isNull() )
264 mShortName = shortNameElem.text();
268 const QDomElement titleElem = layerNode.firstChildElement( QStringLiteral(
"title" ) );
269 if ( !titleElem.isNull() )
271 mTitle = titleElem.text();
272 mWfsTitle = titleElem.attribute( QStringLiteral(
"wfs" ) );
276 const QDomElement abstractElem = layerNode.firstChildElement( QStringLiteral(
"abstract" ) );
277 if ( !abstractElem.isNull() )
279 mAbstract = abstractElem.text();
283 const QDomElement keywordListElem = layerNode.firstChildElement( QStringLiteral(
"keywordList" ) );
284 if ( !keywordListElem.isNull() )
287 for ( QDomNode n = keywordListElem.firstChild(); !n.isNull(); n = n.nextSibling() )
289 kwdList << n.toElement().text();
291 mKeywordList = kwdList.join( QLatin1String(
", " ) );
295 const QDomElement dataUrlElem = layerNode.firstChildElement( QStringLiteral(
"dataUrl" ) );
296 if ( !dataUrlElem.isNull() )
298 mDataUrl = dataUrlElem.text();
299 mDataUrlFormat = dataUrlElem.attribute( QStringLiteral(
"format" ), QString() );
303 const QDomElement attribElem = layerNode.firstChildElement( QStringLiteral(
"attribution" ) );
304 if ( !attribElem.isNull() )
306 mAttribution = attribElem.text();
307 mAttributionUrl = attribElem.attribute( QStringLiteral(
"href" ), QString() );
311 const QDomElement legendUrlElem = layerNode.firstChildElement( QStringLiteral(
"legendUrl" ) );
312 if ( !legendUrlElem.isNull() )
314 mLegendUrl = legendUrlElem.text();
315 mLegendUrlFormat = legendUrlElem.attribute( QStringLiteral(
"format" ), QString() );
325 if ( !mShortName.isEmpty() )
327 QDomElement layerShortName = document.createElement( QStringLiteral(
"shortname" ) );
328 const QDomText layerShortNameText = document.createTextNode( mShortName );
329 layerShortName.appendChild( layerShortNameText );
330 layerNode.appendChild( layerShortName );
334 if ( !mTitle.isEmpty() )
336 QDomElement layerTitle = document.createElement( QStringLiteral(
"title" ) );
337 const QDomText layerTitleText = document.createTextNode( mTitle );
338 layerTitle.appendChild( layerTitleText );
340 if ( mTitle != mWfsTitle )
342 layerTitle.setAttribute(
"wfs", mWfsTitle );
345 layerNode.appendChild( layerTitle );
349 if ( !mAbstract.isEmpty() )
351 QDomElement layerAbstract = document.createElement( QStringLiteral(
"abstract" ) );
352 const QDomText layerAbstractText = document.createTextNode( mAbstract );
353 layerAbstract.appendChild( layerAbstractText );
354 layerNode.appendChild( layerAbstract );
358 const QStringList keywordStringList = mKeywordList.split(
',' );
359 if ( !keywordStringList.isEmpty() )
361 QDomElement layerKeywordList = document.createElement( QStringLiteral(
"keywordList" ) );
362 for (
int i = 0; i < keywordStringList.size(); ++i )
364 QDomElement layerKeywordValue = document.createElement( QStringLiteral(
"value" ) );
365 const QDomText layerKeywordText = document.createTextNode( keywordStringList.at( i ).trimmed() );
366 layerKeywordValue.appendChild( layerKeywordText );
367 layerKeywordList.appendChild( layerKeywordValue );
369 layerNode.appendChild( layerKeywordList );
373 if ( !mDataUrl.isEmpty() )
375 QDomElement layerDataUrl = document.createElement( QStringLiteral(
"dataUrl" ) );
376 const QDomText layerDataUrlText = document.createTextNode( mDataUrl );
377 layerDataUrl.appendChild( layerDataUrlText );
378 layerDataUrl.setAttribute( QStringLiteral(
"format" ), mDataUrlFormat );
379 layerNode.appendChild( layerDataUrl );
383 if ( !mLegendUrl.isEmpty() )
385 QDomElement layerLegendUrl = document.createElement( QStringLiteral(
"legendUrl" ) );
386 const QDomText layerLegendUrlText = document.createTextNode( mLegendUrl );
387 layerLegendUrl.appendChild( layerLegendUrlText );
388 layerLegendUrl.setAttribute( QStringLiteral(
"format" ), mLegendUrlFormat );
389 layerNode.appendChild( layerLegendUrl );
393 if ( !mAttribution.isEmpty() )
395 QDomElement layerAttribution = document.createElement( QStringLiteral(
"attribution" ) );
396 const QDomText layerAttributionText = document.createTextNode( mAttribution );
397 layerAttribution.appendChild( layerAttributionText );
398 layerAttribution.setAttribute( QStringLiteral(
"href" ), mAttributionUrl );
399 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.
QgsMapLayerServerProperties(QgsMapLayer *layer=nullptr)
Constructor - Creates a Map Layer QGIS Server Properties.
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 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 data sets.
Setting to define QGIS Server WMS Dimension.
@ 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.