45using namespace Qt::StringLiterals;
51 QString dateToString(
const QDateTime &dateTime,
bool forceToDate );
53 void getChildrenRanges(
const QgsLayerTreeGroup *layerTreeGroup,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos,
const QStringList &restrictedLayers, QList<QgsDateTimeRange> &dateRanges );
55 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem, QgsMapLayer *currentLayer );
57 void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem, QgsServerInterface *serverIface,
const QgsProject *project );
59 void appendLayerWgs84BoundingRect( QDomDocument &doc, QDomElement &layerElement,
const QgsRectangle &wgs84BoundingRect );
61 void appendLayerCrsExtents( QDomDocument &doc, QDomElement &layerElement,
const QMap<QString, QgsRectangle> &crsExtents );
63 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
const QString &crsText );
65 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
const QStringList &crsList,
const QStringList &constrainedCrsList,
bool hasEarthCrs =
true );
67 void appendLayerStyles( QDomDocument &doc, QDomElement &layerElem,
const QgsWmsLayerInfos &layerInfos,
const QgsProject *project,
const QgsWmsRequest &request,
const QgsServerSettings *settings );
69 void appendLayersFromTreeGroup(
71 QDomElement &parentLayer,
72 QgsServerInterface *serverIface,
73 const QgsProject *project,
75 const QgsLayerTreeGroup *layerTreeGroup,
76 const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos,
80 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent );
86#ifdef HAVE_SERVER_PYTHON_PLUGINS
91 const QDomDocument *capabilitiesDocument =
nullptr;
96 QStringList cacheKeyList;
97 cacheKeyList << ( projectSettings ? u
"projectSettings"_s : request.
wmsParameters().version() );
101#ifdef HAVE_SERVER_PYTHON_PLUGINS
105 QString
cacheKey = cacheKeyList.join(
'-' );
107#ifdef HAVE_SERVER_PYTHON_PLUGINS
109 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
111 capabilitiesDocument = &doc;
114 if ( !capabilitiesDocument && cache )
119 if ( !capabilitiesDocument )
123 doc =
getCapabilities( serverIface, project, request, projectSettings );
125#ifdef HAVE_SERVER_PYTHON_PLUGINS
126 if ( cacheManager && cacheManager->
setCachedDocument( &doc, project, request, accessControl ) )
128 capabilitiesDocument = &doc;
133 if ( !capabilitiesDocument )
138 if ( !capabilitiesDocument )
140 capabilitiesDocument = &doc;
152 response.
setHeader( u
"Content-Type"_s, u
"text/xml; charset=utf-8"_s );
153 response.
write( capabilitiesDocument->toByteArray() );
159 QDomElement wmsCapabilitiesElement;
165 QString hrefString = href.toString();
166 hrefString.append( href.hasQuery() ?
"&" :
"?" );
169 QDomProcessingInstruction xmlDeclaration = doc.createProcessingInstruction( u
"xml"_s, u
"version=\"1.0\" encoding=\"utf-8\""_s );
172 std::function<void( QDomElement &,
const QString & )> appendFormat = [&doc]( QDomElement &elem,
const QString &format ) {
173 QDomElement formatElem = doc.createElement( u
"Format"_s );
174 formatElem.appendChild( doc.createTextNode( format ) );
175 elem.appendChild( formatElem );
181 u
"WMT_MS_Capabilities SYSTEM 'http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd'"_s
183 doc.appendChild( xmlDeclaration );
184 wmsCapabilitiesElement = doc.createElement( u
"WMT_MS_Capabilities"_s );
188 doc.appendChild( xmlDeclaration );
189 wmsCapabilitiesElement = doc.createElement( u
"WMS_Capabilities"_s );
190 wmsCapabilitiesElement.setAttribute( u
"xmlns"_s, u
"http://www.opengis.net/wms"_s );
191 wmsCapabilitiesElement.setAttribute( u
"xmlns:sld"_s, u
"http://www.opengis.net/sld"_s );
192 wmsCapabilitiesElement.setAttribute( u
"xmlns:qgs"_s, u
"http://www.qgis.org/wms"_s );
193 wmsCapabilitiesElement.setAttribute( u
"xmlns:xsi"_s, u
"http://www.w3.org/2001/XMLSchema-instance"_s );
194 QString schemaLocation = u
"http://www.opengis.net/wms"_s;
195 schemaLocation +=
" http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd"_L1;
196 schemaLocation +=
" http://www.opengis.net/sld"_L1;
197 schemaLocation +=
" http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd"_L1;
201 wmsCapabilitiesElement.setAttribute( u
"xmlns:inspire_common"_s, u
"http://inspire.ec.europa.eu/schemas/common/1.0"_s );
202 wmsCapabilitiesElement.setAttribute( u
"xmlns:inspire_vs"_s, u
"http://inspire.ec.europa.eu/schemas/inspire_vs/1.0"_s );
203 schemaLocation +=
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0"_L1;
204 schemaLocation +=
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0/inspire_vs.xsd"_L1;
207 schemaLocation +=
" http://www.qgis.org/wms"_L1;
208 schemaLocation +=
" " + hrefString +
"SERVICE=WMS&REQUEST=GetSchemaExtension";
210 wmsCapabilitiesElement.setAttribute( u
"xsi:schemaLocation"_s, schemaLocation );
213 doc.appendChild( wmsCapabilitiesElement );
219 QDomElement capabilityElement =
getCapabilityElement( doc, project, request, projectSettings, serverIface );
220 wmsCapabilitiesElement.appendChild( capabilityElement );
222 if ( projectSettings )
233 if ( projectSettings )
235 appendDrawingOrder( doc, capabilityElement, serverIface, project );
244 QDomElement serviceElem = doc.createElement( u
"Service"_s );
247 QDomElement nameElem = doc.createElement( u
"Name"_s );
248 QDomText nameText = doc.createTextNode( u
"WMS"_s );
249 nameElem.appendChild( nameText );
250 serviceElem.appendChild( nameElem );
253 QDomElement titleElem = doc.createElement( u
"Title"_s );
255 titleElem.appendChild( titleText );
256 serviceElem.appendChild( titleElem );
259 if ( !abstract.isEmpty() )
261 QDomElement abstractElem = doc.createElement( u
"Abstract"_s );
262 QDomText abstractText = doc.createCDATASection( abstract );
263 abstractElem.appendChild( abstractText );
264 serviceElem.appendChild( abstractElem );
267 addKeywordListElement( project, doc, serviceElem );
270 if ( onlineResource.isEmpty() )
272 onlineResource =
serviceUrl( request, project, *serverSettings ).toString();
274 QDomElement onlineResourceElem = doc.createElement( u
"OnlineResource"_s );
275 onlineResourceElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
276 onlineResourceElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
277 onlineResourceElem.setAttribute( u
"xlink:href"_s, onlineResource );
278 serviceElem.appendChild( onlineResourceElem );
285 if ( !contactPerson.isEmpty() || !contactOrganization.isEmpty() || !contactPosition.isEmpty() || !contactMail.isEmpty() || !contactPhone.isEmpty() )
288 QDomElement contactInfoElem = doc.createElement( u
"ContactInformation"_s );
291 if ( !contactPerson.isEmpty() || !contactOrganization.isEmpty() )
293 QDomElement contactPersonPrimaryElem = doc.createElement( u
"ContactPersonPrimary"_s );
295 QDomText contactPersonText;
296 if ( !contactPerson.isEmpty() )
298 contactPersonText = doc.createTextNode( contactPerson );
302 contactPersonText = doc.createTextNode( u
"unknown"_s );
304 QDomElement contactPersonElem = doc.createElement( u
"ContactPerson"_s );
305 contactPersonElem.appendChild( contactPersonText );
306 contactPersonPrimaryElem.appendChild( contactPersonElem );
308 QDomText contactOrganizationText;
309 if ( !contactOrganization.isEmpty() )
311 contactOrganizationText = doc.createTextNode( contactOrganization );
315 contactOrganizationText = doc.createTextNode( u
"unknown"_s );
317 QDomElement contactOrganizationElem = doc.createElement( u
"ContactOrganization"_s );
318 contactOrganizationElem.appendChild( contactOrganizationText );
319 contactPersonPrimaryElem.appendChild( contactOrganizationElem );
321 contactInfoElem.appendChild( contactPersonPrimaryElem );
324 if ( !contactPosition.isEmpty() )
326 QDomElement contactPositionElem = doc.createElement( u
"ContactPosition"_s );
327 QDomText contactPositionText = doc.createTextNode( contactPosition );
328 contactPositionElem.appendChild( contactPositionText );
329 contactInfoElem.appendChild( contactPositionElem );
332 if ( !contactPhone.isEmpty() )
334 QDomElement phoneElem = doc.createElement( u
"ContactVoiceTelephone"_s );
335 QDomText phoneText = doc.createTextNode( contactPhone );
336 phoneElem.appendChild( phoneText );
337 contactInfoElem.appendChild( phoneElem );
340 if ( !contactMail.isEmpty() )
342 QDomElement mailElem = doc.createElement( u
"ContactElectronicMailAddress"_s );
343 QDomText mailText = doc.createTextNode( contactMail );
344 mailElem.appendChild( mailText );
345 contactInfoElem.appendChild( mailElem );
348 serviceElem.appendChild( contactInfoElem );
351 QDomElement feesElem = doc.createElement( u
"Fees"_s );
352 QDomText feesText = doc.createTextNode( u
"None"_s );
354 if ( !fees.isEmpty() )
356 feesText = doc.createTextNode( fees );
358 feesElem.appendChild( feesText );
359 serviceElem.appendChild( feesElem );
361 QDomElement accessConstraintsElem = doc.createElement( u
"AccessConstraints"_s );
362 QDomText accessConstraintsText = doc.createTextNode( u
"None"_s );
364 if ( !accessConstraints.isEmpty() )
366 accessConstraintsText = doc.createTextNode( accessConstraints );
368 accessConstraintsElem.appendChild( accessConstraintsText );
369 serviceElem.appendChild( accessConstraintsElem );
376 QDomElement maxWidthElem = doc.createElement( u
"MaxWidth"_s );
377 QDomText maxWidthText = doc.createTextNode( QString::number( maxWidth ) );
378 maxWidthElem.appendChild( maxWidthText );
379 serviceElem.appendChild( maxWidthElem );
385 QDomElement maxHeightElem = doc.createElement( u
"MaxHeight"_s );
386 QDomText maxHeightText = doc.createTextNode( QString::number( maxHeight ) );
387 maxHeightElem.appendChild( maxHeightText );
388 serviceElem.appendChild( maxHeightElem );
403 QString hrefString = href.toString();
404 hrefString.append( href.hasQuery() ?
"&" :
"?" );
406 QDomElement capabilityElem = doc.createElement( u
"Capability"_s );
409 QDomElement requestElem = doc.createElement( u
"Request"_s );
410 capabilityElem.appendChild( requestElem );
412 QDomElement dcpTypeElem = doc.createElement( u
"DCPType"_s );
413 QDomElement httpElem = doc.createElement( u
"HTTP"_s );
414 dcpTypeElem.appendChild( httpElem );
417 std::function<void( QDomElement &,
const QString & )> appendFormat = [&doc]( QDomElement &elem,
const QString &format ) {
418 QDomElement formatElem = doc.createElement( u
"Format"_s );
419 formatElem.appendChild( doc.createTextNode( format ) );
420 elem.appendChild( formatElem );
426 elem = doc.createElement( u
"GetCapabilities"_s );
427 appendFormat( elem, ( version ==
"1.1.1"_L1 ?
"application/vnd.ogc.wms_xml" :
"text/xml" ) );
428 elem.appendChild( dcpTypeElem );
429 requestElem.appendChild( elem );
432 QDomElement getElem = doc.createElement( u
"Get"_s );
433 httpElem.appendChild( getElem );
434 QDomElement olResourceElem = doc.createElement( u
"OnlineResource"_s );
435 olResourceElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
436 olResourceElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
437 olResourceElem.setAttribute( u
"xlink:href"_s, hrefString );
438 getElem.appendChild( olResourceElem );
441 elem = doc.createElement( u
"GetMap"_s );
442 appendFormat( elem, u
"image/png"_s );
443 appendFormat( elem, u
"image/png; mode=16bit"_s );
444 appendFormat( elem, u
"image/png; mode=8bit"_s );
445 appendFormat( elem, u
"image/png; mode=1bit"_s );
446 appendFormat( elem, u
"image/jpeg"_s );
447 appendFormat( elem, u
"application/dxf"_s );
448 appendFormat( elem, u
"application/pdf"_s );
449 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
450 requestElem.appendChild( elem );
453 elem = doc.createElement( u
"GetFeatureInfo"_s );
454 appendFormat( elem, u
"text/plain"_s );
455 appendFormat( elem, u
"text/html"_s );
456 appendFormat( elem, u
"text/xml"_s );
457 appendFormat( elem, u
"application/vnd.ogc.gml"_s );
458 appendFormat( elem, u
"application/vnd.ogc.gml/3.1.1"_s );
459 appendFormat( elem, u
"application/json"_s );
460 appendFormat( elem, u
"application/geo+json"_s );
461 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
462 requestElem.appendChild( elem );
465 elem = doc.createElement( ( version ==
"1.1.1"_L1 ?
"GetLegendGraphic" :
"sld:GetLegendGraphic" ) );
466 appendFormat( elem, u
"image/jpeg"_s );
467 appendFormat( elem, u
"image/png"_s );
468 appendFormat( elem, u
"application/json"_s );
469 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
470 requestElem.appendChild( elem );
473 elem = doc.createElement( ( version ==
"1.1.1"_L1 ?
"DescribeLayer" :
"sld:DescribeLayer" ) );
474 appendFormat( elem, u
"text/xml"_s );
475 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
476 requestElem.appendChild( elem );
479 elem = doc.createElement( ( version ==
"1.1.1"_L1 ?
"GetStyles" :
"qgs:GetStyles" ) );
480 appendFormat( elem, u
"text/xml"_s );
481 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
482 requestElem.appendChild( elem );
487 elem = doc.createElement( u
"GetPrint"_s );
488 appendFormat( elem, u
"svg"_s );
489 appendFormat( elem, u
"png"_s );
490 appendFormat( elem, u
"pdf"_s );
491 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
492 requestElem.appendChild( elem );
496 elem = doc.createElement( u
"Exception"_s );
497 appendFormat( elem, ( version ==
"1.1.1"_L1 ?
"application/vnd.ogc.se_xml" :
"XML" ) );
498 capabilityElem.appendChild( elem );
501 if ( version ==
"1.3.0"_L1 )
503 elem = doc.createElement( u
"sld:UserDefinedSymbolization"_s );
504 elem.setAttribute( u
"SupportSLD"_s, u
"1"_s );
505 elem.setAttribute( u
"UserLayer"_s, u
"0"_s );
506 elem.setAttribute( u
"UserStyle"_s, u
"1"_s );
507 elem.setAttribute( u
"RemoteWFS"_s, u
"0"_s );
508 elem.setAttribute( u
"InlineFeature"_s, u
"0"_s );
509 elem.setAttribute( u
"RemoteWCS"_s, u
"0"_s );
510 capabilityElem.appendChild( elem );
518 return capabilityElem;
523 QDomElement inspireCapabilitiesElem;
526 return inspireCapabilitiesElem;
528 inspireCapabilitiesElem = doc.createElement( u
"inspire_vs:ExtendedCapabilities"_s );
532 if ( !inspireMetadataUrl.isEmpty() )
534 QDomElement inspireCommonMetadataUrlElem = doc.createElement( u
"inspire_common:MetadataUrl"_s );
535 inspireCommonMetadataUrlElem.setAttribute( u
"xsi:type"_s, u
"inspire_common:resourceLocatorType"_s );
537 QDomElement inspireCommonMetadataUrlUrlElem = doc.createElement( u
"inspire_common:URL"_s );
538 inspireCommonMetadataUrlUrlElem.appendChild( doc.createTextNode( inspireMetadataUrl ) );
539 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlUrlElem );
542 if ( !inspireMetadataUrlType.isNull() )
544 QDomElement inspireCommonMetadataUrlMediaTypeElem = doc.createElement( u
"inspire_common:MediaType"_s );
545 inspireCommonMetadataUrlMediaTypeElem.appendChild( doc.createTextNode( inspireMetadataUrlType ) );
546 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlMediaTypeElem );
549 inspireCapabilitiesElem.appendChild( inspireCommonMetadataUrlElem );
553 QDomElement inspireCommonResourceTypeElem = doc.createElement( u
"inspire_common:ResourceType"_s );
554 inspireCommonResourceTypeElem.appendChild( doc.createTextNode( u
"service"_s ) );
555 inspireCapabilitiesElem.appendChild( inspireCommonResourceTypeElem );
557 QDomElement inspireCommonSpatialDataServiceTypeElem = doc.createElement( u
"inspire_common:SpatialDataServiceType"_s );
558 inspireCommonSpatialDataServiceTypeElem.appendChild( doc.createTextNode( u
"view"_s ) );
559 inspireCapabilitiesElem.appendChild( inspireCommonSpatialDataServiceTypeElem );
562 if ( !inspireTemporalReference.isNull() )
564 QDomElement inspireCommonTemporalReferenceElem = doc.createElement( u
"inspire_common:TemporalReference"_s );
565 QDomElement inspireCommonDateOfLastRevisionElem = doc.createElement( u
"inspire_common:DateOfLastRevision"_s );
566 inspireCommonDateOfLastRevisionElem.appendChild( doc.createTextNode( inspireTemporalReference ) );
567 inspireCommonTemporalReferenceElem.appendChild( inspireCommonDateOfLastRevisionElem );
568 inspireCapabilitiesElem.appendChild( inspireCommonTemporalReferenceElem );
571 QDomElement inspireCommonMetadataPointOfContactElem = doc.createElement( u
"inspire_common:MetadataPointOfContact"_s );
574 QDomElement inspireCommonOrganisationNameElem = doc.createElement( u
"inspire_common:OrganisationName"_s );
575 if ( !contactOrganization.isNull() )
577 inspireCommonOrganisationNameElem.appendChild( doc.createTextNode( contactOrganization ) );
579 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonOrganisationNameElem );
582 QDomElement inspireCommonEmailAddressElem = doc.createElement( u
"inspire_common:EmailAddress"_s );
583 if ( !contactMail.isNull() )
585 inspireCommonEmailAddressElem.appendChild( doc.createTextNode( contactMail ) );
587 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonEmailAddressElem );
589 inspireCapabilitiesElem.appendChild( inspireCommonMetadataPointOfContactElem );
592 if ( !inspireMetadataDate.isNull() )
594 QDomElement inspireCommonMetadataDateElem = doc.createElement( u
"inspire_common:MetadataDate"_s );
595 inspireCommonMetadataDateElem.appendChild( doc.createTextNode( inspireMetadataDate ) );
596 inspireCapabilitiesElem.appendChild( inspireCommonMetadataDateElem );
601 QDomElement inspireCommonSupportedLanguagesElem = doc.createElement( u
"inspire_common:SupportedLanguages"_s );
602 inspireCommonSupportedLanguagesElem.setAttribute( u
"xsi:type"_s, u
"inspire_common:supportedLanguagesType"_s );
604 QDomElement inspireCommonLanguageElem = doc.createElement( u
"inspire_common:Language"_s );
607 QDomElement inspireCommonDefaultLanguageElem = doc.createElement( u
"inspire_common:DefaultLanguage"_s );
608 inspireCommonDefaultLanguageElem.appendChild( inspireCommonLanguageElem );
609 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonDefaultLanguageElem );
613 QDomElement inspireCommonSupportedLanguageElem = doc.createElement(
"inspire_common:SupportedLanguage" );
614 inspireCommonSupportedLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
615 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonSupportedLanguageElem );
618 inspireCapabilitiesElem.appendChild( inspireCommonSupportedLanguagesElem );
620 QDomElement inspireCommonResponseLanguageElem = doc.createElement( u
"inspire_common:ResponseLanguage"_s );
621 inspireCommonResponseLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
622 inspireCapabilitiesElem.appendChild( inspireCommonResponseLanguageElem );
624 return inspireCapabilitiesElem;
630 if ( projectComposers.size() == 0 )
631 return QDomElement();
635 QDomElement composerTemplatesElem = doc.createElement( u
"ComposerTemplates"_s );
636 QList<QgsPrintLayout *>::const_iterator cIt = projectComposers.constBegin();
637 for ( ; cIt != projectComposers.constEnd(); ++cIt )
640 if ( restrictedComposers.contains( layout->
name() ) )
652 QDomElement composerTemplateElem = doc.createElement( u
"ComposerTemplate"_s );
653 composerTemplateElem.setAttribute( u
"name"_s, layout->
name() );
656 composerTemplateElem.setAttribute( u
"width"_s, width.
length() );
657 composerTemplateElem.setAttribute( u
"height"_s, height.
length() );
661 if ( atlas && atlas->
enabled() )
663 composerTemplateElem.setAttribute( u
"atlasEnabled"_s, u
"1"_s );
670 layerName = cLayer->
id();
672 else if ( layerName.isEmpty() )
674 layerName = cLayer->
name();
676 composerTemplateElem.setAttribute( u
"atlasCoverageLayer"_s, layerName );
681 QList<QgsLayoutItemMap *> layoutMapList;
683 QList<QgsLayoutItemMap *>::const_iterator cmIt = layoutMapList.constBegin();
686 for ( ; cmIt != layoutMapList.constEnd(); ++cmIt )
690 QDomElement composerMapElem = doc.createElement( u
"ComposerMap"_s );
691 composerMapElem.setAttribute( u
"name"_s, u
"map%1"_s.arg( mapId ) );
692 composerMapElem.setAttribute( u
"itemName"_s, composerMap->
displayName() );
694 composerMapElem.setAttribute( u
"width"_s, composerMap->rect().width() );
695 composerMapElem.setAttribute( u
"height"_s, composerMap->rect().height() );
696 composerTemplateElem.appendChild( composerMapElem );
700 QList<QgsLayoutItemLabel *> composerLabelList;
702 QList<QgsLayoutItemLabel *>::const_iterator clIt = composerLabelList.constBegin();
703 for ( ; clIt != composerLabelList.constEnd(); ++clIt )
706 QString
id = composerLabel->
id();
710 QDomElement composerLabelElem = doc.createElement( u
"ComposerLabel"_s );
711 composerLabelElem.setAttribute( u
"name"_s,
id );
712 composerTemplateElem.appendChild( composerLabelElem );
716 QList<QgsLayoutItemHtml *> composerHtmlList;
718 QList<QgsLayoutItemHtml *>::const_iterator chIt = composerHtmlList.constBegin();
719 for ( ; chIt != composerHtmlList.constEnd(); ++chIt )
725 QString
id = composerHtml->
frame( 0 )->
id();
729 QDomElement composerHtmlElem = doc.createElement( u
"ComposerHtml"_s );
730 composerHtmlElem.setAttribute( u
"name"_s,
id );
731 composerTemplateElem.appendChild( composerHtmlElem );
734 composerTemplatesElem.appendChild( composerTemplateElem );
737 if ( composerTemplatesElem.childNodes().size() == 0 )
738 return QDomElement();
740 return composerTemplatesElem;
746 if ( wfsLayerIds.size() == 0 )
747 return QDomElement();
749 QDomElement wfsLayersElem = doc.createElement( u
"WFSLayers"_s );
750 for (
int i = 0; i < wfsLayerIds.size(); ++i )
758 QDomElement wfsLayerElem = doc.createElement( u
"WFSLayer"_s );
761 wfsLayerElem.setAttribute( u
"name"_s, layer->
id() );
765 wfsLayerElem.setAttribute( u
"name"_s, layer->
name() );
767 wfsLayersElem.appendChild( wfsLayerElem );
770 return wfsLayersElem;
775 QDomElement &parentLayer,
780 const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos,
786 parentLayer.setAttribute( u
"queryable"_s,
hasQueryableLayers( layerIds, wmsLayerInfos ) ? u
"1"_s : u
"0"_s );
789 QMap<QString, QgsRectangle> crsExtents =
combineCrsExtents( layerIds, wmsLayerInfos );
791 appendCrsElementsToLayer( doc, parentLayer, crsExtents.keys(), QStringList(), !wgs84BoundingRect.
isNull() );
792 appendLayerWgs84BoundingRect( doc, parentLayer, wgs84BoundingRect );
793 appendLayerCrsExtents( doc, parentLayer, crsExtents );
797 appendLayersFromTreeGroup( doc, parentLayer, serverIface, project, request, layerTreeGroup, wmsLayerInfos, projectSettings );
804 QDomElement layerParentElem = doc.createElement( u
"Layer"_s );
807 if ( !skipNameForGroup )
811 if ( rootLayerName.isEmpty() && !project->
title().isEmpty() )
813 rootLayerName = project->
title();
816 if ( !rootLayerName.isEmpty() )
818 QDomElement layerParentNameElem = doc.createElement( u
"Name"_s );
819 QDomText layerParentNameText = doc.createTextNode( rootLayerName );
820 layerParentNameElem.appendChild( layerParentNameText );
821 layerParentElem.appendChild( layerParentNameElem );
826 QDomElement layerParentTitleElem = doc.createElement( u
"Title"_s );
828 layerParentTitleElem.appendChild( layerParentTitleText );
829 layerParentElem.appendChild( layerParentTitleElem );
833 if ( !rootLayerAbstract.isEmpty() )
835 QDomElement layerParentAbstElem = doc.createElement( u
"Abstract"_s );
836 QDomText layerParentAbstText = doc.createCDATASection( rootLayerAbstract );
837 layerParentAbstElem.appendChild( layerParentAbstText );
838 layerParentElem.appendChild( layerParentAbstElem );
842 addKeywordListElement( project, doc, layerParentElem );
845 if ( projectSettings )
847 QDomElement treeNameElem = doc.createElement( u
"TreeName"_s );
848 QDomText treeNameText = doc.createTextNode( project->
title() );
849 treeNameElem.appendChild( treeNameText );
850 layerParentElem.appendChild( treeNameElem );
856 auto outputCrsList = QList<QgsCoordinateReferenceSystem>();
862 outputCrsList.append( crs );
890 QMap<QString, QgsRectangle> wmsCrsExtents;
902 appendCrsElementsToLayer( doc, layerParentElem, wmsCrsExtents.keys(), QStringList(), project->
crs().
isEarthCrs() );
903 appendLayerWgs84BoundingRect( doc, layerParentElem, wmsWgs84BoundingRect );
904 appendLayerCrsExtents( doc, layerParentElem, wmsCrsExtents );
906 appendLayersFromTreeGroup( doc, layerParentElem, serverIface, project, request, projectLayerTreeRoot, wmsLayerInfos, projectSettings );
910 handleLayersFromTreeGroup( doc, layerParentElem, serverIface, project, request, projectLayerTreeRoot, wmsLayerInfos, projectSettings );
913 return layerParentElem;
921 void writeServerProperties( QDomDocument &doc, QDomElement &layerElem,
const QgsProject *project,
const QgsMapLayerServerProperties *serverProperties,
const QString &name,
const QString &version )
923 const QString title = serverProperties->
title();
924 QDomElement titleElem = doc.createElement( u
"Title"_s );
925 QDomText titleText = doc.createTextNode( !title.isEmpty() ? title : name );
926 titleElem.appendChild( titleText );
927 layerElem.appendChild( titleElem );
929 const QString abstract = serverProperties->
abstract();
930 if ( !abstract.isEmpty() )
932 QDomElement abstractElem = doc.createElement( u
"Abstract"_s );
933 QDomText abstractText = doc.createTextNode( abstract );
934 abstractElem.appendChild( abstractText );
935 layerElem.appendChild( abstractElem );
940 const QStringList keywords = !serverProperties->
keywordList().isEmpty() ? serverProperties->
keywordList().split(
',' ) : QStringList();
941 if ( !keywords.isEmpty() )
943 QDomElement keywordListElem = doc.createElement( u
"KeywordList"_s );
944 for (
const QString &keyword : std::as_const( keywords ) )
946 QDomElement keywordElem = doc.createElement( u
"Keyword"_s );
947 QDomText keywordText = doc.createTextNode( keyword.trimmed() );
948 keywordElem.appendChild( keywordText );
951 keywordElem.setAttribute( u
"vocabulary"_s, u
"SIA_Geo405"_s );
953 keywordListElem.appendChild( keywordElem );
955 layerElem.appendChild( keywordListElem );
959 const QString dataUrl = serverProperties->
dataUrl();
960 if ( !dataUrl.isEmpty() )
962 QDomElement dataUrlElem = doc.createElement( u
"DataURL"_s );
963 QDomElement dataUrlFormatElem = doc.createElement( u
"Format"_s );
964 const QString dataUrlFormat = serverProperties->
dataUrlFormat();
965 QDomText dataUrlFormatText = doc.createTextNode( dataUrlFormat );
966 dataUrlFormatElem.appendChild( dataUrlFormatText );
967 dataUrlElem.appendChild( dataUrlFormatElem );
968 QDomElement dataORElem = doc.createElement( u
"OnlineResource"_s );
969 dataORElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
970 dataORElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
971 dataORElem.setAttribute( u
"xlink:href"_s, dataUrl );
972 dataUrlElem.appendChild( dataORElem );
973 layerElem.appendChild( dataUrlElem );
977 const QString attribution = serverProperties->
attribution();
978 if ( !attribution.isEmpty() )
980 QDomElement attribElem = doc.createElement( u
"Attribution"_s );
981 QDomElement attribTitleElem = doc.createElement( u
"Title"_s );
982 QDomText attribText = doc.createTextNode( attribution );
983 attribTitleElem.appendChild( attribText );
984 attribElem.appendChild( attribTitleElem );
985 const QString attributionUrl = serverProperties->
attributionUrl();
986 if ( !attributionUrl.isEmpty() )
988 QDomElement attribORElem = doc.createElement( u
"OnlineResource"_s );
989 attribORElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
990 attribORElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
991 attribORElem.setAttribute( u
"xlink:href"_s, attributionUrl );
992 attribElem.appendChild( attribORElem );
994 layerElem.appendChild( attribElem );
998 const QList<QgsServerMetadataUrlProperties::MetadataUrl> metadataUrls = serverProperties->
metadataUrls();
999 for (
const QgsMapLayerServerProperties::MetadataUrl &metadataUrl : std::as_const( metadataUrls ) )
1001 QDomElement metaUrlElem = doc.createElement( u
"MetadataURL"_s );
1002 const QString metadataUrlType = metadataUrl.type;
1003 if ( version ==
"1.1.1"_L1 )
1005 metaUrlElem.setAttribute( u
"type"_s, metadataUrlType );
1007 else if ( metadataUrlType ==
"FGDC"_L1 )
1009 metaUrlElem.setAttribute( u
"type"_s, u
"FGDC:1998"_s );
1011 else if ( metadataUrlType ==
"TC211"_L1 )
1013 metaUrlElem.setAttribute( u
"type"_s, u
"ISO19115:2003"_s );
1017 metaUrlElem.setAttribute( u
"type"_s, metadataUrlType );
1019 const QString metadataUrlFormat = metadataUrl.format;
1020 if ( !metadataUrlFormat.isEmpty() )
1022 QDomElement metaUrlFormatElem = doc.createElement( u
"Format"_s );
1023 QDomText metaUrlFormatText = doc.createTextNode( metadataUrlFormat );
1024 metaUrlFormatElem.appendChild( metaUrlFormatText );
1025 metaUrlElem.appendChild( metaUrlFormatElem );
1027 QDomElement metaUrlORElem = doc.createElement( u
"OnlineResource"_s );
1028 metaUrlORElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
1029 metaUrlORElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
1030 metaUrlORElem.setAttribute( u
"xlink:href"_s, metadataUrl.url );
1031 metaUrlElem.appendChild( metaUrlORElem );
1032 layerElem.appendChild( metaUrlElem );
1036 void writeLegendUrl(
1038 QDomElement &styleElem,
1039 const QString &legendUrl,
1040 const QString &legendUrlFormat,
1041 const QString &name,
1042 const QString &styleName,
1043 const QgsProject *project,
1045 const QgsServerSettings *settings
1049 QDomElement getLayerLegendGraphicElem = doc.createElement( u
"LegendURL"_s );
1051 QString customHrefString = legendUrl;
1053 QStringList getLayerLegendGraphicFormats;
1054 if ( !customHrefString.isEmpty() )
1056 getLayerLegendGraphicFormats << legendUrlFormat;
1060 getLayerLegendGraphicFormats << u
"image/png"_s;
1063 for (
const QString &getLayerLegendGraphicFormat : std::as_const( getLayerLegendGraphicFormats ) )
1065 QDomElement getLayerLegendGraphicFormatElem = doc.createElement( u
"Format"_s );
1066 QDomText getLayerLegendGraphicFormatText = doc.createTextNode( getLayerLegendGraphicFormat );
1067 getLayerLegendGraphicFormatElem.appendChild( getLayerLegendGraphicFormatText );
1068 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicFormatElem );
1072 if ( customHrefString.isEmpty() )
1075 QUrl href =
serviceUrl( request, project, *settings );
1076 const QString hrefString = href.toString() + ( href.hasQuery() ?
"&" :
"?" );
1078 QUrl mapUrl( hrefString );
1079 QUrlQuery mapUrlQuery( mapUrl.query() );
1080 mapUrlQuery.addQueryItem( u
"SERVICE"_s, u
"WMS"_s );
1081 mapUrlQuery.addQueryItem( u
"VERSION"_s, request.wmsParameters().version() );
1082 mapUrlQuery.addQueryItem( u
"REQUEST"_s, u
"GetLegendGraphic"_s );
1083 mapUrlQuery.addQueryItem( u
"LAYER"_s, name );
1084 mapUrlQuery.addQueryItem( u
"FORMAT"_s, u
"image/png"_s );
1085 mapUrlQuery.addQueryItem( u
"STYLE"_s, styleName );
1086 if ( request.wmsParameters().version() ==
"1.3.0"_L1 )
1088 mapUrlQuery.addQueryItem( u
"SLD_VERSION"_s, u
"1.1.0"_s );
1090 mapUrl.setQuery( mapUrlQuery );
1091 customHrefString = mapUrl.toString();
1094 QDomElement getLayerLegendGraphicORElem = doc.createElement( u
"OnlineResource"_s );
1095 getLayerLegendGraphicORElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
1096 getLayerLegendGraphicORElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
1097 getLayerLegendGraphicORElem.setAttribute( u
"xlink:href"_s, customHrefString );
1098 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicORElem );
1099 styleElem.appendChild( getLayerLegendGraphicElem );
1102 QDomElement createStyleElement( QDomDocument &doc,
const QString &styleName )
1104 QDomElement styleElem = doc.createElement( u
"Style"_s );
1105 QDomElement styleNameElem = doc.createElement( u
"Name"_s );
1106 QDomText styleNameText = doc.createTextNode( styleName );
1107 styleNameElem.appendChild( styleNameText );
1108 QDomElement styleTitleElem = doc.createElement( u
"Title"_s );
1109 QDomText styleTitleText = doc.createTextNode( styleName );
1110 styleTitleElem.appendChild( styleTitleText );
1111 styleElem.appendChild( styleNameElem );
1112 styleElem.appendChild( styleTitleElem );
1120 QString dateToString(
const QDateTime &dateTime,
bool dateOnly )
1122 return dateOnly ? dateTime.date().toString( Qt::DateFormat::ISODate ) : dateTime.toString( Qt::DateFormat::ISODate );
1129 void getChildrenRanges(
const QgsLayerTreeGroup *layerTreeGroup,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos,
const QStringList &restrictedLayers, QList<QgsDateTimeRange> &dateRanges )
1131 QList<QgsLayerTreeNode *> layerTreeGroupChildren = layerTreeGroup->
children();
1132 for (
int i = 0; i < layerTreeGroupChildren.size(); ++i )
1134 QgsLayerTreeNode *treeNode = layerTreeGroupChildren.at( i );
1138 QgsLayerTreeGroup *treeGroupChild =
static_cast<QgsLayerTreeGroup *
>( treeNode );
1139 if ( !restrictedLayers.contains( treeGroupChild->
name() )
1142 QList<QgsDateTimeRange> childrenDateRanges;
1143 getChildrenRanges( treeGroupChild, wmsLayerInfos, restrictedLayers, childrenDateRanges );
1144 dateRanges.append( childrenDateRanges );
1149 QgsLayerTreeLayer *treeLayer =
static_cast<QgsLayerTreeLayer *
>( treeNode );
1150 QgsMapLayer *l = treeLayer->
layer();
1152 if ( wmsLayerInfos.contains( treeLayer->
layerId() )
1158 dateRanges.append( allRanges );
1165 bool writeTimeDimensionNode( QDomDocument &doc, QDomElement &layerElem,
const QList<QgsDateTimeRange> &dateRanges )
1173 const bool dateOnly = std::all_of( dateRanges.constBegin(), dateRanges.constEnd(), [](
const QgsDateTimeRange &r ) {
1174 return r.begin().time() == QTime( 0, 0 ) && ( r.isInstant() || r.end().time() == QTime( 0, 0 ) );
1177 QStringList strValues;
1181 if ( range.begin().isValid() && range.end().isValid() )
1183 strValues << ( range.isInstant() ? dateToString( range.begin(), dateOnly ) : u
"%1/%2"_s.arg( dateToString( range.begin(), dateOnly ) ).arg( dateToString( range.end(), dateOnly ) ) );
1187 QDomElement dimElem = doc.createElement( u
"Dimension"_s );
1188 dimElem.setAttribute( u
"name"_s, u
"TIME"_s );
1189 dimElem.setAttribute( u
"units"_s, u
"ISO8601"_s );
1190 QDomText dimValuesText = doc.createTextNode( strValues.join( QChar(
',' ) ) );
1191 dimElem.appendChild( dimValuesText );
1193 layerElem.appendChild( dimElem );
1198 void appendLayersFromTreeGroup(
1200 QDomElement &parentLayer,
1201 QgsServerInterface *serverIface,
1202 const QgsProject *project,
1204 const QgsLayerTreeGroup *layerTreeGroup,
1205 const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos,
1206 bool projectSettings
1209 const QString version = request.wmsParameters().version();
1214 QList<QgsLayerTreeNode *> layerTreeGroupChildren = layerTreeGroup->
children();
1215 for (
int i = 0; i < layerTreeGroupChildren.size(); ++i )
1217 QgsLayerTreeNode *treeNode = layerTreeGroupChildren.at( i );
1218 QDomElement layerElem = doc.createElement( u
"Layer"_s );
1220 if ( projectSettings )
1222 layerElem.setAttribute( u
"visible"_s, treeNode->
isVisible() );
1224 layerElem.setAttribute( u
"expanded"_s, treeNode->
isExpanded() );
1229 QgsLayerTreeGroup *treeGroupChild =
static_cast<QgsLayerTreeGroup *
>( treeNode );
1231 QString name = treeGroupChild->
name();
1232 if ( restrictedLayers.contains( name ) )
1237 if ( projectSettings )
1245 if ( !skipNameForGroup )
1247 QDomElement nameElem = doc.createElement( u
"Name"_s );
1249 if ( !shortName.isEmpty() )
1250 nameText = doc.createTextNode( shortName );
1252 nameText = doc.createTextNode( name );
1253 nameElem.appendChild( nameText );
1254 layerElem.appendChild( nameElem );
1257 writeServerProperties( doc, layerElem, project, treeGroupChild->
serverProperties(), name, version );
1260 if ( projectSettings )
1262 QDomElement treeNameElem = doc.createElement( u
"TreeName"_s );
1263 QDomText treeNameText = doc.createTextNode( name );
1264 treeNameElem.appendChild( treeNameText );
1265 layerElem.appendChild( treeNameElem );
1268 handleLayersFromTreeGroup( doc, layerElem, serverIface, project, request, treeGroupChild, wmsLayerInfos, projectSettings );
1272 QList<QgsDateTimeRange> childrenDateRanges;
1273 getChildrenRanges( treeGroupChild, wmsLayerInfos, restrictedLayers, childrenDateRanges );
1274 writeTimeDimensionNode( doc, layerElem, childrenDateRanges );
1285 QgsLayerTreeLayer *treeLayer =
static_cast<QgsLayerTreeLayer *
>( treeNode );
1286 QgsMapLayer *l = treeLayer->
layer();
1287 if ( !wmsLayerInfos.contains( treeLayer->
layerId() ) )
1292 const QgsWmsLayerInfos &layerInfos = wmsLayerInfos[treeLayer->
layerId()];
1294 layerElem.setAttribute( u
"queryable"_s, layerInfos.
queryable ? u
"1"_s : u
"0"_s );
1296 QDomElement nameElem = doc.createElement( u
"Name"_s );
1297 QDomText nameText = doc.createTextNode( layerInfos.
name );
1298 nameElem.appendChild( nameText );
1299 layerElem.appendChild( nameElem );
1306 appendCrsElementsToLayer( doc, layerElem, layerInfos.
crsExtents.keys(), QStringList(), l->
crs().
isEarthCrs() );
1310 appendLayerCrsExtents( doc, layerElem, layerInfos.
crsExtents );
1314 appendLayerStyles( doc, layerElem, layerInfos, project, request, serverIface->
serverSettings() );
1320 auto formatScale = [](
double value ) {
1321 const thread_local QRegularExpression trailingZeroRegEx = QRegularExpression( u
"0+$"_s );
1322 const thread_local QRegularExpression trailingPointRegEx = QRegularExpression( u
"[.]+$"_s );
1323 return QString::number( value,
'f' ).remove( trailingZeroRegEx ).remove( trailingPointRegEx );
1326 if ( version ==
"1.1.1"_L1 )
1329 double SCALE_TO_SCALEHINT =
OGC_PX_M * M_SQRT2;
1331 QDomElement scaleHintElem = doc.createElement( u
"ScaleHint"_s );
1332 scaleHintElem.setAttribute( u
"min"_s, formatScale( layerInfos.
maxScale * SCALE_TO_SCALEHINT ) );
1333 scaleHintElem.setAttribute( u
"max"_s, formatScale( layerInfos.
minScale * SCALE_TO_SCALEHINT ) );
1334 layerElem.appendChild( scaleHintElem );
1338 QDomElement minScaleElem = doc.createElement( u
"MinScaleDenominator"_s );
1339 QDomText minScaleText = doc.createTextNode( formatScale( layerInfos.
maxScale ) );
1340 minScaleElem.appendChild( minScaleText );
1341 layerElem.appendChild( minScaleElem );
1343 QDomElement maxScaleElem = doc.createElement( u
"MaxScaleDenominator"_s );
1344 QDomText maxScaleText = doc.createTextNode( formatScale( layerInfos.
minScale ) );
1345 maxScaleElem.appendChild( maxScaleText );
1346 layerElem.appendChild( maxScaleElem );
1350 bool timeDimensionAdded {
false };
1355 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( l );
1356 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( vl->
serverProperties() );
1357 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> wmsDims = serverProperties->
wmsDimensions();
1358 for (
const QgsMapLayerServerProperties::WmsDimensionInfo &dim : wmsDims )
1362 if ( fieldIndex == -1 )
1367 QSet<QVariant> uniqueValues = vl->
uniqueValues( fieldIndex );
1370 if ( !dim.endFieldName.isEmpty() )
1372 int endFieldIndex = vl->
fields().
indexOf( dim.endFieldName );
1374 if ( endFieldIndex == -1 )
1378 uniqueValues.unite( vl->
uniqueValues( endFieldIndex ) );
1381 QList<QVariant> values = qgis::setToList( uniqueValues );
1382 std::sort( values.begin(), values.end() );
1384 QDomElement dimElem = doc.createElement( u
"Dimension"_s );
1385 dimElem.setAttribute( u
"name"_s, dim.name );
1387 if ( dim.name.toUpper() ==
"TIME"_L1 )
1389 timeDimensionAdded =
true;
1392 if ( !dim.units.isEmpty() )
1394 dimElem.setAttribute( u
"units"_s, dim.units );
1396 if ( !dim.unitSymbol.isEmpty() )
1398 dimElem.setAttribute( u
"unitSymbol"_s, dim.unitSymbol );
1402 dimElem.setAttribute( u
"default"_s, values.first().toString() );
1406 dimElem.setAttribute( u
"default"_s, values.last().toString() );
1410 dimElem.setAttribute( u
"default"_s, dim.referenceValue().toString() );
1412 dimElem.setAttribute( u
"multipleValues"_s, u
"1"_s );
1413 dimElem.setAttribute( u
"nearestValue"_s, u
"0"_s );
1414 if ( projectSettings )
1416 dimElem.setAttribute( u
"fieldName"_s, dim.fieldName );
1417 dimElem.setAttribute( u
"endFieldName"_s, dim.endFieldName );
1420 QStringList strValues;
1421 for (
const QVariant &v : values )
1423 strValues << v.toString();
1425 QDomText dimValuesText = doc.createTextNode( strValues.join(
", "_L1 ) );
1426 dimElem.appendChild( dimValuesText );
1427 layerElem.appendChild( dimElem );
1438 const bool dateOnly = writeTimeDimensionNode( doc, layerElem, allRanges );
1440 QDomElement timeExtentElem = doc.createElement( u
"Extent"_s );
1441 timeExtentElem.setAttribute( u
"name"_s, u
"TIME"_s );
1444 const QString extent = u
"%1/%2"_s.arg( dateToString( timeExtent.
begin(), dateOnly ) ).arg( dateToString( timeExtent.
end(), dateOnly ) );
1445 QDomText extentValueText = doc.createTextNode( extent );
1446 timeExtentElem.appendChild( extentValueText );
1447 layerElem.appendChild( timeExtentElem );
1450 if ( projectSettings )
1452 appendLayerProjectSettings( doc, layerElem, l );
1456 parentLayer.appendChild( layerElem );
1460 void appendLayerStyles( QDomDocument &doc, QDomElement &layerElem,
const QgsWmsLayerInfos &layerInfos,
const QgsProject *project,
const QgsWmsRequest &request,
const QgsServerSettings *settings )
1462 for (
const QString &styleName : std::as_const( layerInfos.
styles ) )
1464 QDomElement styleElem = createStyleElement( doc, styleName );
1466 writeLegendUrl( doc, styleElem, layerInfos.
legendUrl, layerInfos.
legendUrlFormat, layerInfos.
name, styleName, project, request, settings );
1468 layerElem.appendChild( styleElem );
1472 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
const QStringList &crsList,
const QStringList &constrainedCrsList,
bool hasEarthCrs )
1474 if ( layerElement.isNull() )
1479 const QString version = doc.documentElement().attribute( u
"version"_s );
1482 QDomElement titleElement = layerElement.firstChildElement( u
"Title"_s );
1483 QDomElement abstractElement = layerElement.firstChildElement( u
"Abstract"_s );
1484 QDomElement keywordListElement = layerElement.firstChildElement( u
"KeywordList"_s );
1485 QDomElement CRSPrecedingElement = !keywordListElement.isNull() ? keywordListElement : !abstractElement.isNull() ? abstractElement : titleElement;
1487 if ( CRSPrecedingElement.isNull() )
1490 const QDomElement keyElement = layerElement.firstChildElement( u
"KeywordList"_s );
1491 CRSPrecedingElement = keyElement;
1495 if ( !constrainedCrsList.isEmpty() )
1497 for (
int i = constrainedCrsList.size() - 1; i >= 0; --i )
1499 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, constrainedCrsList.at( i ) );
1504 for (
const QString &crs : crsList )
1506 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, crs );
1512 if ( version ==
"1.3.0"_L1 && hasEarthCrs )
1514 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, QString(
"CRS:84" ) );
1518 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
const QString &crsText )
1520 if ( crsText.isEmpty() )
1522 const QString version = doc.documentElement().attribute( u
"version"_s );
1523 QDomElement crsElement = doc.createElement( version ==
"1.1.1"_L1 ?
"SRS" :
"CRS" );
1524 QDomText crsTextNode = doc.createTextNode( crsText );
1525 crsElement.appendChild( crsTextNode );
1526 layerElement.insertAfter( crsElement, precedingElement );
1529 void appendLayerWgs84BoundingRect( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &wgs84BoundingRect )
1532 if ( wgs84BoundingRect.
isNull() )
1538 QDomElement ExGeoBBoxElement;
1539 const int wgs84precision = 6;
1540 const QString version = doc.documentElement().attribute( u
"version"_s );
1541 if ( version ==
"1.1.1"_L1 )
1543 ExGeoBBoxElement = doc.createElement( u
"LatLonBoundingBox"_s );
1551 ExGeoBBoxElement = doc.createElement( u
"EX_GeographicBoundingBox"_s );
1552 QDomElement wBoundLongitudeElement = doc.createElement( u
"westBoundLongitude"_s );
1554 wBoundLongitudeElement.appendChild( wBoundLongitudeText );
1555 ExGeoBBoxElement.appendChild( wBoundLongitudeElement );
1556 QDomElement eBoundLongitudeElement = doc.createElement( u
"eastBoundLongitude"_s );
1558 eBoundLongitudeElement.appendChild( eBoundLongitudeText );
1559 ExGeoBBoxElement.appendChild( eBoundLongitudeElement );
1560 QDomElement sBoundLatitudeElement = doc.createElement( u
"southBoundLatitude"_s );
1562 sBoundLatitudeElement.appendChild( sBoundLatitudeText );
1563 ExGeoBBoxElement.appendChild( sBoundLatitudeElement );
1564 QDomElement nBoundLatitudeElement = doc.createElement( u
"northBoundLatitude"_s );
1566 nBoundLatitudeElement.appendChild( nBoundLatitudeText );
1567 ExGeoBBoxElement.appendChild( nBoundLatitudeElement );
1570 const QDomElement lastCRSElem = layerElem.lastChildElement( version ==
"1.1.1"_L1 ?
"SRS" :
"CRS" );
1571 if ( !lastCRSElem.isNull() )
1573 layerElem.insertAfter( ExGeoBBoxElement, lastCRSElem );
1577 layerElem.appendChild( ExGeoBBoxElement );
1581 void appendLayerCrsExtents( QDomDocument &doc, QDomElement &layerElem,
const QMap<QString, QgsRectangle> &crsExtents )
1583 const QString version = doc.documentElement().attribute( u
"version"_s );
1585 const auto &keys = crsExtents.keys();
1586 for (
const QString &crsText : std::as_const( keys ) )
1589 QgsRectangle crsExtent( crsExtents[crsText] );
1591 if ( crsExtent.isNull() )
1603 QDomElement bBoxElement = doc.createElement( u
"BoundingBox"_s );
1606 bBoxElement.setAttribute( version ==
"1.1.1"_L1 ?
"SRS" :
"CRS", crs.
authid() );
1619 QDomElement lastBBoxElem = layerElem.lastChildElement( u
"BoundingBox"_s );
1620 if ( !lastBBoxElem.isNull() )
1622 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1626 lastBBoxElem = layerElem.lastChildElement( version ==
"1.1.1"_L1 ?
"LatLonBoundingBox" :
"EX_GeographicBoundingBox" );
1627 if ( !lastBBoxElem.isNull() )
1629 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1633 layerElem.appendChild( bBoxElement );
1639 void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem, QgsServerInterface *serverIface,
const QgsProject *project )
1641#ifdef HAVE_SERVER_PYTHON_PLUGINS
1644 ( void ) serverIface;
1649 QStringList layerList;
1651 QHash<const QgsMapLayer *, QStringList> acceptableLayersAndRequestNames;
1654 const QgsLayerTree *projectLayerTreeRoot = project->
layerTreeRoot();
1655 QList<QgsMapLayer *> projectLayerOrder = projectLayerTreeRoot->
layerOrder();
1656 for (
int i = 0; i < projectLayerOrder.size(); ++i )
1658 QgsMapLayer *l = projectLayerOrder.at( i );
1660 if ( restrictedLayers.contains( l->
name() ) )
1666 if ( !acceptableLayersAndRequestNames.contains( l ) )
1670#ifdef HAVE_SERVER_PYTHON_PLUGINS
1676 QString wmsName = l->
name();
1686 layerList << wmsName;
1689 if ( !layerList.isEmpty() )
1691 QStringList reversedList;
1692 reversedList.reserve( layerList.size() );
1693 for (
int i = layerList.size() - 1; i >= 0; --i )
1694 reversedList << layerList[i];
1696 QDomElement layerDrawingOrderElem = doc.createElement( u
"LayerDrawingOrder"_s );
1697 QDomText drawingOrderText = doc.createTextNode( reversedList.join(
',' ) );
1698 layerDrawingOrderElem.appendChild( drawingOrderText );
1699 parentElem.appendChild( layerDrawingOrderElem );
1703 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem, QgsMapLayer *currentLayer )
1705 if ( !currentLayer )
1711 QDomElement treeNameElem = doc.createElement( u
"TreeName"_s );
1712 QDomText treeNameText = doc.createTextNode( currentLayer->
name() );
1713 treeNameElem.appendChild( treeNameText );
1714 layerElem.appendChild( treeNameElem );
1716 switch ( currentLayer->
type() )
1720 QgsVectorLayer *vLayer =
static_cast<QgsVectorLayer *
>( currentLayer );
1722 int displayFieldIdx = -1;
1723 QString displayField = u
"maptip"_s;
1725 if ( exp.isField() )
1727 displayField =
static_cast<const QgsExpressionNodeColumnRef *
>( exp.rootNode() )->name();
1732 QDomElement attributesElem = doc.createElement( u
"Attributes"_s );
1733 const QgsFields layerFields = vLayer->
fields();
1734 for (
int idx = 0; idx < layerFields.
count(); ++idx )
1736 QgsField field = layerFields.
at( idx );
1742 if ( idx == displayFieldIdx )
1746 QDomElement attributeElem = doc.createElement( u
"Attribute"_s );
1747 attributeElem.setAttribute( u
"name"_s, field.
name() );
1748 attributeElem.setAttribute( u
"type"_s, QVariant::typeToName( field.
type() ) );
1749 attributeElem.setAttribute( u
"typeName"_s, field.
typeName() );
1750 QString alias = field.
alias();
1751 if ( !alias.isEmpty() )
1753 attributeElem.setAttribute( u
"alias"_s, alias );
1758 attributeElem.setAttribute( u
"comment"_s, field.
comment() );
1759 attributeElem.setAttribute( u
"length"_s, field.
length() );
1760 attributeElem.setAttribute( u
"precision"_s, field.
precision() );
1761 attributesElem.appendChild( attributeElem );
1765 layerElem.setAttribute( u
"displayField"_s, displayField );
1769 if ( pkAttributes.size() > 0 )
1771 QDomElement pkElem = doc.createElement( u
"PrimaryKey"_s );
1772 QgsAttributeList::const_iterator pkIt = pkAttributes.constBegin();
1773 for ( ; pkIt != pkAttributes.constEnd(); ++pkIt )
1775 QDomElement pkAttributeElem = doc.createElement( u
"PrimaryKeyAttribute"_s );
1776 QDomText pkAttName = doc.createTextNode( layerFields.
at( *pkIt ).
name() );
1777 pkAttributeElem.appendChild( pkAttName );
1778 pkElem.appendChild( pkAttributeElem );
1780 layerElem.appendChild( pkElem );
1787 layerElem.setAttribute( u
"opacity"_s, QString::number( vLayer->
opacity() ) );
1789 layerElem.appendChild( attributesElem );
1795 const QgsDataProvider *provider = currentLayer->
dataProvider();
1796 if ( provider && provider->
name() ==
"wms" )
1799 QVariant wmsBackgroundLayer = currentLayer->
customProperty( u
"WMSBackgroundLayer"_s,
false );
1800 QDomElement wmsBackgroundLayerElem = doc.createElement(
"WMSBackgroundLayer" );
1801 QDomText wmsBackgroundLayerText = doc.createTextNode( wmsBackgroundLayer.toBool() ? u
"1"_s : u
"0"_s );
1802 wmsBackgroundLayerElem.appendChild( wmsBackgroundLayerText );
1803 layerElem.appendChild( wmsBackgroundLayerElem );
1806 QVariant wmsPublishDataSourceUrl = currentLayer->
customProperty( u
"WMSPublishDataSourceUrl"_s,
false );
1807 if ( wmsPublishDataSourceUrl.toBool() )
1809 bool tiled = qobject_cast<const QgsRasterDataProvider *>( provider ) ? !qobject_cast<const QgsRasterDataProvider *>( provider )->nativeResolutions().isEmpty() :
false;
1811 QDomElement dataSourceElem = doc.createElement( tiled ? u
"WMTSDataSource"_s : u
"WMSDataSource"_s );
1812 QDomText dataSourceUri = doc.createTextNode( provider->
dataSourceUri() );
1813 dataSourceElem.appendChild( dataSourceUri );
1814 layerElem.appendChild( dataSourceElem );
1818 QVariant wmsPrintLayer = currentLayer->
customProperty( u
"WMSPrintLayer"_s );
1819 if ( wmsPrintLayer.isValid() )
1821 QDomElement wmsPrintLayerElem = doc.createElement(
"WMSPrintLayer" );
1822 QDomText wmsPrintLayerText = doc.createTextNode( wmsPrintLayer.toString() );
1823 wmsPrintLayerElem.appendChild( wmsPrintLayerText );
1824 layerElem.appendChild( wmsPrintLayerElem );
1828 QgsRasterLayer *rl =
static_cast<QgsRasterLayer *
>( currentLayer );
1829 QgsRasterRenderer *rasterRenderer = rl->
renderer();
1830 if ( rasterRenderer )
1832 layerElem.setAttribute( u
"opacity"_s, QString::number( rasterRenderer->
opacity() ) );
1848 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent )
1852 QDomElement keywordsElem = doc.createElement( u
"KeywordList"_s );
1854 QDomElement keywordElem = doc.createElement( u
"Keyword"_s );
1855 keywordElem.setAttribute( u
"vocabulary"_s, u
"ISO"_s );
1856 QDomText keywordText = doc.createTextNode( u
"infoMapAccessService"_s );
1857 keywordElem.appendChild( keywordText );
1858 keywordsElem.appendChild( keywordElem );
1859 parent.appendChild( keywordsElem );
1861 for (
const QString &keyword : std::as_const( keywords ) )
1863 if ( !keyword.isEmpty() )
1865 keywordElem = doc.createElement( u
"Keyword"_s );
1866 keywordText = doc.createTextNode( keyword );
1867 keywordElem.appendChild( keywordText );
1870 keywordElem.setAttribute( u
"vocabulary"_s, u
"SIA_Geo405"_s );
1872 keywordsElem.appendChild( keywordElem );
1875 parent.appendChild( keywordsElem );
1879 bool hasQueryableLayers(
const QStringList &layerIds,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos )
1881 for (
const QString &
id : std::as_const( layerIds ) )
1883 if ( !wmsLayerInfos.contains(
id ) )
1887 if ( wmsLayerInfos[
id].queryable )
1900 for (
const QString &
id : std::as_const( layerIds ) )
1902 if ( !wmsLayerInfos.contains(
id ) )
1907 QgsRectangle rect = wmsLayerInfos[id].wgs84BoundingRect;
1932 QMap<QString, QgsRectangle>
combineCrsExtents(
const QStringList &layerIds,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos )
1934 QMap<QString, QgsRectangle> combined;
1936 for (
const QString &
id : std::as_const( layerIds ) )
1938 if ( !wmsLayerInfos.contains(
id ) )
1944 const auto keys = layerInfos.
crsExtents.keys();
1945 for (
const QString &crs : std::as_const( keys ) )
1958 if ( !combined.contains( crs ) )
1960 combined[crs] = rect;
1964 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.
@ 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).
bool hasWmsTimeDimension() const
Returns whether the WMS time dimension should be computed for this group or not.
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:...
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.
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.
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.