45using namespace Qt::StringLiterals;
51 QString dateToString(
const QDateTime &dateTime,
bool forceToDate );
53 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem, QgsMapLayer *currentLayer );
55 void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem, QgsServerInterface *serverIface,
const QgsProject *project );
57 void appendLayerWgs84BoundingRect( QDomDocument &doc, QDomElement &layerElement,
const QgsRectangle &wgs84BoundingRect );
59 void appendLayerCrsExtents( QDomDocument &doc, QDomElement &layerElement,
const QMap<QString, QgsRectangle> &crsExtents );
61 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
const QString &crsText );
63 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
const QStringList &crsList,
const QStringList &constrainedCrsList,
bool hasEarthCrs =
true );
65 void appendLayerStyles( QDomDocument &doc, QDomElement &layerElem,
const QgsWmsLayerInfos &layerInfos,
const QgsProject *project,
const QgsWmsRequest &request,
const QgsServerSettings *settings );
67 void appendLayersFromTreeGroup(
69 QDomElement &parentLayer,
70 QgsServerInterface *serverIface,
71 const QgsProject *project,
73 const QgsLayerTreeGroup *layerTreeGroup,
74 const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos,
78 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent );
84#ifdef HAVE_SERVER_PYTHON_PLUGINS
89 const QDomDocument *capabilitiesDocument =
nullptr;
94 QStringList cacheKeyList;
95 cacheKeyList << ( projectSettings ? u
"projectSettings"_s : request.
wmsParameters().version() );
99#ifdef HAVE_SERVER_PYTHON_PLUGINS
103 QString
cacheKey = cacheKeyList.join(
'-' );
105#ifdef HAVE_SERVER_PYTHON_PLUGINS
107 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
109 capabilitiesDocument = &doc;
112 if ( !capabilitiesDocument && cache )
117 if ( !capabilitiesDocument )
121 doc =
getCapabilities( serverIface, project, request, projectSettings );
123#ifdef HAVE_SERVER_PYTHON_PLUGINS
124 if ( cacheManager && cacheManager->
setCachedDocument( &doc, project, request, accessControl ) )
126 capabilitiesDocument = &doc;
131 if ( !capabilitiesDocument )
136 if ( !capabilitiesDocument )
138 capabilitiesDocument = &doc;
150 response.
setHeader( u
"Content-Type"_s, u
"text/xml; charset=utf-8"_s );
151 response.
write( capabilitiesDocument->toByteArray() );
157 QDomElement wmsCapabilitiesElement;
163 QString hrefString = href.toString();
164 hrefString.append( href.hasQuery() ?
"&" :
"?" );
167 QDomProcessingInstruction xmlDeclaration = doc.createProcessingInstruction( u
"xml"_s, u
"version=\"1.0\" encoding=\"utf-8\""_s );
170 std::function<void( QDomElement &,
const QString & )> appendFormat = [&doc]( QDomElement &elem,
const QString &format ) {
171 QDomElement formatElem = doc.createElement( u
"Format"_s );
172 formatElem.appendChild( doc.createTextNode( format ) );
173 elem.appendChild( formatElem );
179 u
"WMT_MS_Capabilities SYSTEM 'http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd'"_s
181 doc.appendChild( xmlDeclaration );
182 wmsCapabilitiesElement = doc.createElement( u
"WMT_MS_Capabilities"_s );
186 doc.appendChild( xmlDeclaration );
187 wmsCapabilitiesElement = doc.createElement( u
"WMS_Capabilities"_s );
188 wmsCapabilitiesElement.setAttribute( u
"xmlns"_s, u
"http://www.opengis.net/wms"_s );
189 wmsCapabilitiesElement.setAttribute( u
"xmlns:sld"_s, u
"http://www.opengis.net/sld"_s );
190 wmsCapabilitiesElement.setAttribute( u
"xmlns:qgs"_s, u
"http://www.qgis.org/wms"_s );
191 wmsCapabilitiesElement.setAttribute( u
"xmlns:xsi"_s, u
"http://www.w3.org/2001/XMLSchema-instance"_s );
192 QString schemaLocation = u
"http://www.opengis.net/wms"_s;
193 schemaLocation +=
" http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd"_L1;
194 schemaLocation +=
" http://www.opengis.net/sld"_L1;
195 schemaLocation +=
" http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd"_L1;
199 wmsCapabilitiesElement.setAttribute( u
"xmlns:inspire_common"_s, u
"http://inspire.ec.europa.eu/schemas/common/1.0"_s );
200 wmsCapabilitiesElement.setAttribute( u
"xmlns:inspire_vs"_s, u
"http://inspire.ec.europa.eu/schemas/inspire_vs/1.0"_s );
201 schemaLocation +=
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0"_L1;
202 schemaLocation +=
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0/inspire_vs.xsd"_L1;
205 schemaLocation +=
" http://www.qgis.org/wms"_L1;
206 schemaLocation +=
" " + hrefString +
"SERVICE=WMS&REQUEST=GetSchemaExtension";
208 wmsCapabilitiesElement.setAttribute( u
"xsi:schemaLocation"_s, schemaLocation );
211 doc.appendChild( wmsCapabilitiesElement );
217 QDomElement capabilityElement =
getCapabilityElement( doc, project, request, projectSettings, serverIface );
218 wmsCapabilitiesElement.appendChild( capabilityElement );
220 if ( projectSettings )
231 if ( projectSettings )
233 appendDrawingOrder( doc, capabilityElement, serverIface, project );
242 QDomElement serviceElem = doc.createElement( u
"Service"_s );
245 QDomElement nameElem = doc.createElement( u
"Name"_s );
246 QDomText nameText = doc.createTextNode( u
"WMS"_s );
247 nameElem.appendChild( nameText );
248 serviceElem.appendChild( nameElem );
251 QDomElement titleElem = doc.createElement( u
"Title"_s );
253 titleElem.appendChild( titleText );
254 serviceElem.appendChild( titleElem );
257 if ( !abstract.isEmpty() )
259 QDomElement abstractElem = doc.createElement( u
"Abstract"_s );
260 QDomText abstractText = doc.createCDATASection( abstract );
261 abstractElem.appendChild( abstractText );
262 serviceElem.appendChild( abstractElem );
265 addKeywordListElement( project, doc, serviceElem );
268 if ( onlineResource.isEmpty() )
270 onlineResource =
serviceUrl( request, project, *serverSettings ).toString();
272 QDomElement onlineResourceElem = doc.createElement( u
"OnlineResource"_s );
273 onlineResourceElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
274 onlineResourceElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
275 onlineResourceElem.setAttribute( u
"xlink:href"_s, onlineResource );
276 serviceElem.appendChild( onlineResourceElem );
283 if ( !contactPerson.isEmpty() || !contactOrganization.isEmpty() || !contactPosition.isEmpty() || !contactMail.isEmpty() || !contactPhone.isEmpty() )
286 QDomElement contactInfoElem = doc.createElement( u
"ContactInformation"_s );
289 if ( !contactPerson.isEmpty() || !contactOrganization.isEmpty() )
291 QDomElement contactPersonPrimaryElem = doc.createElement( u
"ContactPersonPrimary"_s );
293 QDomText contactPersonText;
294 if ( !contactPerson.isEmpty() )
296 contactPersonText = doc.createTextNode( contactPerson );
300 contactPersonText = doc.createTextNode( u
"unknown"_s );
302 QDomElement contactPersonElem = doc.createElement( u
"ContactPerson"_s );
303 contactPersonElem.appendChild( contactPersonText );
304 contactPersonPrimaryElem.appendChild( contactPersonElem );
306 QDomText contactOrganizationText;
307 if ( !contactOrganization.isEmpty() )
309 contactOrganizationText = doc.createTextNode( contactOrganization );
313 contactOrganizationText = doc.createTextNode( u
"unknown"_s );
315 QDomElement contactOrganizationElem = doc.createElement( u
"ContactOrganization"_s );
316 contactOrganizationElem.appendChild( contactOrganizationText );
317 contactPersonPrimaryElem.appendChild( contactOrganizationElem );
319 contactInfoElem.appendChild( contactPersonPrimaryElem );
322 if ( !contactPosition.isEmpty() )
324 QDomElement contactPositionElem = doc.createElement( u
"ContactPosition"_s );
325 QDomText contactPositionText = doc.createTextNode( contactPosition );
326 contactPositionElem.appendChild( contactPositionText );
327 contactInfoElem.appendChild( contactPositionElem );
330 if ( !contactPhone.isEmpty() )
332 QDomElement phoneElem = doc.createElement( u
"ContactVoiceTelephone"_s );
333 QDomText phoneText = doc.createTextNode( contactPhone );
334 phoneElem.appendChild( phoneText );
335 contactInfoElem.appendChild( phoneElem );
338 if ( !contactMail.isEmpty() )
340 QDomElement mailElem = doc.createElement( u
"ContactElectronicMailAddress"_s );
341 QDomText mailText = doc.createTextNode( contactMail );
342 mailElem.appendChild( mailText );
343 contactInfoElem.appendChild( mailElem );
346 serviceElem.appendChild( contactInfoElem );
349 QDomElement feesElem = doc.createElement( u
"Fees"_s );
350 QDomText feesText = doc.createTextNode( u
"None"_s );
352 if ( !fees.isEmpty() )
354 feesText = doc.createTextNode( fees );
356 feesElem.appendChild( feesText );
357 serviceElem.appendChild( feesElem );
359 QDomElement accessConstraintsElem = doc.createElement( u
"AccessConstraints"_s );
360 QDomText accessConstraintsText = doc.createTextNode( u
"None"_s );
362 if ( !accessConstraints.isEmpty() )
364 accessConstraintsText = doc.createTextNode( accessConstraints );
366 accessConstraintsElem.appendChild( accessConstraintsText );
367 serviceElem.appendChild( accessConstraintsElem );
374 QDomElement maxWidthElem = doc.createElement( u
"MaxWidth"_s );
375 QDomText maxWidthText = doc.createTextNode( QString::number( maxWidth ) );
376 maxWidthElem.appendChild( maxWidthText );
377 serviceElem.appendChild( maxWidthElem );
383 QDomElement maxHeightElem = doc.createElement( u
"MaxHeight"_s );
384 QDomText maxHeightText = doc.createTextNode( QString::number( maxHeight ) );
385 maxHeightElem.appendChild( maxHeightText );
386 serviceElem.appendChild( maxHeightElem );
401 QString hrefString = href.toString();
402 hrefString.append( href.hasQuery() ?
"&" :
"?" );
404 QDomElement capabilityElem = doc.createElement( u
"Capability"_s );
407 QDomElement requestElem = doc.createElement( u
"Request"_s );
408 capabilityElem.appendChild( requestElem );
410 QDomElement dcpTypeElem = doc.createElement( u
"DCPType"_s );
411 QDomElement httpElem = doc.createElement( u
"HTTP"_s );
412 dcpTypeElem.appendChild( httpElem );
415 std::function<void( QDomElement &,
const QString & )> appendFormat = [&doc]( QDomElement &elem,
const QString &format ) {
416 QDomElement formatElem = doc.createElement( u
"Format"_s );
417 formatElem.appendChild( doc.createTextNode( format ) );
418 elem.appendChild( formatElem );
424 elem = doc.createElement( u
"GetCapabilities"_s );
425 appendFormat( elem, ( version ==
"1.1.1"_L1 ?
"application/vnd.ogc.wms_xml" :
"text/xml" ) );
426 elem.appendChild( dcpTypeElem );
427 requestElem.appendChild( elem );
430 QDomElement getElem = doc.createElement( u
"Get"_s );
431 httpElem.appendChild( getElem );
432 QDomElement olResourceElem = doc.createElement( u
"OnlineResource"_s );
433 olResourceElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
434 olResourceElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
435 olResourceElem.setAttribute( u
"xlink:href"_s, hrefString );
436 getElem.appendChild( olResourceElem );
439 elem = doc.createElement( u
"GetMap"_s );
440 appendFormat( elem, u
"image/png"_s );
441 appendFormat( elem, u
"image/png; mode=16bit"_s );
442 appendFormat( elem, u
"image/png; mode=8bit"_s );
443 appendFormat( elem, u
"image/png; mode=1bit"_s );
444 appendFormat( elem, u
"image/jpeg"_s );
445 appendFormat( elem, u
"application/dxf"_s );
446 appendFormat( elem, u
"application/pdf"_s );
447 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
448 requestElem.appendChild( elem );
451 elem = doc.createElement( u
"GetFeatureInfo"_s );
452 appendFormat( elem, u
"text/plain"_s );
453 appendFormat( elem, u
"text/html"_s );
454 appendFormat( elem, u
"text/xml"_s );
455 appendFormat( elem, u
"application/vnd.ogc.gml"_s );
456 appendFormat( elem, u
"application/vnd.ogc.gml/3.1.1"_s );
457 appendFormat( elem, u
"application/json"_s );
458 appendFormat( elem, u
"application/geo+json"_s );
459 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
460 requestElem.appendChild( elem );
463 elem = doc.createElement( ( version ==
"1.1.1"_L1 ?
"GetLegendGraphic" :
"sld:GetLegendGraphic" ) );
464 appendFormat( elem, u
"image/jpeg"_s );
465 appendFormat( elem, u
"image/png"_s );
466 appendFormat( elem, u
"application/json"_s );
467 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
468 requestElem.appendChild( elem );
471 elem = doc.createElement( ( version ==
"1.1.1"_L1 ?
"DescribeLayer" :
"sld:DescribeLayer" ) );
472 appendFormat( elem, u
"text/xml"_s );
473 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
474 requestElem.appendChild( elem );
477 elem = doc.createElement( ( version ==
"1.1.1"_L1 ?
"GetStyles" :
"qgs:GetStyles" ) );
478 appendFormat( elem, u
"text/xml"_s );
479 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
480 requestElem.appendChild( elem );
485 elem = doc.createElement( u
"GetPrint"_s );
486 appendFormat( elem, u
"svg"_s );
487 appendFormat( elem, u
"png"_s );
488 appendFormat( elem, u
"pdf"_s );
489 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
490 requestElem.appendChild( elem );
494 elem = doc.createElement( u
"Exception"_s );
495 appendFormat( elem, ( version ==
"1.1.1"_L1 ?
"application/vnd.ogc.se_xml" :
"XML" ) );
496 capabilityElem.appendChild( elem );
499 if ( version ==
"1.3.0"_L1 )
501 elem = doc.createElement( u
"sld:UserDefinedSymbolization"_s );
502 elem.setAttribute( u
"SupportSLD"_s, u
"1"_s );
503 elem.setAttribute( u
"UserLayer"_s, u
"0"_s );
504 elem.setAttribute( u
"UserStyle"_s, u
"1"_s );
505 elem.setAttribute( u
"RemoteWFS"_s, u
"0"_s );
506 elem.setAttribute( u
"InlineFeature"_s, u
"0"_s );
507 elem.setAttribute( u
"RemoteWCS"_s, u
"0"_s );
508 capabilityElem.appendChild( elem );
516 return capabilityElem;
521 QDomElement inspireCapabilitiesElem;
524 return inspireCapabilitiesElem;
526 inspireCapabilitiesElem = doc.createElement( u
"inspire_vs:ExtendedCapabilities"_s );
530 if ( !inspireMetadataUrl.isEmpty() )
532 QDomElement inspireCommonMetadataUrlElem = doc.createElement( u
"inspire_common:MetadataUrl"_s );
533 inspireCommonMetadataUrlElem.setAttribute( u
"xsi:type"_s, u
"inspire_common:resourceLocatorType"_s );
535 QDomElement inspireCommonMetadataUrlUrlElem = doc.createElement( u
"inspire_common:URL"_s );
536 inspireCommonMetadataUrlUrlElem.appendChild( doc.createTextNode( inspireMetadataUrl ) );
537 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlUrlElem );
540 if ( !inspireMetadataUrlType.isNull() )
542 QDomElement inspireCommonMetadataUrlMediaTypeElem = doc.createElement( u
"inspire_common:MediaType"_s );
543 inspireCommonMetadataUrlMediaTypeElem.appendChild( doc.createTextNode( inspireMetadataUrlType ) );
544 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlMediaTypeElem );
547 inspireCapabilitiesElem.appendChild( inspireCommonMetadataUrlElem );
551 QDomElement inspireCommonResourceTypeElem = doc.createElement( u
"inspire_common:ResourceType"_s );
552 inspireCommonResourceTypeElem.appendChild( doc.createTextNode( u
"service"_s ) );
553 inspireCapabilitiesElem.appendChild( inspireCommonResourceTypeElem );
555 QDomElement inspireCommonSpatialDataServiceTypeElem = doc.createElement( u
"inspire_common:SpatialDataServiceType"_s );
556 inspireCommonSpatialDataServiceTypeElem.appendChild( doc.createTextNode( u
"view"_s ) );
557 inspireCapabilitiesElem.appendChild( inspireCommonSpatialDataServiceTypeElem );
560 if ( !inspireTemporalReference.isNull() )
562 QDomElement inspireCommonTemporalReferenceElem = doc.createElement( u
"inspire_common:TemporalReference"_s );
563 QDomElement inspireCommonDateOfLastRevisionElem = doc.createElement( u
"inspire_common:DateOfLastRevision"_s );
564 inspireCommonDateOfLastRevisionElem.appendChild( doc.createTextNode( inspireTemporalReference ) );
565 inspireCommonTemporalReferenceElem.appendChild( inspireCommonDateOfLastRevisionElem );
566 inspireCapabilitiesElem.appendChild( inspireCommonTemporalReferenceElem );
569 QDomElement inspireCommonMetadataPointOfContactElem = doc.createElement( u
"inspire_common:MetadataPointOfContact"_s );
572 QDomElement inspireCommonOrganisationNameElem = doc.createElement( u
"inspire_common:OrganisationName"_s );
573 if ( !contactOrganization.isNull() )
575 inspireCommonOrganisationNameElem.appendChild( doc.createTextNode( contactOrganization ) );
577 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonOrganisationNameElem );
580 QDomElement inspireCommonEmailAddressElem = doc.createElement( u
"inspire_common:EmailAddress"_s );
581 if ( !contactMail.isNull() )
583 inspireCommonEmailAddressElem.appendChild( doc.createTextNode( contactMail ) );
585 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonEmailAddressElem );
587 inspireCapabilitiesElem.appendChild( inspireCommonMetadataPointOfContactElem );
590 if ( !inspireMetadataDate.isNull() )
592 QDomElement inspireCommonMetadataDateElem = doc.createElement( u
"inspire_common:MetadataDate"_s );
593 inspireCommonMetadataDateElem.appendChild( doc.createTextNode( inspireMetadataDate ) );
594 inspireCapabilitiesElem.appendChild( inspireCommonMetadataDateElem );
599 QDomElement inspireCommonSupportedLanguagesElem = doc.createElement( u
"inspire_common:SupportedLanguages"_s );
600 inspireCommonSupportedLanguagesElem.setAttribute( u
"xsi:type"_s, u
"inspire_common:supportedLanguagesType"_s );
602 QDomElement inspireCommonLanguageElem = doc.createElement( u
"inspire_common:Language"_s );
605 QDomElement inspireCommonDefaultLanguageElem = doc.createElement( u
"inspire_common:DefaultLanguage"_s );
606 inspireCommonDefaultLanguageElem.appendChild( inspireCommonLanguageElem );
607 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonDefaultLanguageElem );
611 QDomElement inspireCommonSupportedLanguageElem = doc.createElement(
"inspire_common:SupportedLanguage" );
612 inspireCommonSupportedLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
613 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonSupportedLanguageElem );
616 inspireCapabilitiesElem.appendChild( inspireCommonSupportedLanguagesElem );
618 QDomElement inspireCommonResponseLanguageElem = doc.createElement( u
"inspire_common:ResponseLanguage"_s );
619 inspireCommonResponseLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
620 inspireCapabilitiesElem.appendChild( inspireCommonResponseLanguageElem );
622 return inspireCapabilitiesElem;
628 if ( projectComposers.size() == 0 )
629 return QDomElement();
633 QDomElement composerTemplatesElem = doc.createElement( u
"ComposerTemplates"_s );
634 QList<QgsPrintLayout *>::const_iterator cIt = projectComposers.constBegin();
635 for ( ; cIt != projectComposers.constEnd(); ++cIt )
638 if ( restrictedComposers.contains( layout->
name() ) )
650 QDomElement composerTemplateElem = doc.createElement( u
"ComposerTemplate"_s );
651 composerTemplateElem.setAttribute( u
"name"_s, layout->
name() );
654 composerTemplateElem.setAttribute( u
"width"_s, width.
length() );
655 composerTemplateElem.setAttribute( u
"height"_s, height.
length() );
659 if ( atlas && atlas->
enabled() )
661 composerTemplateElem.setAttribute( u
"atlasEnabled"_s, u
"1"_s );
668 layerName = cLayer->
id();
670 else if ( layerName.isEmpty() )
672 layerName = cLayer->
name();
674 composerTemplateElem.setAttribute( u
"atlasCoverageLayer"_s, layerName );
679 QList<QgsLayoutItemMap *> layoutMapList;
681 QList<QgsLayoutItemMap *>::const_iterator cmIt = layoutMapList.constBegin();
684 for ( ; cmIt != layoutMapList.constEnd(); ++cmIt )
688 QDomElement composerMapElem = doc.createElement( u
"ComposerMap"_s );
689 composerMapElem.setAttribute( u
"name"_s, u
"map%1"_s.arg( mapId ) );
690 composerMapElem.setAttribute( u
"itemName"_s, composerMap->
displayName() );
692 composerMapElem.setAttribute( u
"width"_s, composerMap->rect().width() );
693 composerMapElem.setAttribute( u
"height"_s, composerMap->rect().height() );
694 composerTemplateElem.appendChild( composerMapElem );
698 QList<QgsLayoutItemLabel *> composerLabelList;
700 QList<QgsLayoutItemLabel *>::const_iterator clIt = composerLabelList.constBegin();
701 for ( ; clIt != composerLabelList.constEnd(); ++clIt )
704 QString
id = composerLabel->
id();
708 QDomElement composerLabelElem = doc.createElement( u
"ComposerLabel"_s );
709 composerLabelElem.setAttribute( u
"name"_s,
id );
710 composerTemplateElem.appendChild( composerLabelElem );
714 QList<QgsLayoutItemHtml *> composerHtmlList;
716 QList<QgsLayoutItemHtml *>::const_iterator chIt = composerHtmlList.constBegin();
717 for ( ; chIt != composerHtmlList.constEnd(); ++chIt )
723 QString
id = composerHtml->
frame( 0 )->
id();
727 QDomElement composerHtmlElem = doc.createElement( u
"ComposerHtml"_s );
728 composerHtmlElem.setAttribute( u
"name"_s,
id );
729 composerTemplateElem.appendChild( composerHtmlElem );
732 composerTemplatesElem.appendChild( composerTemplateElem );
735 if ( composerTemplatesElem.childNodes().size() == 0 )
736 return QDomElement();
738 return composerTemplatesElem;
744 if ( wfsLayerIds.size() == 0 )
745 return QDomElement();
747 QDomElement wfsLayersElem = doc.createElement( u
"WFSLayers"_s );
748 for (
int i = 0; i < wfsLayerIds.size(); ++i )
756 QDomElement wfsLayerElem = doc.createElement( u
"WFSLayer"_s );
759 wfsLayerElem.setAttribute( u
"name"_s, layer->
id() );
763 wfsLayerElem.setAttribute( u
"name"_s, layer->
name() );
765 wfsLayersElem.appendChild( wfsLayerElem );
768 return wfsLayersElem;
773 QDomElement &parentLayer,
778 const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos,
784 parentLayer.setAttribute( u
"queryable"_s,
hasQueryableLayers( layerIds, wmsLayerInfos ) ? u
"1"_s : u
"0"_s );
787 QMap<QString, QgsRectangle> crsExtents =
combineCrsExtents( layerIds, wmsLayerInfos );
789 appendCrsElementsToLayer( doc, parentLayer, crsExtents.keys(), QStringList(), !wgs84BoundingRect.
isNull() );
790 appendLayerWgs84BoundingRect( doc, parentLayer, wgs84BoundingRect );
791 appendLayerCrsExtents( doc, parentLayer, crsExtents );
795 appendLayersFromTreeGroup( doc, parentLayer, serverIface, project, request, layerTreeGroup, wmsLayerInfos, projectSettings );
802 QDomElement layerParentElem = doc.createElement( u
"Layer"_s );
805 if ( !skipNameForGroup )
809 if ( rootLayerName.isEmpty() && !project->
title().isEmpty() )
811 rootLayerName = project->
title();
814 if ( !rootLayerName.isEmpty() )
816 QDomElement layerParentNameElem = doc.createElement( u
"Name"_s );
817 QDomText layerParentNameText = doc.createTextNode( rootLayerName );
818 layerParentNameElem.appendChild( layerParentNameText );
819 layerParentElem.appendChild( layerParentNameElem );
824 QDomElement layerParentTitleElem = doc.createElement( u
"Title"_s );
826 layerParentTitleElem.appendChild( layerParentTitleText );
827 layerParentElem.appendChild( layerParentTitleElem );
831 if ( !rootLayerAbstract.isEmpty() )
833 QDomElement layerParentAbstElem = doc.createElement( u
"Abstract"_s );
834 QDomText layerParentAbstText = doc.createCDATASection( rootLayerAbstract );
835 layerParentAbstElem.appendChild( layerParentAbstText );
836 layerParentElem.appendChild( layerParentAbstElem );
840 addKeywordListElement( project, doc, layerParentElem );
843 if ( projectSettings )
845 QDomElement treeNameElem = doc.createElement( u
"TreeName"_s );
846 QDomText treeNameText = doc.createTextNode( project->
title() );
847 treeNameElem.appendChild( treeNameText );
848 layerParentElem.appendChild( treeNameElem );
854 auto outputCrsList = QList<QgsCoordinateReferenceSystem>();
860 outputCrsList.append( crs );
888 QMap<QString, QgsRectangle> wmsCrsExtents;
900 appendCrsElementsToLayer( doc, layerParentElem, wmsCrsExtents.keys(), QStringList(), project->
crs().
isEarthCrs() );
901 appendLayerWgs84BoundingRect( doc, layerParentElem, wmsWgs84BoundingRect );
902 appendLayerCrsExtents( doc, layerParentElem, wmsCrsExtents );
904 appendLayersFromTreeGroup( doc, layerParentElem, serverIface, project, request, projectLayerTreeRoot, wmsLayerInfos, projectSettings );
908 handleLayersFromTreeGroup( doc, layerParentElem, serverIface, project, request, projectLayerTreeRoot, wmsLayerInfos, projectSettings );
911 return layerParentElem;
919 void writeServerProperties( QDomDocument &doc, QDomElement &layerElem,
const QgsProject *project,
const QgsMapLayerServerProperties *serverProperties,
const QString &name,
const QString &version )
921 const QString title = serverProperties->
title();
922 QDomElement titleElem = doc.createElement( u
"Title"_s );
923 QDomText titleText = doc.createTextNode( !title.isEmpty() ? title : name );
924 titleElem.appendChild( titleText );
925 layerElem.appendChild( titleElem );
927 const QString abstract = serverProperties->
abstract();
928 if ( !abstract.isEmpty() )
930 QDomElement abstractElem = doc.createElement( u
"Abstract"_s );
931 QDomText abstractText = doc.createTextNode( abstract );
932 abstractElem.appendChild( abstractText );
933 layerElem.appendChild( abstractElem );
938 const QStringList keywords = !serverProperties->
keywordList().isEmpty() ? serverProperties->
keywordList().split(
',' ) : QStringList();
939 if ( !keywords.isEmpty() )
941 QDomElement keywordListElem = doc.createElement( u
"KeywordList"_s );
942 for (
const QString &keyword : std::as_const( keywords ) )
944 QDomElement keywordElem = doc.createElement( u
"Keyword"_s );
945 QDomText keywordText = doc.createTextNode( keyword.trimmed() );
946 keywordElem.appendChild( keywordText );
949 keywordElem.setAttribute( u
"vocabulary"_s, u
"SIA_Geo405"_s );
951 keywordListElem.appendChild( keywordElem );
953 layerElem.appendChild( keywordListElem );
957 const QString dataUrl = serverProperties->
dataUrl();
958 if ( !dataUrl.isEmpty() )
960 QDomElement dataUrlElem = doc.createElement( u
"DataURL"_s );
961 QDomElement dataUrlFormatElem = doc.createElement( u
"Format"_s );
962 const QString dataUrlFormat = serverProperties->
dataUrlFormat();
963 QDomText dataUrlFormatText = doc.createTextNode( dataUrlFormat );
964 dataUrlFormatElem.appendChild( dataUrlFormatText );
965 dataUrlElem.appendChild( dataUrlFormatElem );
966 QDomElement dataORElem = doc.createElement( u
"OnlineResource"_s );
967 dataORElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
968 dataORElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
969 dataORElem.setAttribute( u
"xlink:href"_s, dataUrl );
970 dataUrlElem.appendChild( dataORElem );
971 layerElem.appendChild( dataUrlElem );
975 const QString attribution = serverProperties->
attribution();
976 if ( !attribution.isEmpty() )
978 QDomElement attribElem = doc.createElement( u
"Attribution"_s );
979 QDomElement attribTitleElem = doc.createElement( u
"Title"_s );
980 QDomText attribText = doc.createTextNode( attribution );
981 attribTitleElem.appendChild( attribText );
982 attribElem.appendChild( attribTitleElem );
983 const QString attributionUrl = serverProperties->
attributionUrl();
984 if ( !attributionUrl.isEmpty() )
986 QDomElement attribORElem = doc.createElement( u
"OnlineResource"_s );
987 attribORElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
988 attribORElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
989 attribORElem.setAttribute( u
"xlink:href"_s, attributionUrl );
990 attribElem.appendChild( attribORElem );
992 layerElem.appendChild( attribElem );
996 const QList<QgsServerMetadataUrlProperties::MetadataUrl> metadataUrls = serverProperties->
metadataUrls();
997 for (
const QgsMapLayerServerProperties::MetadataUrl &metadataUrl : std::as_const( metadataUrls ) )
999 QDomElement metaUrlElem = doc.createElement( u
"MetadataURL"_s );
1000 const QString metadataUrlType = metadataUrl.type;
1001 if ( version ==
"1.1.1"_L1 )
1003 metaUrlElem.setAttribute( u
"type"_s, metadataUrlType );
1005 else if ( metadataUrlType ==
"FGDC"_L1 )
1007 metaUrlElem.setAttribute( u
"type"_s, u
"FGDC:1998"_s );
1009 else if ( metadataUrlType ==
"TC211"_L1 )
1011 metaUrlElem.setAttribute( u
"type"_s, u
"ISO19115:2003"_s );
1015 metaUrlElem.setAttribute( u
"type"_s, metadataUrlType );
1017 const QString metadataUrlFormat = metadataUrl.format;
1018 if ( !metadataUrlFormat.isEmpty() )
1020 QDomElement metaUrlFormatElem = doc.createElement( u
"Format"_s );
1021 QDomText metaUrlFormatText = doc.createTextNode( metadataUrlFormat );
1022 metaUrlFormatElem.appendChild( metaUrlFormatText );
1023 metaUrlElem.appendChild( metaUrlFormatElem );
1025 QDomElement metaUrlORElem = doc.createElement( u
"OnlineResource"_s );
1026 metaUrlORElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
1027 metaUrlORElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
1028 metaUrlORElem.setAttribute( u
"xlink:href"_s, metadataUrl.url );
1029 metaUrlElem.appendChild( metaUrlORElem );
1030 layerElem.appendChild( metaUrlElem );
1034 void writeLegendUrl(
1036 QDomElement &styleElem,
1037 const QString &legendUrl,
1038 const QString &legendUrlFormat,
1039 const QString &name,
1040 const QString &styleName,
1041 const QgsProject *project,
1043 const QgsServerSettings *settings
1047 QDomElement getLayerLegendGraphicElem = doc.createElement( u
"LegendURL"_s );
1049 QString customHrefString = legendUrl;
1051 QStringList getLayerLegendGraphicFormats;
1052 if ( !customHrefString.isEmpty() )
1054 getLayerLegendGraphicFormats << legendUrlFormat;
1058 getLayerLegendGraphicFormats << u
"image/png"_s;
1061 for (
const QString &getLayerLegendGraphicFormat : std::as_const( getLayerLegendGraphicFormats ) )
1063 QDomElement getLayerLegendGraphicFormatElem = doc.createElement( u
"Format"_s );
1064 QDomText getLayerLegendGraphicFormatText = doc.createTextNode( getLayerLegendGraphicFormat );
1065 getLayerLegendGraphicFormatElem.appendChild( getLayerLegendGraphicFormatText );
1066 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicFormatElem );
1070 if ( customHrefString.isEmpty() )
1073 QUrl href =
serviceUrl( request, project, *settings );
1074 const QString hrefString = href.toString() + ( href.hasQuery() ?
"&" :
"?" );
1076 QUrl mapUrl( hrefString );
1077 QUrlQuery mapUrlQuery( mapUrl.query() );
1078 mapUrlQuery.addQueryItem( u
"SERVICE"_s, u
"WMS"_s );
1079 mapUrlQuery.addQueryItem( u
"VERSION"_s, request.wmsParameters().version() );
1080 mapUrlQuery.addQueryItem( u
"REQUEST"_s, u
"GetLegendGraphic"_s );
1081 mapUrlQuery.addQueryItem( u
"LAYER"_s, name );
1082 mapUrlQuery.addQueryItem( u
"FORMAT"_s, u
"image/png"_s );
1083 mapUrlQuery.addQueryItem( u
"STYLE"_s, styleName );
1084 if ( request.wmsParameters().version() ==
"1.3.0"_L1 )
1086 mapUrlQuery.addQueryItem( u
"SLD_VERSION"_s, u
"1.1.0"_s );
1088 mapUrl.setQuery( mapUrlQuery );
1089 customHrefString = mapUrl.toString();
1092 QDomElement getLayerLegendGraphicORElem = doc.createElement( u
"OnlineResource"_s );
1093 getLayerLegendGraphicORElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
1094 getLayerLegendGraphicORElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
1095 getLayerLegendGraphicORElem.setAttribute( u
"xlink:href"_s, customHrefString );
1096 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicORElem );
1097 styleElem.appendChild( getLayerLegendGraphicElem );
1100 QDomElement createStyleElement( QDomDocument &doc,
const QString &styleName )
1102 QDomElement styleElem = doc.createElement( u
"Style"_s );
1103 QDomElement styleNameElem = doc.createElement( u
"Name"_s );
1104 QDomText styleNameText = doc.createTextNode( styleName );
1105 styleNameElem.appendChild( styleNameText );
1106 QDomElement styleTitleElem = doc.createElement( u
"Title"_s );
1107 QDomText styleTitleText = doc.createTextNode( styleName );
1108 styleTitleElem.appendChild( styleTitleText );
1109 styleElem.appendChild( styleNameElem );
1110 styleElem.appendChild( styleTitleElem );
1118 QString dateToString(
const QDateTime &dateTime,
bool dateOnly )
1120 return dateOnly ? dateTime.date().toString( Qt::DateFormat::ISODate ) : dateTime.toString( Qt::DateFormat::ISODate );
1124 bool writeTimeDimensionNode( QDomDocument &doc, QDomElement &layerElem,
const QList<QgsDateTimeRange> &dateRanges,
const QDateTime &defaultDateTime = QDateTime() )
1132 const bool dateOnly = std::all_of( dateRanges.constBegin(), dateRanges.constEnd(), [](
const QgsDateTimeRange &r ) {
1133 return r.begin().time() == QTime( 0, 0 ) && ( r.isInstant() || r.end().time() == QTime( 0, 0 ) );
1136 QStringList strValues;
1140 if ( range.begin().isValid() && range.end().isValid() )
1142 strValues << ( range.isInstant() ? dateToString( range.begin(), dateOnly ) : u
"%1/%2"_s.arg( dateToString( range.begin(), dateOnly ) ).arg( dateToString( range.end(), dateOnly ) ) );
1146 QDomElement dimElem = doc.createElement( u
"Dimension"_s );
1147 dimElem.setAttribute( u
"name"_s, u
"TIME"_s );
1148 dimElem.setAttribute( u
"units"_s, u
"ISO8601"_s );
1150 if ( defaultDateTime.isValid() )
1151 dimElem.setAttribute( u
"default"_s, defaultDateTime.toString( Qt::ISODate ) );
1153 QDomText dimValuesText = doc.createTextNode( strValues.join( QChar(
',' ) ) );
1154 dimElem.appendChild( dimValuesText );
1156 layerElem.appendChild( dimElem );
1161 void appendLayersFromTreeGroup(
1163 QDomElement &parentLayer,
1164 QgsServerInterface *serverIface,
1165 const QgsProject *project,
1167 const QgsLayerTreeGroup *layerTreeGroup,
1168 const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos,
1169 bool projectSettings
1172 const QString version = request.wmsParameters().version();
1177 QList<QgsLayerTreeNode *> layerTreeGroupChildren = layerTreeGroup->
children();
1178 for (
int i = 0; i < layerTreeGroupChildren.size(); ++i )
1180 QgsLayerTreeNode *treeNode = layerTreeGroupChildren.at( i );
1181 QDomElement layerElem = doc.createElement( u
"Layer"_s );
1183 if ( projectSettings )
1185 layerElem.setAttribute( u
"visible"_s, treeNode->
isVisible() );
1187 layerElem.setAttribute( u
"expanded"_s, treeNode->
isExpanded() );
1192 QgsLayerTreeGroup *treeGroupChild =
static_cast<QgsLayerTreeGroup *
>( treeNode );
1194 QString name = treeGroupChild->
name();
1195 if ( restrictedLayers.contains( name ) )
1200 if ( projectSettings )
1208 if ( !skipNameForGroup )
1210 QDomElement nameElem = doc.createElement( u
"Name"_s );
1212 if ( !shortName.isEmpty() )
1213 nameText = doc.createTextNode( shortName );
1215 nameText = doc.createTextNode( name );
1216 nameElem.appendChild( nameText );
1217 layerElem.appendChild( nameElem );
1220 writeServerProperties( doc, layerElem, project, treeGroupChild->
serverProperties(), name, version );
1223 if ( projectSettings )
1225 QDomElement treeNameElem = doc.createElement( u
"TreeName"_s );
1226 QDomText treeNameText = doc.createTextNode( name );
1227 treeNameElem.appendChild( treeNameText );
1228 layerElem.appendChild( treeNameElem );
1231 handleLayersFromTreeGroup( doc, layerElem, serverIface, project, request, treeGroupChild, wmsLayerInfos, projectSettings );
1234 auto it = std::find_if( wmsDimensions.constBegin(), wmsDimensions.constEnd(), [](
const QgsMapLayerServerProperties::WmsDimensionInfo &dim ) {
1235 return dim.name == QgsServerWmsDimensionProperties::TIME_DIMENSION_NAME;
1238 if ( it != wmsDimensions.end() )
1240 QList<QgsDateTimeRange> childrenDateRanges;
1242 QDateTime defaultDateTime;
1243 switch ( it->defaultDisplayType )
1251 defaultDateTime = it->referenceValue().toDateTime();
1259 writeTimeDimensionNode( doc, layerElem, childrenDateRanges, defaultDateTime );
1270 QgsLayerTreeLayer *treeLayer =
static_cast<QgsLayerTreeLayer *
>( treeNode );
1271 QgsMapLayer *l = treeLayer->
layer();
1272 if ( !wmsLayerInfos.contains( treeLayer->
layerId() ) )
1277 const QgsWmsLayerInfos &layerInfos = wmsLayerInfos[treeLayer->
layerId()];
1279 layerElem.setAttribute( u
"queryable"_s, layerInfos.
queryable ? u
"1"_s : u
"0"_s );
1281 QDomElement nameElem = doc.createElement( u
"Name"_s );
1282 QDomText nameText = doc.createTextNode( layerInfos.
name );
1283 nameElem.appendChild( nameText );
1284 layerElem.appendChild( nameElem );
1291 appendCrsElementsToLayer( doc, layerElem, layerInfos.
crsExtents.keys(), QStringList(), l->
crs().
isEarthCrs() );
1295 appendLayerCrsExtents( doc, layerElem, layerInfos.
crsExtents );
1299 appendLayerStyles( doc, layerElem, layerInfos, project, request, serverIface->
serverSettings() );
1305 auto formatScale = [](
double value ) {
1306 const thread_local QRegularExpression trailingZeroRegEx = QRegularExpression( u
"0+$"_s );
1307 const thread_local QRegularExpression trailingPointRegEx = QRegularExpression( u
"[.]+$"_s );
1308 return QString::number( value,
'f' ).remove( trailingZeroRegEx ).remove( trailingPointRegEx );
1311 if ( version ==
"1.1.1"_L1 )
1314 double SCALE_TO_SCALEHINT =
OGC_PX_M * M_SQRT2;
1316 QDomElement scaleHintElem = doc.createElement( u
"ScaleHint"_s );
1317 scaleHintElem.setAttribute( u
"min"_s, formatScale( layerInfos.
maxScale * SCALE_TO_SCALEHINT ) );
1318 scaleHintElem.setAttribute( u
"max"_s, formatScale( layerInfos.
minScale * SCALE_TO_SCALEHINT ) );
1319 layerElem.appendChild( scaleHintElem );
1323 QDomElement minScaleElem = doc.createElement( u
"MinScaleDenominator"_s );
1324 QDomText minScaleText = doc.createTextNode( formatScale( layerInfos.
maxScale ) );
1325 minScaleElem.appendChild( minScaleText );
1326 layerElem.appendChild( minScaleElem );
1328 QDomElement maxScaleElem = doc.createElement( u
"MaxScaleDenominator"_s );
1329 QDomText maxScaleText = doc.createTextNode( formatScale( layerInfos.
minScale ) );
1330 maxScaleElem.appendChild( maxScaleText );
1331 layerElem.appendChild( maxScaleElem );
1335 bool timeDimensionAdded {
false };
1340 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( l );
1341 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( vl->
serverProperties() );
1342 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> wmsDims = serverProperties->
wmsDimensions();
1343 for (
const QgsMapLayerServerProperties::WmsDimensionInfo &dim : wmsDims )
1347 if ( fieldIndex == -1 )
1352 QSet<QVariant> uniqueValues = vl->
uniqueValues( fieldIndex );
1355 if ( !dim.endFieldName.isEmpty() )
1357 int endFieldIndex = vl->
fields().
indexOf( dim.endFieldName );
1359 if ( endFieldIndex == -1 )
1363 uniqueValues.unite( vl->
uniqueValues( endFieldIndex ) );
1366 QList<QVariant> values = qgis::setToList( uniqueValues );
1367 std::sort( values.begin(), values.end() );
1369 QDomElement dimElem = doc.createElement( u
"Dimension"_s );
1370 dimElem.setAttribute( u
"name"_s, dim.name );
1374 timeDimensionAdded =
true;
1377 if ( !dim.units.isEmpty() )
1379 dimElem.setAttribute( u
"units"_s, dim.units );
1381 if ( !dim.unitSymbol.isEmpty() )
1383 dimElem.setAttribute( u
"unitSymbol"_s, dim.unitSymbol );
1387 dimElem.setAttribute( u
"default"_s, values.first().toString() );
1391 dimElem.setAttribute( u
"default"_s, values.last().toString() );
1395 dimElem.setAttribute( u
"default"_s, dim.referenceValue().toString() );
1397 dimElem.setAttribute( u
"multipleValues"_s, u
"1"_s );
1398 dimElem.setAttribute( u
"nearestValue"_s, u
"0"_s );
1399 if ( projectSettings )
1401 dimElem.setAttribute( u
"fieldName"_s, dim.fieldName );
1402 dimElem.setAttribute( u
"endFieldName"_s, dim.endFieldName );
1405 QStringList strValues;
1406 for (
const QVariant &v : values )
1408 strValues << v.toString();
1410 QDomText dimValuesText = doc.createTextNode( strValues.join(
", "_L1 ) );
1411 dimElem.appendChild( dimValuesText );
1412 layerElem.appendChild( dimElem );
1423 const bool dateOnly = writeTimeDimensionNode( doc, layerElem, allRanges );
1425 QDomElement timeExtentElem = doc.createElement( u
"Extent"_s );
1426 timeExtentElem.setAttribute( u
"name"_s, u
"TIME"_s );
1429 const QString extent = u
"%1/%2"_s.arg( dateToString( timeExtent.
begin(), dateOnly ) ).arg( dateToString( timeExtent.
end(), dateOnly ) );
1430 QDomText extentValueText = doc.createTextNode( extent );
1431 timeExtentElem.appendChild( extentValueText );
1432 layerElem.appendChild( timeExtentElem );
1435 if ( projectSettings )
1437 appendLayerProjectSettings( doc, layerElem, l );
1441 parentLayer.appendChild( layerElem );
1445 void appendLayerStyles( QDomDocument &doc, QDomElement &layerElem,
const QgsWmsLayerInfos &layerInfos,
const QgsProject *project,
const QgsWmsRequest &request,
const QgsServerSettings *settings )
1447 for (
const QString &styleName : std::as_const( layerInfos.
styles ) )
1449 QDomElement styleElem = createStyleElement( doc, styleName );
1451 writeLegendUrl( doc, styleElem, layerInfos.
legendUrl, layerInfos.
legendUrlFormat, layerInfos.
name, styleName, project, request, settings );
1453 layerElem.appendChild( styleElem );
1457 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
const QStringList &crsList,
const QStringList &constrainedCrsList,
bool hasEarthCrs )
1459 if ( layerElement.isNull() )
1464 const QString version = doc.documentElement().attribute( u
"version"_s );
1467 QDomElement titleElement = layerElement.firstChildElement( u
"Title"_s );
1468 QDomElement abstractElement = layerElement.firstChildElement( u
"Abstract"_s );
1469 QDomElement keywordListElement = layerElement.firstChildElement( u
"KeywordList"_s );
1470 QDomElement CRSPrecedingElement = !keywordListElement.isNull() ? keywordListElement : !abstractElement.isNull() ? abstractElement : titleElement;
1472 if ( CRSPrecedingElement.isNull() )
1475 const QDomElement keyElement = layerElement.firstChildElement( u
"KeywordList"_s );
1476 CRSPrecedingElement = keyElement;
1480 if ( !constrainedCrsList.isEmpty() )
1482 for (
int i = constrainedCrsList.size() - 1; i >= 0; --i )
1484 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, constrainedCrsList.at( i ) );
1489 for (
const QString &crs : crsList )
1491 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, crs );
1497 if ( version ==
"1.3.0"_L1 && hasEarthCrs )
1499 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, QString(
"CRS:84" ) );
1503 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
const QString &crsText )
1505 if ( crsText.isEmpty() )
1507 const QString version = doc.documentElement().attribute( u
"version"_s );
1508 QDomElement crsElement = doc.createElement( version ==
"1.1.1"_L1 ?
"SRS" :
"CRS" );
1509 QDomText crsTextNode = doc.createTextNode( crsText );
1510 crsElement.appendChild( crsTextNode );
1511 layerElement.insertAfter( crsElement, precedingElement );
1514 void appendLayerWgs84BoundingRect( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &wgs84BoundingRect )
1517 if ( wgs84BoundingRect.
isNull() )
1523 QDomElement ExGeoBBoxElement;
1524 const int wgs84precision = 6;
1525 const QString version = doc.documentElement().attribute( u
"version"_s );
1526 if ( version ==
"1.1.1"_L1 )
1528 ExGeoBBoxElement = doc.createElement( u
"LatLonBoundingBox"_s );
1536 ExGeoBBoxElement = doc.createElement( u
"EX_GeographicBoundingBox"_s );
1537 QDomElement wBoundLongitudeElement = doc.createElement( u
"westBoundLongitude"_s );
1539 wBoundLongitudeElement.appendChild( wBoundLongitudeText );
1540 ExGeoBBoxElement.appendChild( wBoundLongitudeElement );
1541 QDomElement eBoundLongitudeElement = doc.createElement( u
"eastBoundLongitude"_s );
1543 eBoundLongitudeElement.appendChild( eBoundLongitudeText );
1544 ExGeoBBoxElement.appendChild( eBoundLongitudeElement );
1545 QDomElement sBoundLatitudeElement = doc.createElement( u
"southBoundLatitude"_s );
1547 sBoundLatitudeElement.appendChild( sBoundLatitudeText );
1548 ExGeoBBoxElement.appendChild( sBoundLatitudeElement );
1549 QDomElement nBoundLatitudeElement = doc.createElement( u
"northBoundLatitude"_s );
1551 nBoundLatitudeElement.appendChild( nBoundLatitudeText );
1552 ExGeoBBoxElement.appendChild( nBoundLatitudeElement );
1555 const QDomElement lastCRSElem = layerElem.lastChildElement( version ==
"1.1.1"_L1 ?
"SRS" :
"CRS" );
1556 if ( !lastCRSElem.isNull() )
1558 layerElem.insertAfter( ExGeoBBoxElement, lastCRSElem );
1562 layerElem.appendChild( ExGeoBBoxElement );
1566 void appendLayerCrsExtents( QDomDocument &doc, QDomElement &layerElem,
const QMap<QString, QgsRectangle> &crsExtents )
1568 const QString version = doc.documentElement().attribute( u
"version"_s );
1570 const auto &keys = crsExtents.keys();
1571 for (
const QString &crsText : std::as_const( keys ) )
1574 QgsRectangle crsExtent( crsExtents[crsText] );
1576 if ( crsExtent.isNull() )
1588 QDomElement bBoxElement = doc.createElement( u
"BoundingBox"_s );
1591 bBoxElement.setAttribute( version ==
"1.1.1"_L1 ?
"SRS" :
"CRS", crs.
authid() );
1604 QDomElement lastBBoxElem = layerElem.lastChildElement( u
"BoundingBox"_s );
1605 if ( !lastBBoxElem.isNull() )
1607 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1611 lastBBoxElem = layerElem.lastChildElement( version ==
"1.1.1"_L1 ?
"LatLonBoundingBox" :
"EX_GeographicBoundingBox" );
1612 if ( !lastBBoxElem.isNull() )
1614 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1618 layerElem.appendChild( bBoxElement );
1624 void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem, QgsServerInterface *serverIface,
const QgsProject *project )
1626#ifdef HAVE_SERVER_PYTHON_PLUGINS
1629 ( void ) serverIface;
1634 QStringList layerList;
1636 QHash<const QgsMapLayer *, QStringList> acceptableLayersAndRequestNames;
1639 const QgsLayerTree *projectLayerTreeRoot = project->
layerTreeRoot();
1640 QList<QgsMapLayer *> projectLayerOrder = projectLayerTreeRoot->
layerOrder();
1641 for (
int i = 0; i < projectLayerOrder.size(); ++i )
1643 QgsMapLayer *l = projectLayerOrder.at( i );
1645 if ( restrictedLayers.contains( l->
name() ) )
1651 if ( !acceptableLayersAndRequestNames.contains( l ) )
1655#ifdef HAVE_SERVER_PYTHON_PLUGINS
1661 QString wmsName = l->
name();
1671 layerList << wmsName;
1674 if ( !layerList.isEmpty() )
1676 QStringList reversedList;
1677 reversedList.reserve( layerList.size() );
1678 for (
int i = layerList.size() - 1; i >= 0; --i )
1679 reversedList << layerList[i];
1681 QDomElement layerDrawingOrderElem = doc.createElement( u
"LayerDrawingOrder"_s );
1682 QDomText drawingOrderText = doc.createTextNode( reversedList.join(
',' ) );
1683 layerDrawingOrderElem.appendChild( drawingOrderText );
1684 parentElem.appendChild( layerDrawingOrderElem );
1688 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem, QgsMapLayer *currentLayer )
1690 if ( !currentLayer )
1696 QDomElement treeNameElem = doc.createElement( u
"TreeName"_s );
1697 QDomText treeNameText = doc.createTextNode( currentLayer->
name() );
1698 treeNameElem.appendChild( treeNameText );
1699 layerElem.appendChild( treeNameElem );
1701 switch ( currentLayer->
type() )
1705 QgsVectorLayer *vLayer =
static_cast<QgsVectorLayer *
>( currentLayer );
1707 int displayFieldIdx = -1;
1708 QString displayField = u
"maptip"_s;
1710 if ( exp.isField() )
1712 displayField =
static_cast<const QgsExpressionNodeColumnRef *
>( exp.rootNode() )->name();
1717 QDomElement attributesElem = doc.createElement( u
"Attributes"_s );
1718 const QgsFields layerFields = vLayer->
fields();
1719 for (
int idx = 0; idx < layerFields.
count(); ++idx )
1721 QgsField field = layerFields.
at( idx );
1727 if ( idx == displayFieldIdx )
1731 QDomElement attributeElem = doc.createElement( u
"Attribute"_s );
1732 attributeElem.setAttribute( u
"name"_s, field.
name() );
1733 attributeElem.setAttribute( u
"type"_s, QVariant::typeToName( field.
type() ) );
1734 attributeElem.setAttribute( u
"typeName"_s, field.
typeName() );
1735 QString alias = field.
alias();
1736 if ( !alias.isEmpty() )
1738 attributeElem.setAttribute( u
"alias"_s, alias );
1743 attributeElem.setAttribute( u
"comment"_s, field.
comment() );
1744 attributeElem.setAttribute( u
"length"_s, field.
length() );
1745 attributeElem.setAttribute( u
"precision"_s, field.
precision() );
1746 attributesElem.appendChild( attributeElem );
1750 layerElem.setAttribute( u
"displayField"_s, displayField );
1754 if ( pkAttributes.size() > 0 )
1756 QDomElement pkElem = doc.createElement( u
"PrimaryKey"_s );
1757 QgsAttributeList::const_iterator pkIt = pkAttributes.constBegin();
1758 for ( ; pkIt != pkAttributes.constEnd(); ++pkIt )
1760 QDomElement pkAttributeElem = doc.createElement( u
"PrimaryKeyAttribute"_s );
1761 QDomText pkAttName = doc.createTextNode( layerFields.
at( *pkIt ).
name() );
1762 pkAttributeElem.appendChild( pkAttName );
1763 pkElem.appendChild( pkAttributeElem );
1765 layerElem.appendChild( pkElem );
1772 layerElem.setAttribute( u
"opacity"_s, QString::number( vLayer->
opacity() ) );
1774 layerElem.appendChild( attributesElem );
1780 const QgsDataProvider *provider = currentLayer->
dataProvider();
1781 if ( provider && provider->
name() ==
"wms" )
1784 QVariant wmsBackgroundLayer = currentLayer->
customProperty( u
"WMSBackgroundLayer"_s,
false );
1785 QDomElement wmsBackgroundLayerElem = doc.createElement(
"WMSBackgroundLayer" );
1786 QDomText wmsBackgroundLayerText = doc.createTextNode( wmsBackgroundLayer.toBool() ? u
"1"_s : u
"0"_s );
1787 wmsBackgroundLayerElem.appendChild( wmsBackgroundLayerText );
1788 layerElem.appendChild( wmsBackgroundLayerElem );
1791 QVariant wmsPublishDataSourceUrl = currentLayer->
customProperty( u
"WMSPublishDataSourceUrl"_s,
false );
1792 if ( wmsPublishDataSourceUrl.toBool() )
1794 bool tiled = qobject_cast<const QgsRasterDataProvider *>( provider ) ? !qobject_cast<const QgsRasterDataProvider *>( provider )->nativeResolutions().isEmpty() :
false;
1796 QDomElement dataSourceElem = doc.createElement( tiled ? u
"WMTSDataSource"_s : u
"WMSDataSource"_s );
1797 QDomText dataSourceUri = doc.createTextNode( provider->
dataSourceUri() );
1798 dataSourceElem.appendChild( dataSourceUri );
1799 layerElem.appendChild( dataSourceElem );
1803 QVariant wmsPrintLayer = currentLayer->
customProperty( u
"WMSPrintLayer"_s );
1804 if ( wmsPrintLayer.isValid() )
1806 QDomElement wmsPrintLayerElem = doc.createElement(
"WMSPrintLayer" );
1807 QDomText wmsPrintLayerText = doc.createTextNode( wmsPrintLayer.toString() );
1808 wmsPrintLayerElem.appendChild( wmsPrintLayerText );
1809 layerElem.appendChild( wmsPrintLayerElem );
1813 QgsRasterLayer *rl =
static_cast<QgsRasterLayer *
>( currentLayer );
1814 QgsRasterRenderer *rasterRenderer = rl->
renderer();
1815 if ( rasterRenderer )
1817 layerElem.setAttribute( u
"opacity"_s, QString::number( rasterRenderer->
opacity() ) );
1833 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent )
1837 QDomElement keywordsElem = doc.createElement( u
"KeywordList"_s );
1839 QDomElement keywordElem = doc.createElement( u
"Keyword"_s );
1840 keywordElem.setAttribute( u
"vocabulary"_s, u
"ISO"_s );
1841 QDomText keywordText = doc.createTextNode( u
"infoMapAccessService"_s );
1842 keywordElem.appendChild( keywordText );
1843 keywordsElem.appendChild( keywordElem );
1844 parent.appendChild( keywordsElem );
1846 for (
const QString &keyword : std::as_const( keywords ) )
1848 if ( !keyword.isEmpty() )
1850 keywordElem = doc.createElement( u
"Keyword"_s );
1851 keywordText = doc.createTextNode( keyword );
1852 keywordElem.appendChild( keywordText );
1855 keywordElem.setAttribute( u
"vocabulary"_s, u
"SIA_Geo405"_s );
1857 keywordsElem.appendChild( keywordElem );
1860 parent.appendChild( keywordsElem );
1864 bool hasQueryableLayers(
const QStringList &layerIds,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos )
1866 for (
const QString &
id : std::as_const( layerIds ) )
1868 if ( !wmsLayerInfos.contains(
id ) )
1872 if ( wmsLayerInfos[
id].queryable )
1885 for (
const QString &
id : std::as_const( layerIds ) )
1887 if ( !wmsLayerInfos.contains(
id ) )
1892 QgsRectangle rect = wmsLayerInfos[id].wgs84BoundingRect;
1917 QMap<QString, QgsRectangle>
combineCrsExtents(
const QStringList &layerIds,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos )
1919 QMap<QString, QgsRectangle> combined;
1921 for (
const QString &
id : std::as_const( layerIds ) )
1923 if ( !wmsLayerInfos.contains(
id ) )
1929 const auto keys = layerInfos.
crsExtents.keys();
1930 for (
const QString &crs : std::as_const( keys ) )
1943 if ( !combined.contains( crs ) )
1945 combined[crs] = rect;
1949 combined[crs].combineExtentWith( rect );
@ Opaque
Group can be requested, children cannot (appears like a single layer).
@ Millimeters
Millimeters.
@ Warning
Warning message.
@ Group
Composite group layer. Added in QGIS 3.24.
@ Plugin
Plugin based layer.
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
@ Mesh
Mesh layer. Added in QGIS 3.2.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
static QString geographicCrsAuthId()
Geographic coordinate system auth:id string for a default geographic CRS (EPSG:4326).
@ 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.
@ HideFromWms
Field is not available if layer is served as WMS from QGIS server.
A helper class that centralizes restrictions given by all the access control filter plugins.
bool layerReadPermission(const QgsMapLayer *layer) const
Returns the layer read right.
bool fillCacheKey(QStringList &cacheKey) const
Fill the capabilities caching key.
A cache for capabilities xml documents (by configuration file path).
const QDomDocument * searchCapabilitiesDocument(const QString &configFilePath, const QString &key)
Returns cached capabilities document (or 0 if document for configuration file not in cache).
void insertCapabilitiesDocument(const QString &configFilePath, const QString &key, const QDomDocument *doc)
Inserts new capabilities document (creates a copy of the document, does not take ownership).
Represents a coordinate reference system (CRS).
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
bool isEarthCrs() const
Returns true if the CRS is associated with the Earth.
bool hasAxisInverted() const
Returns whether the axis order is inverted for the CRS compared to the order east/north (longitude/la...
Custom exception class for Coordinate Reference System related exceptions.
virtual QString name() const =0
Returns a provider name.
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
QString typeName() const
Gets the field type.
Qgis::FieldConfigurationFlags configurationFlags
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).
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
Layer tree group node serves as a container for layers and further groups.
QString name() const override
Returns the group's name.
QStringList findLayerIds() const
Find layer IDs used in all layer nodes.
QgsMapLayerServerProperties * serverProperties()
Returns QGIS Server Properties for the layer tree group.
bool isMutuallyExclusive() const
Returns whether the group is mutually exclusive (only one child can be checked at a time).
Qgis::WmsGroupRequestMode wmsGroupRequestMode() const
Returns the request mode of the group.
QString layerId() const
Returns the ID for the map layer associated with this node.
QgsMapLayer * layer() const
Returns the map layer associated with this node.
@ NodeGroup
Container of other groups and layers.
bool isVisible() const
Returns whether a node is really visible (ie checked and all its ancestors checked as well).
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
NodeType nodeType() const
Find out about type of the node. It is usually shorter to use convenience functions from QgsLayerTree...
bool isExpanded() const
Returns whether the node should be shown as expanded or collapsed in GUI.
bool itemVisibilityChecked() const
Returns whether a node is checked (independently of its ancestors or children).
Namespace with helper functions for layer tree operations.
QList< QgsMapLayer * > layerOrder() const
The order in which layers will be rendered on the canvas.
Used to render QgsLayout as an atlas, by iterating over the features from an associated vector layer.
bool enabled() const
Returns whether the atlas generation is enabled.
QgsVectorLayer * coverageLayer() const
Returns the coverage layer used for the atlas features.
A layout multiframe subclass for HTML content.
A layout item subclass for text labels.
Layout graphical items for displaying a map.
QString displayName() const override
Gets item display name.
QgsLayoutSize sizeWithUnits() const
Returns the item's current size, including units.
QString id() const
Returns the item's ID name.
QList< QgsPrintLayout * > printLayouts() const
Returns a list of all print layouts contained in the manager.
Provides a method of storing measurements for use in QGIS layouts using a variety of different measur...
double length() const
Returns the length of the measurement.
int frameCount() const
Returns the number of frames associated with this multiframe.
QgsLayoutFrame * frame(int index) const
Returns the child frame at a specified index from the multiframe.
int pageCount() const
Returns the number of pages in the collection.
QgsLayoutItemPage * page(int pageNumber)
Returns a specific page (by pageNumber) from the collection.
Provides a method of storing sizes, consisting of a width and height, for use in QGIS layouts.
double height() const
Returns the height of the size.
double width() const
Returns the width of the size.
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout.
void layoutItems(QList< T * > &itemList) const
Returns a list of layout items of a specific type.
void layoutObjects(QList< T * > &objectList) const
Returns a list of layout objects (items and multiframes) of a specific type.
QgsLayoutMeasurement convertFromLayoutUnits(double length, Qgis::LayoutUnit unit) const
Converts a length measurement from the layout's native units to a specified target unit.
Manages QGIS Server properties for a map layer.
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
QString keywordList() const
Returns the keyword list of the layerused by QGIS Server in GetCapabilities request.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
QString abstract() const
Returns the abstract of the layerused by QGIS Server in GetCapabilities request.
virtual QgsDateTimeRange calculateTemporalExtent(QgsMapLayer *layer) const
Attempts to calculate the overall temporal extent for the specified layer, using the settings defined...
virtual QList< QgsDateTimeRange > allTemporalRanges(QgsMapLayer *layer) const
Attempts to calculate the overall list of all temporal extents which are contained in the specified l...
Base class for all map layer types.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QgsCoordinateReferenceSystem crs
QgsMapLayerServerProperties * serverProperties()
Returns QGIS Server Properties for the map layer.
virtual QgsMapLayerTemporalProperties * temporalProperties()
Returns the layer's temporal properties.
virtual Q_INVOKABLE QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be nullptr.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE(), Qgis::StringFormat format=Qgis::StringFormat::PlainText)
Adds a message to the log instance (and creates it if necessary).
Print layout, a QgsLayout subclass for static or atlas-based layouts.
QgsLayoutAtlas * atlas()
Returns the print layout's atlas.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
QgsCoordinateTransformContext transformContext
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree.
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
QgsCoordinateReferenceSystem crs
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
double opacity() const
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
A rectangle specified with double values.
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle.
A helper class that centralizes caches accesses given by all the server cache filter plugins.
bool setCachedDocument(const QDomDocument *doc, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Updates or inserts the document in cache like capabilities.
bool getCachedDocument(QDomDocument *doc, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Returns cached document (or 0 if document not in cache) like capabilities.
Defines interfaces exposed by QGIS Server and made available to plugins.
virtual QgsServerCacheManager * cacheManager() const =0
Gets the registered server cache filters.
virtual QString configFilePath()=0
Returns the configuration file path.
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
virtual QgsServerSettings * serverSettings()=0
Returns the server settings.
virtual QgsCapabilitiesCache * capabilitiesCache()=0
Gets pointer to the capabiblities cache.
QString service() const
Returns SERVICE parameter as a string or an empty string if not defined.
static QString wmsRootName(const QgsProject &project)
Returns the WMS root layer name defined in a QGIS project.
static bool wmsInfoFormatSia2045(const QgsProject &project)
Returns if the info format is SIA20145.
static bool wmsSkipNameForGroup(const QgsProject &project)
Returns if name attribute should be skipped for groups in WMS capabilities document.
static QString wmsInspireMetadataUrl(const QgsProject &project)
Returns the Inspire metadata URL.
static double ceilWithPrecision(double number, int places)
Returns a double greater than number to the specified number of places.
static QStringList wmsRestrictedComposers(const QgsProject &project)
Returns the restricted composer list.
static QgsRectangle wmsExtent(const QgsProject &project)
Returns the WMS Extent restriction.
static bool wmsUseLayerIds(const QgsProject &project)
Returns if layer ids are used as name in WMS.
static QString owsServiceAccessConstraints(const QgsProject &project)
Returns the owsService access constraints defined in project.
static QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
static QString owsServiceOnlineResource(const QgsProject &project)
Returns the owsService online resource defined in project.
static QString owsServiceFees(const QgsProject &project)
Returns the owsService fees defined in project.
static QStringList owsServiceKeywords(const QgsProject &project)
Returns the owsService keywords defined in project.
static QString owsServiceContactPosition(const QgsProject &project)
Returns the owsService contact position defined in project.
static QString serviceUrl(const QString &service, const QgsServerRequest &request, const QgsServerSettings &settings)
Returns the service url defined in the environment variable or with HTTP header.
static QString wmsInspireTemporalReference(const QgsProject &project)
Returns the Inspire temporal reference.
static QStringList wmsOutputCrsList(const QgsProject &project)
Returns the WMS output CRS list.
static QString wmsInspireMetadataDate(const QgsProject &project)
Returns the Inspire metadata date.
static QString owsServiceContactOrganization(const QgsProject &project)
Returns the owsService contact organization defined in project.
static QStringList wmsRestrictedLayers(const QgsProject &project)
Returns the restricted layer name list.
static QString wmsInspireLanguage(const QgsProject &project)
Returns the Inspire language.
static QString wmsInspireMetadataUrlType(const QgsProject &project)
Returns the Inspire metadata URL type.
static bool wmsInspireActivate(const QgsProject &project)
Returns if Inspire is activated.
static int wmsMaxWidth(const QgsProject &project)
Returns the maximum width for WMS images defined in a QGIS project.
static QString owsServiceTitle(const QgsProject &project)
Returns the owsService title defined in project.
static QString owsServiceContactMail(const QgsProject &project)
Returns the owsService contact mail defined in project.
static QString owsServiceAbstract(const QgsProject &project)
Returns the owsService abstract defined in project.
static double floorWithPrecision(double number, int places)
Returns a double less than number to the specified number of places.
static int wmsMaxHeight(const QgsProject &project)
Returns the maximum height for WMS images defined in a QGIS project.
static QString owsServiceContactPhone(const QgsProject &project)
Returns the owsService contact phone defined in project.
static QString owsServiceContactPerson(const QgsProject &project)
Returns the owsService contact person defined in project.
QgsServerParameters serverParameters() const
Returns parameters.
Defines the response interface passed to QgsService.
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device.
virtual void setHeader(const QString &key, const QString &value)=0
Set a single header value replacing any existing value(s) for the same key.
Provides a way to retrieve settings by prioritizing according to environment variables,...
bool getPrintDisabled() const
Returns true if WMS GetPrint request is disabled and the project's reading flag QgsProject::ReadFlag:...
static constexpr const char * TIME_DIMENSION_NAME
const QList< QgsServerWmsDimensionProperties::WmsDimensionInfo > wmsDimensions() const
Returns the QGIS Server WMS Dimension list.
bool isActive() const
Returns true if the temporal property is active.
T begin() const
Returns the beginning of the range.
static QDateTime min(const QList< QgsTemporalRange< QDateTime > > &ranges)
T end() const
Returns the upper bound of the range.
Represents a vector layer which manages a vector based dataset.
Q_INVOKABLE QString attributeDisplayName(int index) const
Convenience function that returns the attribute alias if defined or the field name else.
Q_INVOKABLE Qgis::WkbType wkbType() const final
Returns the WKBType or WKBUnknown in case of error.
QString displayExpression
QgsEditorWidgetSetup editorWidgetSetup(int index) const
Returns the editor widget setup for the field at the specified index.
QgsAttributeList primaryKeyAttributes() const
Returns the list of attributes which make up the layer's primary keys.
Q_INVOKABLE QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const final
Calculates a list of unique values contained within an attribute in the layer.
static Q_INVOKABLE QString displayString(Qgis::WkbType type)
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
QString legendUrlFormat
WMS layer legend URL format.
QStringList styles
WMS layer styles.
QString legendUrl
WMS layer legend URL.
static QgsRectangle transformExtent(const QgsRectangle &extent, const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination, const QgsCoordinateTransformContext &context, const bool &ballparkTransformsAreAppropriate=false)
Returns a transformed extent.
double maxScale
WMS layer maximum scale (if negative, no maximum scale is defined).
QMap< QString, QgsRectangle > crsExtents
WMS layer CRS extents (can be empty).
static QMap< QString, QgsRectangle > transformExtentToCrsList(const QgsRectangle &extent, const QgsCoordinateReferenceSystem &source, const QList< QgsCoordinateReferenceSystem > &destinations, const QgsCoordinateTransformContext &context)
Returns a map with CRS authid as key and the transformed extent as value.
QString name
WMS layer name.
static QMap< QString, QgsWmsLayerInfos > buildWmsLayerInfos(QgsServerInterface *serverIface, const QgsProject *project, const QList< QgsCoordinateReferenceSystem > &outputCrsList)
Returns the WMS layers definition to build WMS capabilities.
bool hasScaleBasedVisibility
WMS layer has scale based visibility.
double minScale
WMS layer minimum scale (if negative, no maximum scale is defined).
bool queryable
WMS layer is queryable.
QgsRectangle wgs84BoundingRect
WMS layer WGS84 bounding rectangle (can be empty).
QString version() const override
Returns VERSION parameter as a string or an empty string if not defined.
Defines request interfaces passed to WMS service.
const QgsWmsParameters & wmsParameters() const
Returns the parameters interpreted for the WMS service.
Median cut implementation.
QDomElement getWFSLayersElement(QDomDocument &doc, const QgsProject *project)
Create WFSLayers element for get capabilities document.
void writeGetCapabilities(QgsServerInterface *serverIface, const QgsProject *project, const QgsWmsRequest &request, QgsServerResponse &response, bool projectSettings)
Output GetCapabilities response.
void collectAcceptableLayersAndRequestNames(QHash< const QgsMapLayer *, QStringList > &acceptableLayersAndRequestNames, const QgsProject &project, const QStringList &requestedLayerNames)
Collects the acceptableLayersAndRequestNames, a hash of all the layers that can be rendered and for e...
QDomElement getLayersAndStylesCapabilitiesElement(QDomDocument &doc, QgsServerInterface *serverIface, const QgsProject *project, const QgsWmsRequest &request, bool projectSettings)
Create element for get capabilities document.
QDomElement getInspireCapabilitiesElement(QDomDocument &doc, const QgsProject *project)
Create InspireCapabilities element for get capabilities document.
void handleLayersFromTreeGroup(QDomDocument &doc, QDomElement &parentLayer, QgsServerInterface *serverIface, const QgsProject *project, const QgsWmsRequest &request, const QgsLayerTreeGroup *layerTreeGroup, const QMap< QString, QgsWmsLayerInfos > &wmsLayerInfos, bool projectSettings)
QDomElement getComposerTemplatesElement(QDomDocument &doc, const QgsProject *project)
Create ComposerTemplates element for get capabilities document.
QDomElement getServiceElement(QDomDocument &doc, const QgsProject *project, const QgsWmsRequest &request, const QgsServerSettings *serverSettings)
Create Service element for get capabilities document.
QDomElement getCapabilityElement(QDomDocument &doc, const QgsProject *project, const QgsWmsRequest &request, bool projectSettings, QgsServerInterface *serverIface)
Create Capability element for get capabilities document.
QDomDocument getCapabilities(QgsServerInterface *serverIface, const QgsProject *project, const QgsWmsRequest &request, bool projectSettings)
Creates the WMS GetCapabilities XML document.
void getChildRanges(const QgsLayerTreeGroup *layerTreeGroup, const QMap< QString, QgsWmsLayerInfos > &wmsLayerInfos, const QStringList &restrictedLayers, QList< QgsDateTimeRange > &dateRanges)
Update recursively dateRanges with all layerTreeGroup children date ranges.
bool hasQueryableLayers(const QStringList &layerIds, const QMap< QString, QgsWmsLayerInfos > &wmsLayerInfos)
Returns true if at least one layer from the layers ids is queryable.
QgsRectangle combineWgs84BoundingRect(const QStringList &layerIds, const QMap< QString, QgsWmsLayerInfos > &wmsLayerInfos)
Returns the combination of the WGS84 bounding rectangle of the layers from the list of layers ids.
QMap< QString, QgsRectangle > combineCrsExtents(const QStringList &layerIds, const QMap< QString, QgsWmsLayerInfos > &wmsLayerInfos)
Returns the combinations of the extent CRSes of the layers from the list of layers ids.
QUrl serviceUrl(const QgsServerRequest &request, const QgsProject *project, const QgsServerSettings &settings)
Returns WMS service URL.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
const QString cacheKey(const QString &pathIn)
QList< int > QgsAttributeList
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.