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 if ( !mMetadataUrls.empty() )
64 QDomElement urls = document.createElement( QStringLiteral(
"metadataUrls" ) );
67 QDomElement urlElement = document.createElement( QStringLiteral(
"metadataUrl" ) );
68 urlElement.setAttribute( QStringLiteral(
"type" ), url.type );
69 urlElement.setAttribute( QStringLiteral(
"format" ), url.format );
70 urlElement.appendChild( document.createTextNode( url.url ) );
71 urls.appendChild( urlElement );
73 layer_node.appendChild( urls );
86 mWmsDimensions.clear();
91 mWmsDimensions = dimensions;
96 QMap<int, QString> labels;
108 if ( dim.name == wmsDimInfo.
name )
113 mWmsDimensions.append( wmsDimInfo );
119 for (
int i = 0; i < mWmsDimensions.size(); ++i )
121 if ( mWmsDimensions[ i ].name == wmsDimName )
123 mWmsDimensions.removeAt( i );
132 return mWmsDimensions;
145 const QDomNode wmsDimsNode = layer_node.namedItem( QStringLiteral(
"wmsDimensions" ) );
146 if ( wmsDimsNode.isNull() )
150 const QDomElement wmsDimsElem = wmsDimsNode.toElement();
151 const QDomNodeList wmsDimsList = wmsDimsElem.elementsByTagName( QStringLiteral(
"dimension" ) );
152 for (
int i = 0; i < wmsDimsList.size(); ++i )
154 const QDomElement dimElem = wmsDimsList.
at( i ).toElement();
155 const QString dimName = dimElem.attribute( QStringLiteral(
"name" ) );
156 const QString dimFieldName = dimElem.attribute( QStringLiteral(
"fieldName" ) );
158 const int dimFieldNameIndex = fields.
indexOf( dimFieldName );
159 if ( dimFieldNameIndex == -1 )
163 QVariant dimRefValue;
164 const int dimDefaultDisplayType = dimElem.attribute( QStringLiteral(
"defaultDisplayType" ) ).toInt();
167 const QString dimRefValueStr = dimElem.attribute( QStringLiteral(
"referenceValue" ) );
168 if ( !dimRefValueStr.isEmpty() )
170 const QgsField dimField = fields.
at( dimFieldNameIndex );
171 dimRefValue = QVariant( dimRefValueStr );
179 dimElem.attribute( QStringLiteral(
"endFieldName" ) ),
180 dimElem.attribute( QStringLiteral(
"units" ) ),
181 dimElem.attribute( QStringLiteral(
"unitSymbol" ) ),
182 dimDefaultDisplayType, dimRefValue );
186 mWmsDimensions.append( dim );
193 if ( ! mWmsDimensions.isEmpty() )
195 QDomElement wmsDimsElem = document.createElement( QStringLiteral(
"wmsDimensions" ) );
198 QDomElement dimElem = document.createElement( QStringLiteral(
"dimension" ) );
199 dimElem.setAttribute( QStringLiteral(
"name" ), dim.name );
200 dimElem.setAttribute( QStringLiteral(
"fieldName" ), dim.fieldName );
201 dimElem.setAttribute( QStringLiteral(
"endFieldName" ), dim.endFieldName );
202 dimElem.setAttribute( QStringLiteral(
"units" ), dim.units );
203 dimElem.setAttribute( QStringLiteral(
"unitSymbol" ), dim.unitSymbol );
204 dimElem.setAttribute( QStringLiteral(
"defaultDisplayType" ), dim.defaultDisplayType );
205 dimElem.setAttribute( QStringLiteral(
"referenceValue" ), dim.referenceValue.toString() );
206 wmsDimsElem.appendChild( dimElem );
208 layer_node.appendChild( wmsDimsElem );
250 const QDomElement metaUrlElem = layerNode.firstChildElement( QStringLiteral(
"metadataUrl" ) );
251 if ( !metaUrlElem.isNull() )
253 const QString url = metaUrlElem.text();
254 const QString type = metaUrlElem.attribute( QStringLiteral(
"type" ), QString() );
255 const QString format = metaUrlElem.attribute( QStringLiteral(
"format" ), QString() );
257 setMetadataUrls( QList<QgsMapLayerServerProperties::MetadataUrl>() << newItem );
264 const QDomElement shortNameElem = layerNode.firstChildElement( QStringLiteral(
"shortname" ) );
265 if ( !shortNameElem.isNull() )
267 mShortName = shortNameElem.text();
271 const QDomElement titleElem = layerNode.firstChildElement( QStringLiteral(
"title" ) );
272 if ( !titleElem.isNull() )
274 mTitle = titleElem.text();
275 mWfsTitle = titleElem.attribute( QStringLiteral(
"wfs" ) );
279 const QDomElement abstractElem = layerNode.firstChildElement( QStringLiteral(
"abstract" ) );
280 if ( !abstractElem.isNull() )
282 mAbstract = abstractElem.text();
286 const QDomElement keywordListElem = layerNode.firstChildElement( QStringLiteral(
"keywordList" ) );
287 if ( !keywordListElem.isNull() )
290 for ( QDomNode n = keywordListElem.firstChild(); !n.isNull(); n = n.nextSibling() )
292 const QString keyword = n.toElement().text();
293 if ( !keyword.isEmpty() )
296 mKeywordList = kwdList.join( QLatin1String(
", " ) );
300 const QDomElement dataUrlElem = layerNode.firstChildElement( QStringLiteral(
"dataUrl" ) );
301 if ( !dataUrlElem.isNull() )
303 mDataUrl = dataUrlElem.text();
304 mDataUrlFormat = dataUrlElem.attribute( QStringLiteral(
"format" ), QString() );
308 const QDomElement attribElem = layerNode.firstChildElement( QStringLiteral(
"attribution" ) );
309 if ( !attribElem.isNull() )
311 mAttribution = attribElem.text();
312 mAttributionUrl = attribElem.attribute( QStringLiteral(
"href" ), QString() );
316 const QDomElement legendUrlElem = layerNode.firstChildElement( QStringLiteral(
"legendUrl" ) );
317 if ( !legendUrlElem.isNull() )
319 mLegendUrl = legendUrlElem.text();
320 mLegendUrlFormat = legendUrlElem.attribute( QStringLiteral(
"format" ), QString() );
330 if ( !mShortName.isEmpty() )
332 QDomElement layerShortName = document.createElement( QStringLiteral(
"shortname" ) );
333 const QDomText layerShortNameText = document.createTextNode( mShortName );
334 layerShortName.appendChild( layerShortNameText );
335 layerNode.appendChild( layerShortName );
339 if ( !mTitle.isEmpty() )
341 QDomElement layerTitle = document.createElement( QStringLiteral(
"title" ) );
342 const QDomText layerTitleText = document.createTextNode( mTitle );
343 layerTitle.appendChild( layerTitleText );
345 if ( mTitle != mWfsTitle )
347 layerTitle.setAttribute(
"wfs", mWfsTitle );
350 layerNode.appendChild( layerTitle );
354 if ( !mAbstract.isEmpty() )
356 QDomElement layerAbstract = document.createElement( QStringLiteral(
"abstract" ) );
357 const QDomText layerAbstractText = document.createTextNode( mAbstract );
358 layerAbstract.appendChild( layerAbstractText );
359 layerNode.appendChild( layerAbstract );
363 const QStringList keywordStringList = mKeywordList.split(
',', Qt::SkipEmptyParts );
364 if ( !keywordStringList.isEmpty() )
366 QDomElement layerKeywordList = document.createElement( QStringLiteral(
"keywordList" ) );
367 for (
int i = 0; i < keywordStringList.size(); ++i )
369 QDomElement layerKeywordValue = document.createElement( QStringLiteral(
"value" ) );
370 const QDomText layerKeywordText = document.createTextNode( keywordStringList.at( i ).trimmed() );
371 layerKeywordValue.appendChild( layerKeywordText );
372 layerKeywordList.appendChild( layerKeywordValue );
374 layerNode.appendChild( layerKeywordList );
378 if ( !mDataUrl.isEmpty() )
380 QDomElement layerDataUrl = document.createElement( QStringLiteral(
"dataUrl" ) );
381 const QDomText layerDataUrlText = document.createTextNode( mDataUrl );
382 layerDataUrl.appendChild( layerDataUrlText );
383 layerDataUrl.setAttribute( QStringLiteral(
"format" ), mDataUrlFormat );
384 layerNode.appendChild( layerDataUrl );
388 if ( !mLegendUrl.isEmpty() )
390 QDomElement layerLegendUrl = document.createElement( QStringLiteral(
"legendUrl" ) );
391 const QDomText layerLegendUrlText = document.createTextNode( mLegendUrl );
392 layerLegendUrl.appendChild( layerLegendUrlText );
393 layerLegendUrl.setAttribute( QStringLiteral(
"format" ), mLegendUrlFormat );
394 layerNode.appendChild( layerLegendUrl );
398 if ( !mAttribution.isEmpty() )
400 QDomElement layerAttribution = document.createElement( QStringLiteral(
"attribution" ) );
401 const QDomText layerAttributionText = document.createTextNode( mAttribution );
402 layerAttribution.appendChild( layerAttributionText );
403 layerAttribution.setAttribute( QStringLiteral(
"href" ), mAttributionUrl );
404 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 dataset.
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.