45using namespace Qt::StringLiterals;
52 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem, QgsMapLayer *currentLayer );
54 void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem, QgsServerInterface *serverIface,
const QgsProject *project );
56 void appendLayerWgs84BoundingRect( QDomDocument &doc, QDomElement &layerElement,
const QgsRectangle &wgs84BoundingRect );
58 void appendLayerCrsExtents( QDomDocument &doc, QDomElement &layerElement,
const QMap<QString, QgsRectangle> &crsExtents );
60 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
const QString &crsText );
62 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
const QStringList &crsList,
const QStringList &constrainedCrsList );
64 void appendLayerStyles( QDomDocument &doc, QDomElement &layerElem,
const QgsWmsLayerInfos &layerInfos,
const QgsProject *project,
const QgsWmsRequest &request,
const QgsServerSettings *settings );
66 void appendLayersFromTreeGroup( QDomDocument &doc, QDomElement &parentLayer, QgsServerInterface *serverIface,
const QgsProject *project,
const QgsWmsRequest &request,
const QgsLayerTreeGroup *layerTreeGroup,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos,
bool projectSettings, QList<QgsDateTimeRange> &parentDateRanges );
68 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent );
73#ifdef HAVE_SERVER_PYTHON_PLUGINS
78 const QDomDocument *capabilitiesDocument =
nullptr;
83 QStringList cacheKeyList;
84 cacheKeyList << ( projectSettings ? u
"projectSettings"_s : request.
wmsParameters().version() );
88#ifdef HAVE_SERVER_PYTHON_PLUGINS
92 QString
cacheKey = cacheKeyList.join(
'-' );
94#ifdef HAVE_SERVER_PYTHON_PLUGINS
96 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
98 capabilitiesDocument = &doc;
101 if ( !capabilitiesDocument && cache )
106 if ( !capabilitiesDocument )
110 doc =
getCapabilities( serverIface, project, request, projectSettings );
112#ifdef HAVE_SERVER_PYTHON_PLUGINS
113 if ( cacheManager && cacheManager->
setCachedDocument( &doc, project, request, accessControl ) )
115 capabilitiesDocument = &doc;
120 if ( !capabilitiesDocument )
125 if ( !capabilitiesDocument )
127 capabilitiesDocument = &doc;
139 response.
setHeader( u
"Content-Type"_s, u
"text/xml; charset=utf-8"_s );
140 response.
write( capabilitiesDocument->toByteArray() );
146 QDomElement wmsCapabilitiesElement;
152 QString hrefString = href.toString();
153 hrefString.append( href.hasQuery() ?
"&" :
"?" );
156 QDomProcessingInstruction xmlDeclaration = doc.createProcessingInstruction( u
"xml"_s, u
"version=\"1.0\" encoding=\"utf-8\""_s );
159 std::function<void( QDomElement &,
const QString & )> appendFormat = [&doc]( QDomElement &elem,
const QString &format ) {
160 QDomElement formatElem = doc.createElement( u
"Format"_s );
161 formatElem.appendChild( doc.createTextNode( format ) );
162 elem.appendChild( formatElem );
167 doc = QDomDocument( u
"WMT_MS_Capabilities SYSTEM 'http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd'"_s );
168 doc.appendChild( xmlDeclaration );
169 wmsCapabilitiesElement = doc.createElement( u
"WMT_MS_Capabilities"_s );
173 doc.appendChild( xmlDeclaration );
174 wmsCapabilitiesElement = doc.createElement( u
"WMS_Capabilities"_s );
175 wmsCapabilitiesElement.setAttribute( u
"xmlns"_s, u
"http://www.opengis.net/wms"_s );
176 wmsCapabilitiesElement.setAttribute( u
"xmlns:sld"_s, u
"http://www.opengis.net/sld"_s );
177 wmsCapabilitiesElement.setAttribute( u
"xmlns:qgs"_s, u
"http://www.qgis.org/wms"_s );
178 wmsCapabilitiesElement.setAttribute( u
"xmlns:xsi"_s, u
"http://www.w3.org/2001/XMLSchema-instance"_s );
179 QString schemaLocation = u
"http://www.opengis.net/wms"_s;
180 schemaLocation +=
" http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd"_L1;
181 schemaLocation +=
" http://www.opengis.net/sld"_L1;
182 schemaLocation +=
" http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd"_L1;
186 wmsCapabilitiesElement.setAttribute( u
"xmlns:inspire_common"_s, u
"http://inspire.ec.europa.eu/schemas/common/1.0"_s );
187 wmsCapabilitiesElement.setAttribute( u
"xmlns:inspire_vs"_s, u
"http://inspire.ec.europa.eu/schemas/inspire_vs/1.0"_s );
188 schemaLocation +=
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0"_L1;
189 schemaLocation +=
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0/inspire_vs.xsd"_L1;
192 schemaLocation +=
" http://www.qgis.org/wms"_L1;
193 schemaLocation +=
" " + hrefString +
"SERVICE=WMS&REQUEST=GetSchemaExtension";
195 wmsCapabilitiesElement.setAttribute( u
"xsi:schemaLocation"_s, schemaLocation );
198 doc.appendChild( wmsCapabilitiesElement );
204 QDomElement capabilityElement =
getCapabilityElement( doc, project, request, projectSettings, serverIface );
205 wmsCapabilitiesElement.appendChild( capabilityElement );
207 if ( projectSettings )
216 capabilityElement.appendChild(
220 if ( projectSettings )
222 appendDrawingOrder( doc, capabilityElement, serverIface, project );
231 QDomElement serviceElem = doc.createElement( u
"Service"_s );
234 QDomElement nameElem = doc.createElement( u
"Name"_s );
235 QDomText nameText = doc.createTextNode( u
"WMS"_s );
236 nameElem.appendChild( nameText );
237 serviceElem.appendChild( nameElem );
240 QDomElement titleElem = doc.createElement( u
"Title"_s );
242 titleElem.appendChild( titleText );
243 serviceElem.appendChild( titleElem );
246 if ( !abstract.isEmpty() )
248 QDomElement abstractElem = doc.createElement( u
"Abstract"_s );
249 QDomText abstractText = doc.createCDATASection( abstract );
250 abstractElem.appendChild( abstractText );
251 serviceElem.appendChild( abstractElem );
254 addKeywordListElement( project, doc, serviceElem );
257 if ( onlineResource.isEmpty() )
259 onlineResource =
serviceUrl( request, project, *serverSettings ).toString();
261 QDomElement onlineResourceElem = doc.createElement( u
"OnlineResource"_s );
262 onlineResourceElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
263 onlineResourceElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
264 onlineResourceElem.setAttribute( u
"xlink:href"_s, onlineResource );
265 serviceElem.appendChild( onlineResourceElem );
272 if ( !contactPerson.isEmpty() || !contactOrganization.isEmpty() || !contactPosition.isEmpty() || !contactMail.isEmpty() || !contactPhone.isEmpty() )
275 QDomElement contactInfoElem = doc.createElement( u
"ContactInformation"_s );
278 if ( !contactPerson.isEmpty() || !contactOrganization.isEmpty() )
280 QDomElement contactPersonPrimaryElem = doc.createElement( u
"ContactPersonPrimary"_s );
282 QDomText contactPersonText;
283 if ( !contactPerson.isEmpty() )
285 contactPersonText = doc.createTextNode( contactPerson );
289 contactPersonText = doc.createTextNode( u
"unknown"_s );
291 QDomElement contactPersonElem = doc.createElement( u
"ContactPerson"_s );
292 contactPersonElem.appendChild( contactPersonText );
293 contactPersonPrimaryElem.appendChild( contactPersonElem );
295 QDomText contactOrganizationText;
296 if ( !contactOrganization.isEmpty() )
298 contactOrganizationText = doc.createTextNode( contactOrganization );
302 contactOrganizationText = doc.createTextNode( u
"unknown"_s );
304 QDomElement contactOrganizationElem = doc.createElement( u
"ContactOrganization"_s );
305 contactOrganizationElem.appendChild( contactOrganizationText );
306 contactPersonPrimaryElem.appendChild( contactOrganizationElem );
308 contactInfoElem.appendChild( contactPersonPrimaryElem );
311 if ( !contactPosition.isEmpty() )
313 QDomElement contactPositionElem = doc.createElement( u
"ContactPosition"_s );
314 QDomText contactPositionText = doc.createTextNode( contactPosition );
315 contactPositionElem.appendChild( contactPositionText );
316 contactInfoElem.appendChild( contactPositionElem );
319 if ( !contactPhone.isEmpty() )
321 QDomElement phoneElem = doc.createElement( u
"ContactVoiceTelephone"_s );
322 QDomText phoneText = doc.createTextNode( contactPhone );
323 phoneElem.appendChild( phoneText );
324 contactInfoElem.appendChild( phoneElem );
327 if ( !contactMail.isEmpty() )
329 QDomElement mailElem = doc.createElement( u
"ContactElectronicMailAddress"_s );
330 QDomText mailText = doc.createTextNode( contactMail );
331 mailElem.appendChild( mailText );
332 contactInfoElem.appendChild( mailElem );
335 serviceElem.appendChild( contactInfoElem );
338 QDomElement feesElem = doc.createElement( u
"Fees"_s );
339 QDomText feesText = doc.createTextNode( u
"None"_s );
341 if ( !fees.isEmpty() )
343 feesText = doc.createTextNode( fees );
345 feesElem.appendChild( feesText );
346 serviceElem.appendChild( feesElem );
348 QDomElement accessConstraintsElem = doc.createElement( u
"AccessConstraints"_s );
349 QDomText accessConstraintsText = doc.createTextNode( u
"None"_s );
351 if ( !accessConstraints.isEmpty() )
353 accessConstraintsText = doc.createTextNode( accessConstraints );
355 accessConstraintsElem.appendChild( accessConstraintsText );
356 serviceElem.appendChild( accessConstraintsElem );
363 QDomElement maxWidthElem = doc.createElement( u
"MaxWidth"_s );
364 QDomText maxWidthText = doc.createTextNode( QString::number( maxWidth ) );
365 maxWidthElem.appendChild( maxWidthText );
366 serviceElem.appendChild( maxWidthElem );
372 QDomElement maxHeightElem = doc.createElement( u
"MaxHeight"_s );
373 QDomText maxHeightText = doc.createTextNode( QString::number( maxHeight ) );
374 maxHeightElem.appendChild( maxHeightText );
375 serviceElem.appendChild( maxHeightElem );
390 QString hrefString = href.toString();
391 hrefString.append( href.hasQuery() ?
"&" :
"?" );
393 QDomElement capabilityElem = doc.createElement( u
"Capability"_s );
396 QDomElement requestElem = doc.createElement( u
"Request"_s );
397 capabilityElem.appendChild( requestElem );
399 QDomElement dcpTypeElem = doc.createElement( u
"DCPType"_s );
400 QDomElement httpElem = doc.createElement( u
"HTTP"_s );
401 dcpTypeElem.appendChild( httpElem );
404 std::function<void( QDomElement &,
const QString & )> appendFormat = [&doc]( QDomElement &elem,
const QString &format ) {
405 QDomElement formatElem = doc.createElement( u
"Format"_s );
406 formatElem.appendChild( doc.createTextNode( format ) );
407 elem.appendChild( formatElem );
413 elem = doc.createElement( u
"GetCapabilities"_s );
414 appendFormat( elem, ( version ==
"1.1.1"_L1 ?
"application/vnd.ogc.wms_xml" :
"text/xml" ) );
415 elem.appendChild( dcpTypeElem );
416 requestElem.appendChild( elem );
419 QDomElement getElem = doc.createElement( u
"Get"_s );
420 httpElem.appendChild( getElem );
421 QDomElement olResourceElem = doc.createElement( u
"OnlineResource"_s );
422 olResourceElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
423 olResourceElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
424 olResourceElem.setAttribute( u
"xlink:href"_s, hrefString );
425 getElem.appendChild( olResourceElem );
428 elem = doc.createElement( u
"GetMap"_s );
429 appendFormat( elem, u
"image/png"_s );
430 appendFormat( elem, u
"image/png; mode=16bit"_s );
431 appendFormat( elem, u
"image/png; mode=8bit"_s );
432 appendFormat( elem, u
"image/png; mode=1bit"_s );
433 appendFormat( elem, u
"image/jpeg"_s );
434 appendFormat( elem, u
"application/dxf"_s );
435 appendFormat( elem, u
"application/pdf"_s );
436 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
437 requestElem.appendChild( elem );
440 elem = doc.createElement( u
"GetFeatureInfo"_s );
441 appendFormat( elem, u
"text/plain"_s );
442 appendFormat( elem, u
"text/html"_s );
443 appendFormat( elem, u
"text/xml"_s );
444 appendFormat( elem, u
"application/vnd.ogc.gml"_s );
445 appendFormat( elem, u
"application/vnd.ogc.gml/3.1.1"_s );
446 appendFormat( elem, u
"application/json"_s );
447 appendFormat( elem, u
"application/geo+json"_s );
448 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
449 requestElem.appendChild( elem );
452 elem = doc.createElement( ( version ==
"1.1.1"_L1 ?
"GetLegendGraphic" :
"sld:GetLegendGraphic" ) );
453 appendFormat( elem, u
"image/jpeg"_s );
454 appendFormat( elem, u
"image/png"_s );
455 appendFormat( elem, u
"application/json"_s );
456 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
457 requestElem.appendChild( elem );
460 elem = doc.createElement( ( version ==
"1.1.1"_L1 ?
"DescribeLayer" :
"sld:DescribeLayer" ) );
461 appendFormat( elem, u
"text/xml"_s );
462 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
463 requestElem.appendChild( elem );
466 elem = doc.createElement( ( version ==
"1.1.1"_L1 ?
"GetStyles" :
"qgs:GetStyles" ) );
467 appendFormat( elem, u
"text/xml"_s );
468 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
469 requestElem.appendChild( elem );
474 elem = doc.createElement( u
"GetPrint"_s );
475 appendFormat( elem, u
"svg"_s );
476 appendFormat( elem, u
"png"_s );
477 appendFormat( elem, u
"pdf"_s );
478 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
479 requestElem.appendChild( elem );
483 elem = doc.createElement( u
"Exception"_s );
484 appendFormat( elem, ( version ==
"1.1.1"_L1 ?
"application/vnd.ogc.se_xml" :
"XML" ) );
485 capabilityElem.appendChild( elem );
488 if ( version ==
"1.3.0"_L1 )
490 elem = doc.createElement( u
"sld:UserDefinedSymbolization"_s );
491 elem.setAttribute( u
"SupportSLD"_s, u
"1"_s );
492 elem.setAttribute( u
"UserLayer"_s, u
"0"_s );
493 elem.setAttribute( u
"UserStyle"_s, u
"1"_s );
494 elem.setAttribute( u
"RemoteWFS"_s, u
"0"_s );
495 elem.setAttribute( u
"InlineFeature"_s, u
"0"_s );
496 elem.setAttribute( u
"RemoteWCS"_s, u
"0"_s );
497 capabilityElem.appendChild( elem );
505 return capabilityElem;
510 QDomElement inspireCapabilitiesElem;
513 return inspireCapabilitiesElem;
515 inspireCapabilitiesElem = doc.createElement( u
"inspire_vs:ExtendedCapabilities"_s );
519 if ( !inspireMetadataUrl.isEmpty() )
521 QDomElement inspireCommonMetadataUrlElem = doc.createElement( u
"inspire_common:MetadataUrl"_s );
522 inspireCommonMetadataUrlElem.setAttribute( u
"xsi:type"_s, u
"inspire_common:resourceLocatorType"_s );
524 QDomElement inspireCommonMetadataUrlUrlElem = doc.createElement( u
"inspire_common:URL"_s );
525 inspireCommonMetadataUrlUrlElem.appendChild( doc.createTextNode( inspireMetadataUrl ) );
526 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlUrlElem );
529 if ( !inspireMetadataUrlType.isNull() )
531 QDomElement inspireCommonMetadataUrlMediaTypeElem = doc.createElement( u
"inspire_common:MediaType"_s );
532 inspireCommonMetadataUrlMediaTypeElem.appendChild( doc.createTextNode( inspireMetadataUrlType ) );
533 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlMediaTypeElem );
536 inspireCapabilitiesElem.appendChild( inspireCommonMetadataUrlElem );
540 QDomElement inspireCommonResourceTypeElem = doc.createElement( u
"inspire_common:ResourceType"_s );
541 inspireCommonResourceTypeElem.appendChild( doc.createTextNode( u
"service"_s ) );
542 inspireCapabilitiesElem.appendChild( inspireCommonResourceTypeElem );
544 QDomElement inspireCommonSpatialDataServiceTypeElem = doc.createElement( u
"inspire_common:SpatialDataServiceType"_s );
545 inspireCommonSpatialDataServiceTypeElem.appendChild( doc.createTextNode( u
"view"_s ) );
546 inspireCapabilitiesElem.appendChild( inspireCommonSpatialDataServiceTypeElem );
549 if ( !inspireTemporalReference.isNull() )
551 QDomElement inspireCommonTemporalReferenceElem = doc.createElement( u
"inspire_common:TemporalReference"_s );
552 QDomElement inspireCommonDateOfLastRevisionElem = doc.createElement( u
"inspire_common:DateOfLastRevision"_s );
553 inspireCommonDateOfLastRevisionElem.appendChild( doc.createTextNode( inspireTemporalReference ) );
554 inspireCommonTemporalReferenceElem.appendChild( inspireCommonDateOfLastRevisionElem );
555 inspireCapabilitiesElem.appendChild( inspireCommonTemporalReferenceElem );
558 QDomElement inspireCommonMetadataPointOfContactElem = doc.createElement( u
"inspire_common:MetadataPointOfContact"_s );
561 QDomElement inspireCommonOrganisationNameElem = doc.createElement( u
"inspire_common:OrganisationName"_s );
562 if ( !contactOrganization.isNull() )
564 inspireCommonOrganisationNameElem.appendChild( doc.createTextNode( contactOrganization ) );
566 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonOrganisationNameElem );
569 QDomElement inspireCommonEmailAddressElem = doc.createElement( u
"inspire_common:EmailAddress"_s );
570 if ( !contactMail.isNull() )
572 inspireCommonEmailAddressElem.appendChild( doc.createTextNode( contactMail ) );
574 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonEmailAddressElem );
576 inspireCapabilitiesElem.appendChild( inspireCommonMetadataPointOfContactElem );
579 if ( !inspireMetadataDate.isNull() )
581 QDomElement inspireCommonMetadataDateElem = doc.createElement( u
"inspire_common:MetadataDate"_s );
582 inspireCommonMetadataDateElem.appendChild( doc.createTextNode( inspireMetadataDate ) );
583 inspireCapabilitiesElem.appendChild( inspireCommonMetadataDateElem );
588 QDomElement inspireCommonSupportedLanguagesElem = doc.createElement( u
"inspire_common:SupportedLanguages"_s );
589 inspireCommonSupportedLanguagesElem.setAttribute( u
"xsi:type"_s, u
"inspire_common:supportedLanguagesType"_s );
591 QDomElement inspireCommonLanguageElem = doc.createElement( u
"inspire_common:Language"_s );
594 QDomElement inspireCommonDefaultLanguageElem = doc.createElement( u
"inspire_common:DefaultLanguage"_s );
595 inspireCommonDefaultLanguageElem.appendChild( inspireCommonLanguageElem );
596 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonDefaultLanguageElem );
600 QDomElement inspireCommonSupportedLanguageElem = doc.createElement(
"inspire_common:SupportedLanguage" );
601 inspireCommonSupportedLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
602 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonSupportedLanguageElem );
605 inspireCapabilitiesElem.appendChild( inspireCommonSupportedLanguagesElem );
607 QDomElement inspireCommonResponseLanguageElem = doc.createElement( u
"inspire_common:ResponseLanguage"_s );
608 inspireCommonResponseLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
609 inspireCapabilitiesElem.appendChild( inspireCommonResponseLanguageElem );
611 return inspireCapabilitiesElem;
617 if ( projectComposers.size() == 0 )
618 return QDomElement();
622 QDomElement composerTemplatesElem = doc.createElement( u
"ComposerTemplates"_s );
623 QList<QgsPrintLayout *>::const_iterator cIt = projectComposers.constBegin();
624 for ( ; cIt != projectComposers.constEnd(); ++cIt )
627 if ( restrictedComposers.contains( layout->
name() ) )
639 QDomElement composerTemplateElem = doc.createElement( u
"ComposerTemplate"_s );
640 composerTemplateElem.setAttribute( u
"name"_s, layout->
name() );
643 composerTemplateElem.setAttribute( u
"width"_s, width.
length() );
644 composerTemplateElem.setAttribute( u
"height"_s, height.
length() );
648 if ( atlas && atlas->
enabled() )
650 composerTemplateElem.setAttribute( u
"atlasEnabled"_s, u
"1"_s );
657 layerName = cLayer->
id();
659 else if ( layerName.isEmpty() )
661 layerName = cLayer->
name();
663 composerTemplateElem.setAttribute( u
"atlasCoverageLayer"_s, layerName );
668 QList<QgsLayoutItemMap *> layoutMapList;
670 QList<QgsLayoutItemMap *>::const_iterator cmIt = layoutMapList.constBegin();
673 for ( ; cmIt != layoutMapList.constEnd(); ++cmIt )
677 QDomElement composerMapElem = doc.createElement( u
"ComposerMap"_s );
678 composerMapElem.setAttribute( u
"name"_s, u
"map%1"_s.arg( mapId ) );
679 composerMapElem.setAttribute( u
"itemName"_s, composerMap->
displayName() );
681 composerMapElem.setAttribute( u
"width"_s, composerMap->rect().width() );
682 composerMapElem.setAttribute( u
"height"_s, composerMap->rect().height() );
683 composerTemplateElem.appendChild( composerMapElem );
687 QList<QgsLayoutItemLabel *> composerLabelList;
689 QList<QgsLayoutItemLabel *>::const_iterator clIt = composerLabelList.constBegin();
690 for ( ; clIt != composerLabelList.constEnd(); ++clIt )
693 QString
id = composerLabel->
id();
697 QDomElement composerLabelElem = doc.createElement( u
"ComposerLabel"_s );
698 composerLabelElem.setAttribute( u
"name"_s,
id );
699 composerTemplateElem.appendChild( composerLabelElem );
703 QList<QgsLayoutItemHtml *> composerHtmlList;
705 QList<QgsLayoutItemHtml *>::const_iterator chIt = composerHtmlList.constBegin();
706 for ( ; chIt != composerHtmlList.constEnd(); ++chIt )
712 QString
id = composerHtml->
frame( 0 )->
id();
716 QDomElement composerHtmlElem = doc.createElement( u
"ComposerHtml"_s );
717 composerHtmlElem.setAttribute( u
"name"_s,
id );
718 composerTemplateElem.appendChild( composerHtmlElem );
721 composerTemplatesElem.appendChild( composerTemplateElem );
724 if ( composerTemplatesElem.childNodes().size() == 0 )
725 return QDomElement();
727 return composerTemplatesElem;
733 if ( wfsLayerIds.size() == 0 )
734 return QDomElement();
736 QDomElement wfsLayersElem = doc.createElement( u
"WFSLayers"_s );
737 for (
int i = 0; i < wfsLayerIds.size(); ++i )
745 QDomElement wfsLayerElem = doc.createElement( u
"WFSLayer"_s );
748 wfsLayerElem.setAttribute( u
"name"_s, layer->
id() );
752 wfsLayerElem.setAttribute( u
"name"_s, layer->
name() );
754 wfsLayersElem.appendChild( wfsLayerElem );
757 return wfsLayersElem;
764 parentLayer.setAttribute(
770 QMap<QString, QgsRectangle> crsExtents =
combineCrsExtents( layerIds, wmsLayerInfos );
772 appendCrsElementsToLayer( doc, parentLayer, crsExtents.keys(), QStringList() );
773 appendLayerWgs84BoundingRect( doc, parentLayer, wgs84BoundingRect );
774 appendLayerCrsExtents( doc, parentLayer, crsExtents );
776 appendLayersFromTreeGroup( doc, parentLayer, serverIface, project, request, layerTreeGroup, wmsLayerInfos, projectSettings, parentDateRanges );
783 QDomElement layerParentElem = doc.createElement( u
"Layer"_s );
787 if ( rootLayerName.isEmpty() && !project->
title().isEmpty() )
789 rootLayerName = project->
title();
792 if ( !rootLayerName.isEmpty() )
794 QDomElement layerParentNameElem = doc.createElement( u
"Name"_s );
795 QDomText layerParentNameText = doc.createTextNode( rootLayerName );
796 layerParentNameElem.appendChild( layerParentNameText );
797 layerParentElem.appendChild( layerParentNameElem );
801 QDomElement layerParentTitleElem = doc.createElement( u
"Title"_s );
803 layerParentTitleElem.appendChild( layerParentTitleText );
804 layerParentElem.appendChild( layerParentTitleElem );
808 if ( !rootLayerAbstract.isEmpty() )
810 QDomElement layerParentAbstElem = doc.createElement( u
"Abstract"_s );
811 QDomText layerParentAbstText = doc.createCDATASection( rootLayerAbstract );
812 layerParentAbstElem.appendChild( layerParentAbstText );
813 layerParentElem.appendChild( layerParentAbstElem );
817 addKeywordListElement( project, doc, layerParentElem );
820 if ( projectSettings )
822 QDomElement treeNameElem = doc.createElement( u
"TreeName"_s );
823 QDomText treeNameText = doc.createTextNode( project->
title() );
824 treeNameElem.appendChild( treeNameText );
825 layerParentElem.appendChild( treeNameElem );
831 auto outputCrsList = QList<QgsCoordinateReferenceSystem>();
837 outputCrsList.append( crs );
861 u
"Error transforming extent: %1"_s.arg( cse.
what() ),
868 QMap<QString, QgsRectangle> wmsCrsExtents;
880 layerParentElem.setAttribute(
885 appendCrsElementsToLayer( doc, layerParentElem, wmsCrsExtents.keys(), QStringList() );
886 appendLayerWgs84BoundingRect( doc, layerParentElem, wmsWgs84BoundingRect );
887 appendLayerCrsExtents( doc, layerParentElem, wmsCrsExtents );
889 QList<QgsDateTimeRange> parentDateRanges;
890 appendLayersFromTreeGroup( doc, layerParentElem, serverIface, project, request, projectLayerTreeRoot, wmsLayerInfos, projectSettings, parentDateRanges );
894 QList<QgsDateTimeRange> parentDateRanges;
895 handleLayersFromTreeGroup( doc, layerParentElem, serverIface, project, request, projectLayerTreeRoot, wmsLayerInfos, projectSettings, parentDateRanges );
898 return layerParentElem;
906 void writeServerProperties( QDomDocument &doc, QDomElement &layerElem,
const QgsProject *project,
const QgsMapLayerServerProperties *serverProperties,
const QString &name,
const QString &version )
908 const QString title = serverProperties->
title();
909 QDomElement titleElem = doc.createElement( u
"Title"_s );
910 QDomText titleText = doc.createTextNode( !title.isEmpty() ? title : name );
911 titleElem.appendChild( titleText );
912 layerElem.appendChild( titleElem );
914 const QString abstract = serverProperties->
abstract();
915 if ( !abstract.isEmpty() )
917 QDomElement abstractElem = doc.createElement( u
"Abstract"_s );
918 QDomText abstractText = doc.createTextNode( abstract );
919 abstractElem.appendChild( abstractText );
920 layerElem.appendChild( abstractElem );
925 const QStringList keywords = !serverProperties->
keywordList().isEmpty() ? serverProperties->
keywordList().split(
',' ) : QStringList();
926 if ( !keywords.isEmpty() )
928 QDomElement keywordListElem = doc.createElement( u
"KeywordList"_s );
929 for (
const QString &keyword : std::as_const( keywords ) )
931 QDomElement keywordElem = doc.createElement( u
"Keyword"_s );
932 QDomText keywordText = doc.createTextNode( keyword.trimmed() );
933 keywordElem.appendChild( keywordText );
936 keywordElem.setAttribute( u
"vocabulary"_s, u
"SIA_Geo405"_s );
938 keywordListElem.appendChild( keywordElem );
940 layerElem.appendChild( keywordListElem );
944 const QString dataUrl = serverProperties->
dataUrl();
945 if ( !dataUrl.isEmpty() )
947 QDomElement dataUrlElem = doc.createElement( u
"DataURL"_s );
948 QDomElement dataUrlFormatElem = doc.createElement( u
"Format"_s );
949 const QString dataUrlFormat = serverProperties->
dataUrlFormat();
950 QDomText dataUrlFormatText = doc.createTextNode( dataUrlFormat );
951 dataUrlFormatElem.appendChild( dataUrlFormatText );
952 dataUrlElem.appendChild( dataUrlFormatElem );
953 QDomElement dataORElem = doc.createElement( u
"OnlineResource"_s );
954 dataORElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
955 dataORElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
956 dataORElem.setAttribute( u
"xlink:href"_s, dataUrl );
957 dataUrlElem.appendChild( dataORElem );
958 layerElem.appendChild( dataUrlElem );
962 const QString attribution = serverProperties->
attribution();
963 if ( !attribution.isEmpty() )
965 QDomElement attribElem = doc.createElement( u
"Attribution"_s );
966 QDomElement attribTitleElem = doc.createElement( u
"Title"_s );
967 QDomText attribText = doc.createTextNode( attribution );
968 attribTitleElem.appendChild( attribText );
969 attribElem.appendChild( attribTitleElem );
970 const QString attributionUrl = serverProperties->
attributionUrl();
971 if ( !attributionUrl.isEmpty() )
973 QDomElement attribORElem = doc.createElement( u
"OnlineResource"_s );
974 attribORElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
975 attribORElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
976 attribORElem.setAttribute( u
"xlink:href"_s, attributionUrl );
977 attribElem.appendChild( attribORElem );
979 layerElem.appendChild( attribElem );
983 const QList<QgsServerMetadataUrlProperties::MetadataUrl> metadataUrls = serverProperties->
metadataUrls();
984 for (
const QgsMapLayerServerProperties::MetadataUrl &metadataUrl : std::as_const( metadataUrls ) )
986 QDomElement metaUrlElem = doc.createElement( u
"MetadataURL"_s );
987 const QString metadataUrlType = metadataUrl.type;
988 if ( version ==
"1.1.1"_L1 )
990 metaUrlElem.setAttribute( u
"type"_s, metadataUrlType );
992 else if ( metadataUrlType ==
"FGDC"_L1 )
994 metaUrlElem.setAttribute( u
"type"_s, u
"FGDC:1998"_s );
996 else if ( metadataUrlType ==
"TC211"_L1 )
998 metaUrlElem.setAttribute( u
"type"_s, u
"ISO19115:2003"_s );
1002 metaUrlElem.setAttribute( u
"type"_s, metadataUrlType );
1004 const QString metadataUrlFormat = metadataUrl.format;
1005 if ( !metadataUrlFormat.isEmpty() )
1007 QDomElement metaUrlFormatElem = doc.createElement( u
"Format"_s );
1008 QDomText metaUrlFormatText = doc.createTextNode( metadataUrlFormat );
1009 metaUrlFormatElem.appendChild( metaUrlFormatText );
1010 metaUrlElem.appendChild( metaUrlFormatElem );
1012 QDomElement metaUrlORElem = doc.createElement( u
"OnlineResource"_s );
1013 metaUrlORElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
1014 metaUrlORElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
1015 metaUrlORElem.setAttribute( u
"xlink:href"_s, metadataUrl.url );
1016 metaUrlElem.appendChild( metaUrlORElem );
1017 layerElem.appendChild( metaUrlElem );
1021 void writeLegendUrl( QDomDocument &doc, QDomElement &styleElem,
const QString &legendUrl,
const QString &legendUrlFormat,
const QString &name,
const QString &styleName,
const QgsProject *project,
const QgsWmsRequest &request,
const QgsServerSettings *settings )
1024 QDomElement getLayerLegendGraphicElem = doc.createElement( u
"LegendURL"_s );
1026 QString customHrefString = legendUrl;
1028 QStringList getLayerLegendGraphicFormats;
1029 if ( !customHrefString.isEmpty() )
1031 getLayerLegendGraphicFormats << legendUrlFormat;
1035 getLayerLegendGraphicFormats << u
"image/png"_s;
1038 for (
const QString &getLayerLegendGraphicFormat : std::as_const( getLayerLegendGraphicFormats ) )
1040 QDomElement getLayerLegendGraphicFormatElem = doc.createElement( u
"Format"_s );
1041 QDomText getLayerLegendGraphicFormatText = doc.createTextNode( getLayerLegendGraphicFormat );
1042 getLayerLegendGraphicFormatElem.appendChild( getLayerLegendGraphicFormatText );
1043 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicFormatElem );
1047 if ( customHrefString.isEmpty() )
1050 QUrl href =
serviceUrl( request, project, *settings );
1051 const QString hrefString = href.toString() + ( href.hasQuery() ?
"&" :
"?" );
1053 QUrl mapUrl( hrefString );
1054 QUrlQuery mapUrlQuery( mapUrl.query() );
1055 mapUrlQuery.addQueryItem( u
"SERVICE"_s, u
"WMS"_s );
1056 mapUrlQuery.addQueryItem( u
"VERSION"_s, request.wmsParameters().version() );
1057 mapUrlQuery.addQueryItem( u
"REQUEST"_s, u
"GetLegendGraphic"_s );
1058 mapUrlQuery.addQueryItem( u
"LAYER"_s, name );
1059 mapUrlQuery.addQueryItem( u
"FORMAT"_s, u
"image/png"_s );
1060 mapUrlQuery.addQueryItem( u
"STYLE"_s, styleName );
1061 if ( request.wmsParameters().version() ==
"1.3.0"_L1 )
1063 mapUrlQuery.addQueryItem( u
"SLD_VERSION"_s, u
"1.1.0"_s );
1065 mapUrl.setQuery( mapUrlQuery );
1066 customHrefString = mapUrl.toString();
1069 QDomElement getLayerLegendGraphicORElem = doc.createElement( u
"OnlineResource"_s );
1070 getLayerLegendGraphicORElem.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
1071 getLayerLegendGraphicORElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
1072 getLayerLegendGraphicORElem.setAttribute( u
"xlink:href"_s, customHrefString );
1073 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicORElem );
1074 styleElem.appendChild( getLayerLegendGraphicElem );
1077 QDomElement createStyleElement( QDomDocument &doc,
const QString &styleName )
1079 QDomElement styleElem = doc.createElement( u
"Style"_s );
1080 QDomElement styleNameElem = doc.createElement( u
"Name"_s );
1081 QDomText styleNameText = doc.createTextNode( styleName );
1082 styleNameElem.appendChild( styleNameText );
1083 QDomElement styleTitleElem = doc.createElement( u
"Title"_s );
1084 QDomText styleTitleText = doc.createTextNode( styleName );
1085 styleTitleElem.appendChild( styleTitleText );
1086 styleElem.appendChild( styleNameElem );
1087 styleElem.appendChild( styleTitleElem );
1093 bool writeTimeDimensionNode( QDomDocument &doc, QDomElement &layerElem,
const QList<QgsDateTimeRange> &dateRanges )
1101 const bool hasDateTime = std::any_of( dateRanges.constBegin(), dateRanges.constEnd(), [](
const QgsDateTimeRange &r ) { return r.begin().time() != QTime( 0, 0 )
1102 || ( !r.isInstant() && r.end().time() != QTime( 0, 0 ) ); } );
1104 const QString dateFormat = hasDateTime ? u
"yyyy-MM-ddTHH:mm:ss"_s : u
"yyyy-MM-dd"_s;
1106 QStringList strValues;
1110 if ( range.begin().isValid() && range.end().isValid() )
1112 strValues << ( range.isInstant() ? range.begin().toString( dateFormat ) : u
"%1/%2"_s.arg( range.begin().toString( dateFormat ) ).arg( range.end().toString( dateFormat ) ) );
1116 QDomElement dimElem = doc.createElement( u
"Dimension"_s );
1117 dimElem.setAttribute( u
"name"_s, u
"TIME"_s );
1118 dimElem.setAttribute( u
"units"_s, u
"ISO8601"_s );
1119 QDomText dimValuesText = doc.createTextNode( strValues.join( QChar(
',' ) ) );
1120 dimElem.appendChild( dimValuesText );
1122 layerElem.appendChild( dimElem );
1124 return !hasDateTime;
1127 void appendLayersFromTreeGroup( QDomDocument &doc, QDomElement &parentLayer, QgsServerInterface *serverIface,
const QgsProject *project,
const QgsWmsRequest &request,
const QgsLayerTreeGroup *layerTreeGroup,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos,
bool projectSettings, QList<QgsDateTimeRange> &parentDateRanges )
1129 const QString version = request.wmsParameters().version();
1134 QList<QgsLayerTreeNode *> layerTreeGroupChildren = layerTreeGroup->
children();
1135 for (
int i = 0; i < layerTreeGroupChildren.size(); ++i )
1137 QgsLayerTreeNode *treeNode = layerTreeGroupChildren.at( i );
1138 QDomElement layerElem = doc.createElement( u
"Layer"_s );
1140 if ( projectSettings )
1142 layerElem.setAttribute( u
"visible"_s, treeNode->
isVisible() );
1144 layerElem.setAttribute( u
"expanded"_s, treeNode->
isExpanded() );
1149 QgsLayerTreeGroup *treeGroupChild =
static_cast<QgsLayerTreeGroup *
>( treeNode );
1151 QString name = treeGroupChild->
name();
1152 if ( restrictedLayers.contains( name ) )
1157 if ( projectSettings )
1164 if ( !skipNameForGroup )
1166 QDomElement nameElem = doc.createElement( u
"Name"_s );
1168 if ( !shortName.isEmpty() )
1169 nameText = doc.createTextNode( shortName );
1171 nameText = doc.createTextNode( name );
1172 nameElem.appendChild( nameText );
1173 layerElem.appendChild( nameElem );
1176 writeServerProperties( doc, layerElem, project, treeGroupChild->
serverProperties(), name, version );
1179 const QString styleName = u
"default"_s;
1180 QDomElement styleElem = createStyleElement( doc, styleName );
1183 layerElem.appendChild( styleElem );
1186 if ( projectSettings )
1188 QDomElement treeNameElem = doc.createElement( u
"TreeName"_s );
1189 QDomText treeNameText = doc.createTextNode( name );
1190 treeNameElem.appendChild( treeNameText );
1191 layerElem.appendChild( treeNameElem );
1194 QList<QgsDateTimeRange> childrenDateRanges;
1195 handleLayersFromTreeGroup( doc, layerElem, serverIface, project, request, treeGroupChild, wmsLayerInfos, projectSettings, childrenDateRanges );
1199 writeTimeDimensionNode( doc, layerElem, childrenDateRanges );
1200 parentDateRanges.append( childrenDateRanges );
1204 if ( layerElem.elementsByTagName( u
"Layer"_s ).length() == 0 )
1211 QgsLayerTreeLayer *treeLayer =
static_cast<QgsLayerTreeLayer *
>( treeNode );
1212 QgsMapLayer *l = treeLayer->
layer();
1213 if ( !wmsLayerInfos.contains( treeLayer->
layerId() ) )
1218 const QgsWmsLayerInfos &layerInfos = wmsLayerInfos[treeLayer->
layerId()];
1220 layerElem.setAttribute(
1225 QDomElement nameElem = doc.createElement( u
"Name"_s );
1226 QDomText nameText = doc.createTextNode( layerInfos.
name );
1227 nameElem.appendChild( nameText );
1228 layerElem.appendChild( nameElem );
1235 appendCrsElementsToLayer( doc, layerElem, layerInfos.
crsExtents.keys(), QStringList() );
1239 appendLayerCrsExtents( doc, layerElem, layerInfos.
crsExtents );
1243 appendLayerStyles( doc, layerElem, layerInfos, project, request, serverIface->
serverSettings() );
1249 auto formatScale = [](
double value ) {
1250 const thread_local QRegularExpression trailingZeroRegEx = QRegularExpression( u
"0+$"_s );
1251 const thread_local QRegularExpression trailingPointRegEx = QRegularExpression( u
"[.]+$"_s );
1252 return QString::number( value,
'f' ).remove( trailingZeroRegEx ).remove( trailingPointRegEx );
1255 if ( version ==
"1.1.1"_L1 )
1258 double SCALE_TO_SCALEHINT =
OGC_PX_M * M_SQRT2;
1260 QDomElement scaleHintElem = doc.createElement( u
"ScaleHint"_s );
1261 scaleHintElem.setAttribute( u
"min"_s, formatScale( layerInfos.
maxScale * SCALE_TO_SCALEHINT ) );
1262 scaleHintElem.setAttribute( u
"max"_s, formatScale( layerInfos.
minScale * SCALE_TO_SCALEHINT ) );
1263 layerElem.appendChild( scaleHintElem );
1267 QDomElement minScaleElem = doc.createElement( u
"MinScaleDenominator"_s );
1268 QDomText minScaleText = doc.createTextNode( formatScale( layerInfos.
maxScale ) );
1269 minScaleElem.appendChild( minScaleText );
1270 layerElem.appendChild( minScaleElem );
1272 QDomElement maxScaleElem = doc.createElement( u
"MaxScaleDenominator"_s );
1273 QDomText maxScaleText = doc.createTextNode( formatScale( layerInfos.
minScale ) );
1274 maxScaleElem.appendChild( maxScaleText );
1275 layerElem.appendChild( maxScaleElem );
1279 bool timeDimensionAdded {
false };
1284 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( l );
1285 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( vl->
serverProperties() );
1286 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> wmsDims = serverProperties->
wmsDimensions();
1287 for (
const QgsMapLayerServerProperties::WmsDimensionInfo &dim : wmsDims )
1291 if ( fieldIndex == -1 )
1296 QSet<QVariant> uniqueValues = vl->
uniqueValues( fieldIndex );
1299 if ( !dim.endFieldName.isEmpty() )
1301 int endFieldIndex = vl->
fields().
indexOf( dim.endFieldName );
1303 if ( endFieldIndex == -1 )
1307 uniqueValues.unite( vl->
uniqueValues( endFieldIndex ) );
1310 QList<QVariant> values = qgis::setToList( uniqueValues );
1311 std::sort( values.begin(), values.end() );
1313 QDomElement dimElem = doc.createElement( u
"Dimension"_s );
1314 dimElem.setAttribute( u
"name"_s, dim.name );
1316 if ( dim.name.toUpper() ==
"TIME"_L1 )
1318 timeDimensionAdded =
true;
1321 if ( !dim.units.isEmpty() )
1323 dimElem.setAttribute( u
"units"_s, dim.units );
1325 if ( !dim.unitSymbol.isEmpty() )
1327 dimElem.setAttribute( u
"unitSymbol"_s, dim.unitSymbol );
1329 if ( !values.isEmpty() && dim.defaultDisplayType == QgsMapLayerServerProperties::WmsDimensionInfo::MinValue )
1331 dimElem.setAttribute( u
"default"_s, values.first().toString() );
1333 else if ( !values.isEmpty() && dim.defaultDisplayType == QgsMapLayerServerProperties::WmsDimensionInfo::MaxValue )
1335 dimElem.setAttribute( u
"default"_s, values.last().toString() );
1337 else if ( dim.defaultDisplayType == QgsMapLayerServerProperties::WmsDimensionInfo::ReferenceValue )
1339 dimElem.setAttribute( u
"default"_s, dim.referenceValue.toString() );
1341 dimElem.setAttribute( u
"multipleValues"_s, u
"1"_s );
1342 dimElem.setAttribute( u
"nearestValue"_s, u
"0"_s );
1343 if ( projectSettings )
1345 dimElem.setAttribute( u
"fieldName"_s, dim.fieldName );
1346 dimElem.setAttribute( u
"endFieldName"_s, dim.endFieldName );
1349 QStringList strValues;
1350 for (
const QVariant &v : values )
1352 strValues << v.toString();
1354 QDomText dimValuesText = doc.createTextNode( strValues.join(
", "_L1 ) );
1355 dimElem.appendChild( dimValuesText );
1356 layerElem.appendChild( dimElem );
1361 if ( !timeDimensionAdded
1369 const bool isDateList = writeTimeDimensionNode( doc, layerElem, allRanges );
1371 parentDateRanges.append( allRanges );
1373 QDomElement timeExtentElem = doc.createElement( u
"Extent"_s );
1374 timeExtentElem.setAttribute( u
"name"_s, u
"TIME"_s );
1380 extent = u
"%1/%2"_s.arg( timeExtent.
begin().date().toString( Qt::DateFormat::ISODate ), timeExtent.
end().date().toString( Qt::DateFormat::ISODate ) );
1384 extent = u
"%1/%2"_s.arg( timeExtent.
begin().toString( Qt::DateFormat::ISODate ), timeExtent.
end().toString( Qt::DateFormat::ISODate ) );
1386 QDomText extentValueText = doc.createTextNode( extent );
1387 timeExtentElem.appendChild( extentValueText );
1388 layerElem.appendChild( timeExtentElem );
1391 if ( projectSettings )
1393 appendLayerProjectSettings( doc, layerElem, l );
1397 parentLayer.appendChild( layerElem );
1401 void appendLayerStyles( QDomDocument &doc, QDomElement &layerElem,
const QgsWmsLayerInfos &layerInfos,
const QgsProject *project,
const QgsWmsRequest &request,
const QgsServerSettings *settings )
1403 for (
const QString &styleName : std::as_const( layerInfos.
styles ) )
1405 QDomElement styleElem = createStyleElement( doc, styleName );
1407 writeLegendUrl( doc, styleElem, layerInfos.
legendUrl, layerInfos.
legendUrlFormat, layerInfos.
name, styleName, project, request, settings );
1409 layerElem.appendChild( styleElem );
1413 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
const QStringList &crsList,
const QStringList &constrainedCrsList )
1415 if ( layerElement.isNull() )
1420 const QString version = doc.documentElement().attribute( u
"version"_s );
1423 QDomElement titleElement = layerElement.firstChildElement( u
"Title"_s );
1424 QDomElement abstractElement = layerElement.firstChildElement( u
"Abstract"_s );
1425 QDomElement keywordListElement = layerElement.firstChildElement( u
"KeywordList"_s );
1426 QDomElement CRSPrecedingElement = !keywordListElement.isNull() ? keywordListElement : !abstractElement.isNull() ? abstractElement
1429 if ( CRSPrecedingElement.isNull() )
1432 const QDomElement keyElement = layerElement.firstChildElement( u
"KeywordList"_s );
1433 CRSPrecedingElement = keyElement;
1437 if ( !constrainedCrsList.isEmpty() )
1439 for (
int i = constrainedCrsList.size() - 1; i >= 0; --i )
1441 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, constrainedCrsList.at( i ) );
1446 for (
const QString &crs : crsList )
1448 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, crs );
1454 if ( version ==
"1.3.0"_L1 )
1456 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, QString(
"CRS:84" ) );
1460 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
const QString &crsText )
1462 if ( crsText.isEmpty() )
1464 const QString version = doc.documentElement().attribute( u
"version"_s );
1465 QDomElement crsElement = doc.createElement( version ==
"1.1.1"_L1 ?
"SRS" :
"CRS" );
1466 QDomText crsTextNode = doc.createTextNode( crsText );
1467 crsElement.appendChild( crsTextNode );
1468 layerElement.insertAfter( crsElement, precedingElement );
1471 void appendLayerWgs84BoundingRect( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &wgs84BoundingRect )
1474 if ( wgs84BoundingRect.
isNull() )
1480 QDomElement ExGeoBBoxElement;
1481 const int wgs84precision = 6;
1482 const QString version = doc.documentElement().attribute( u
"version"_s );
1483 if ( version ==
"1.1.1"_L1 )
1485 ExGeoBBoxElement = doc.createElement( u
"LatLonBoundingBox"_s );
1493 ExGeoBBoxElement = doc.createElement( u
"EX_GeographicBoundingBox"_s );
1494 QDomElement wBoundLongitudeElement = doc.createElement( u
"westBoundLongitude"_s );
1496 wBoundLongitudeElement.appendChild( wBoundLongitudeText );
1497 ExGeoBBoxElement.appendChild( wBoundLongitudeElement );
1498 QDomElement eBoundLongitudeElement = doc.createElement( u
"eastBoundLongitude"_s );
1500 eBoundLongitudeElement.appendChild( eBoundLongitudeText );
1501 ExGeoBBoxElement.appendChild( eBoundLongitudeElement );
1502 QDomElement sBoundLatitudeElement = doc.createElement( u
"southBoundLatitude"_s );
1504 sBoundLatitudeElement.appendChild( sBoundLatitudeText );
1505 ExGeoBBoxElement.appendChild( sBoundLatitudeElement );
1506 QDomElement nBoundLatitudeElement = doc.createElement( u
"northBoundLatitude"_s );
1508 nBoundLatitudeElement.appendChild( nBoundLatitudeText );
1509 ExGeoBBoxElement.appendChild( nBoundLatitudeElement );
1512 const QDomElement lastCRSElem = layerElem.lastChildElement( version ==
"1.1.1"_L1 ?
"SRS" :
"CRS" );
1513 if ( !lastCRSElem.isNull() )
1515 layerElem.insertAfter( ExGeoBBoxElement, lastCRSElem );
1519 layerElem.appendChild( ExGeoBBoxElement );
1523 void appendLayerCrsExtents( QDomDocument &doc, QDomElement &layerElem,
const QMap<QString, QgsRectangle> &crsExtents )
1525 const QString version = doc.documentElement().attribute( u
"version"_s );
1527 const auto &keys = crsExtents.keys();
1528 for (
const QString &crsText : std::as_const( keys ) )
1531 QgsRectangle crsExtent( crsExtents[crsText] );
1533 if ( crsExtent.isNull() )
1545 QDomElement bBoxElement = doc.createElement( u
"BoundingBox"_s );
1548 bBoxElement.setAttribute( version ==
"1.1.1"_L1 ?
"SRS" :
"CRS", crs.
authid() );
1561 QDomElement lastBBoxElem = layerElem.lastChildElement( u
"BoundingBox"_s );
1562 if ( !lastBBoxElem.isNull() )
1564 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1568 lastBBoxElem = layerElem.lastChildElement( version ==
"1.1.1"_L1 ?
"LatLonBoundingBox" :
"EX_GeographicBoundingBox" );
1569 if ( !lastBBoxElem.isNull() )
1571 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1575 layerElem.appendChild( bBoxElement );
1581 void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem, QgsServerInterface *serverIface,
const QgsProject *project )
1583#ifdef HAVE_SERVER_PYTHON_PLUGINS
1586 ( void ) serverIface;
1591 QStringList layerList;
1593 const QgsLayerTree *projectLayerTreeRoot = project->
layerTreeRoot();
1594 QList<QgsMapLayer *> projectLayerOrder = projectLayerTreeRoot->
layerOrder();
1595 for (
int i = 0; i < projectLayerOrder.size(); ++i )
1597 QgsMapLayer *l = projectLayerOrder.at( i );
1599 if ( restrictedLayers.contains( l->
name() ) )
1603#ifdef HAVE_SERVER_PYTHON_PLUGINS
1609 QString wmsName = l->
name();
1619 layerList << wmsName;
1622 if ( !layerList.isEmpty() )
1624 QStringList reversedList;
1625 reversedList.reserve( layerList.size() );
1626 for (
int i = layerList.size() - 1; i >= 0; --i )
1627 reversedList << layerList[i];
1629 QDomElement layerDrawingOrderElem = doc.createElement( u
"LayerDrawingOrder"_s );
1630 QDomText drawingOrderText = doc.createTextNode( reversedList.join(
',' ) );
1631 layerDrawingOrderElem.appendChild( drawingOrderText );
1632 parentElem.appendChild( layerDrawingOrderElem );
1636 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem, QgsMapLayer *currentLayer )
1638 if ( !currentLayer )
1644 QDomElement treeNameElem = doc.createElement( u
"TreeName"_s );
1645 QDomText treeNameText = doc.createTextNode( currentLayer->
name() );
1646 treeNameElem.appendChild( treeNameText );
1647 layerElem.appendChild( treeNameElem );
1649 switch ( currentLayer->
type() )
1653 QgsVectorLayer *vLayer =
static_cast<QgsVectorLayer *
>( currentLayer );
1655 int displayFieldIdx = -1;
1656 QString displayField = u
"maptip"_s;
1658 if ( exp.isField() )
1660 displayField =
static_cast<const QgsExpressionNodeColumnRef *
>( exp.rootNode() )->name();
1665 QDomElement attributesElem = doc.createElement( u
"Attributes"_s );
1666 const QgsFields layerFields = vLayer->
fields();
1667 for (
int idx = 0; idx < layerFields.
count(); ++idx )
1669 QgsField field = layerFields.
at( idx );
1675 if ( idx == displayFieldIdx )
1679 QDomElement attributeElem = doc.createElement( u
"Attribute"_s );
1680 attributeElem.setAttribute( u
"name"_s, field.
name() );
1681 attributeElem.setAttribute( u
"type"_s, QVariant::typeToName( field.
type() ) );
1682 attributeElem.setAttribute( u
"typeName"_s, field.
typeName() );
1683 QString alias = field.
alias();
1684 if ( !alias.isEmpty() )
1686 attributeElem.setAttribute( u
"alias"_s, alias );
1691 attributeElem.setAttribute( u
"comment"_s, field.
comment() );
1692 attributeElem.setAttribute( u
"length"_s, field.
length() );
1693 attributeElem.setAttribute( u
"precision"_s, field.
precision() );
1694 attributesElem.appendChild( attributeElem );
1698 layerElem.setAttribute( u
"displayField"_s, displayField );
1702 if ( pkAttributes.size() > 0 )
1704 QDomElement pkElem = doc.createElement( u
"PrimaryKey"_s );
1705 QgsAttributeList::const_iterator pkIt = pkAttributes.constBegin();
1706 for ( ; pkIt != pkAttributes.constEnd(); ++pkIt )
1708 QDomElement pkAttributeElem = doc.createElement( u
"PrimaryKeyAttribute"_s );
1709 QDomText pkAttName = doc.createTextNode( layerFields.
at( *pkIt ).
name() );
1710 pkAttributeElem.appendChild( pkAttName );
1711 pkElem.appendChild( pkAttributeElem );
1713 layerElem.appendChild( pkElem );
1720 layerElem.setAttribute( u
"opacity"_s, QString::number( vLayer->
opacity() ) );
1722 layerElem.appendChild( attributesElem );
1728 const QgsDataProvider *provider = currentLayer->
dataProvider();
1729 if ( provider && provider->
name() ==
"wms" )
1732 QVariant wmsBackgroundLayer = currentLayer->
customProperty( u
"WMSBackgroundLayer"_s,
false );
1733 QDomElement wmsBackgroundLayerElem = doc.createElement(
"WMSBackgroundLayer" );
1734 QDomText wmsBackgroundLayerText = doc.createTextNode( wmsBackgroundLayer.toBool() ? u
"1"_s : u
"0"_s );
1735 wmsBackgroundLayerElem.appendChild( wmsBackgroundLayerText );
1736 layerElem.appendChild( wmsBackgroundLayerElem );
1739 QVariant wmsPublishDataSourceUrl = currentLayer->
customProperty( u
"WMSPublishDataSourceUrl"_s,
false );
1740 if ( wmsPublishDataSourceUrl.toBool() )
1742 bool tiled = qobject_cast<const QgsRasterDataProvider *>( provider )
1743 ? !qobject_cast<const QgsRasterDataProvider *>( provider )->nativeResolutions().isEmpty()
1746 QDomElement dataSourceElem = doc.createElement( tiled ? u
"WMTSDataSource"_s : u
"WMSDataSource"_s );
1747 QDomText dataSourceUri = doc.createTextNode( provider->
dataSourceUri() );
1748 dataSourceElem.appendChild( dataSourceUri );
1749 layerElem.appendChild( dataSourceElem );
1753 QVariant wmsPrintLayer = currentLayer->
customProperty( u
"WMSPrintLayer"_s );
1754 if ( wmsPrintLayer.isValid() )
1756 QDomElement wmsPrintLayerElem = doc.createElement(
"WMSPrintLayer" );
1757 QDomText wmsPrintLayerText = doc.createTextNode( wmsPrintLayer.toString() );
1758 wmsPrintLayerElem.appendChild( wmsPrintLayerText );
1759 layerElem.appendChild( wmsPrintLayerElem );
1763 QgsRasterLayer *rl =
static_cast<QgsRasterLayer *
>( currentLayer );
1764 QgsRasterRenderer *rasterRenderer = rl->
renderer();
1765 if ( rasterRenderer )
1767 layerElem.setAttribute( u
"opacity"_s, QString::number( rasterRenderer->
opacity() ) );
1783 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent )
1787 QDomElement keywordsElem = doc.createElement( u
"KeywordList"_s );
1789 QDomElement keywordElem = doc.createElement( u
"Keyword"_s );
1790 keywordElem.setAttribute( u
"vocabulary"_s, u
"ISO"_s );
1791 QDomText keywordText = doc.createTextNode( u
"infoMapAccessService"_s );
1792 keywordElem.appendChild( keywordText );
1793 keywordsElem.appendChild( keywordElem );
1794 parent.appendChild( keywordsElem );
1796 for (
const QString &keyword : std::as_const( keywords ) )
1798 if ( !keyword.isEmpty() )
1800 keywordElem = doc.createElement( u
"Keyword"_s );
1801 keywordText = doc.createTextNode( keyword );
1802 keywordElem.appendChild( keywordText );
1805 keywordElem.setAttribute( u
"vocabulary"_s, u
"SIA_Geo405"_s );
1807 keywordsElem.appendChild( keywordElem );
1810 parent.appendChild( keywordsElem );
1814 bool hasQueryableLayers(
const QStringList &layerIds,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos )
1816 for (
const QString &
id : std::as_const( layerIds ) )
1818 if ( !wmsLayerInfos.contains(
id ) )
1822 if ( wmsLayerInfos[
id].queryable )
1835 for (
const QString &
id : std::as_const( layerIds ) )
1837 if ( !wmsLayerInfos.contains(
id ) )
1842 QgsRectangle rect = wmsLayerInfos[id].wgs84BoundingRect;
1867 QMap<QString, QgsRectangle>
combineCrsExtents(
const QStringList &layerIds,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos )
1869 QMap<QString, QgsRectangle> combined;
1871 for (
const QString &
id : std::as_const( layerIds ) )
1873 if ( !wmsLayerInfos.contains(
id ) )
1879 const auto keys = layerInfos.
crsExtents.keys();
1880 for (
const QString &crs : std::as_const( keys ) )
1893 if ( !combined.contains( crs ) )
1895 combined[crs] = rect;
1899 combined[crs].combineExtentWith( rect );
@ 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).
@ 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 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.
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 legendUrlFormat() const
Returns the format for a URL based layer legend.
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 legendUrl() const
Returns the URL for the layer's legend.
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.
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())
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 Header entry Add Header entry to the response Note that it is usually an error to set Header afte...
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.
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.
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, QList< QgsDateTimeRange > &parentDateRanges)
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.