47 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem,
QgsMapLayer *currentLayer );
49 void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem,
QgsServerInterface *serverIface,
52 void appendLayerWgs84BoundingRect( QDomDocument &doc, QDomElement &layerElement,
const QgsRectangle &wgs84BoundingRect );
54 void appendLayerCrsExtents( QDomDocument &doc, QDomElement &layerElement,
const QMap<QString, QgsRectangle> &crsExtents );
56 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
57 const QString &crsText );
59 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
60 const QStringList &crsList,
const QStringList &constrainedCrsList );
62 void appendLayerStyles( QDomDocument &doc, QDomElement &layerElem,
const QgsWmsLayerInfos &layerInfos,
65 void appendLayersFromTreeGroup( QDomDocument &doc,
66 QDomElement &parentLayer,
69 const QgsWmsRequest &request,
71 const QMap< QString, QgsWmsLayerInfos > &wmsLayerInfos,
72 bool projectSettings );
74 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent );
81 bool projectSettings )
83#ifdef HAVE_SERVER_PYTHON_PLUGINS
88 const QDomDocument *capabilitiesDocument =
nullptr;
93 QStringList cacheKeyList;
94 cacheKeyList << ( projectSettings ? QStringLiteral(
"projectSettings" ) : request.
wmsParameters().
version() );
98#ifdef HAVE_SERVER_PYTHON_PLUGINS
102 QString cacheKey = cacheKeyList.join(
'-' );
104#ifdef HAVE_SERVER_PYTHON_PLUGINS
106 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
108 capabilitiesDocument = &doc;
111 if ( !capabilitiesDocument && cache )
116 if ( !capabilitiesDocument )
118 QgsMessageLog::logMessage( QStringLiteral(
"WMS capabilities document not found in cache" ), QStringLiteral(
"Server" ) );
120 doc =
getCapabilities( serverIface, project, request, projectSettings );
122#ifdef HAVE_SERVER_PYTHON_PLUGINS
126 capabilitiesDocument = &doc;
131 if ( !capabilitiesDocument )
136 if ( !capabilitiesDocument )
138 capabilitiesDocument = &doc;
150 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
151 response.
write( capabilitiesDocument->toByteArray() );
156 bool projectSettings )
159 QDomElement wmsCapabilitiesElement;
165 QString hrefString = href.toString();
166 hrefString.append( href.hasQuery() ?
"&" :
"?" );
169 QDomProcessingInstruction xmlDeclaration = doc.createProcessingInstruction( QStringLiteral(
"xml" ),
170 QStringLiteral(
"version=\"1.0\" encoding=\"utf-8\"" ) );
173 std::function < void ( QDomElement &,
const QString & ) > appendFormat = [&doc]( QDomElement & elem,
const QString & format )
175 QDomElement formatElem = doc.createElement( QStringLiteral(
"Format" ) );
176 formatElem.appendChild( doc.createTextNode( format ) );
177 elem.appendChild( formatElem );
182 doc = QDomDocument( QStringLiteral(
"WMT_MS_Capabilities SYSTEM 'http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd'" ) );
183 doc.appendChild( xmlDeclaration );
184 wmsCapabilitiesElement = doc.createElement( QStringLiteral(
"WMT_MS_Capabilities" ) );
188 doc.appendChild( xmlDeclaration );
189 wmsCapabilitiesElement = doc.createElement( QStringLiteral(
"WMS_Capabilities" ) );
190 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns" ), QStringLiteral(
"http://www.opengis.net/wms" ) );
191 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:sld" ), QStringLiteral(
"http://www.opengis.net/sld" ) );
192 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:qgs" ), QStringLiteral(
"http://www.qgis.org/wms" ) );
193 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
194 QString schemaLocation = QStringLiteral(
"http://www.opengis.net/wms" );
195 schemaLocation += QLatin1String(
" http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd" );
196 schemaLocation += QLatin1String(
" http://www.opengis.net/sld" );
197 schemaLocation += QLatin1String(
" http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd" );
201 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:inspire_common" ), QStringLiteral(
"http://inspire.ec.europa.eu/schemas/common/1.0" ) );
202 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:inspire_vs" ), QStringLiteral(
"http://inspire.ec.europa.eu/schemas/inspire_vs/1.0" ) );
203 schemaLocation += QLatin1String(
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0" );
204 schemaLocation += QLatin1String(
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0/inspire_vs.xsd" );
207 schemaLocation += QLatin1String(
" http://www.qgis.org/wms" );
208 schemaLocation +=
" " + hrefString +
"SERVICE=WMS&REQUEST=GetSchemaExtension";
210 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xsi:schemaLocation" ), schemaLocation );
212 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"version" ), request.
wmsParameters().
version() );
213 doc.appendChild( wmsCapabilitiesElement );
219 QDomElement capabilityElement =
getCapabilityElement( doc, project, request, projectSettings, serverIface );
220 wmsCapabilitiesElement.appendChild( capabilityElement );
222 if ( projectSettings )
231 capabilityElement.appendChild(
235 if ( projectSettings )
237 appendDrawingOrder( doc, capabilityElement, serverIface, project );
247 QDomElement serviceElem = doc.createElement( QStringLiteral(
"Service" ) );
250 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
251 QDomText nameText = doc.createTextNode( QStringLiteral(
"WMS" ) );
252 nameElem.appendChild( nameText );
253 serviceElem.appendChild( nameElem );
256 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
258 titleElem.appendChild( titleText );
259 serviceElem.appendChild( titleElem );
262 if ( !abstract.isEmpty() )
264 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
265 QDomText abstractText = doc.createCDATASection( abstract );
266 abstractElem.appendChild( abstractText );
267 serviceElem.appendChild( abstractElem );
270 addKeywordListElement( project, doc, serviceElem );
273 if ( onlineResource.isEmpty() )
275 onlineResource =
serviceUrl( request, project, *serverSettings ).toString();
277 QDomElement onlineResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
278 onlineResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
279 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
280 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), onlineResource );
281 serviceElem.appendChild( onlineResourceElem );
288 if ( !contactPerson.isEmpty() ||
289 !contactOrganization.isEmpty() ||
290 !contactPosition.isEmpty() ||
291 !contactMail.isEmpty() ||
292 !contactPhone.isEmpty() )
295 QDomElement contactInfoElem = doc.createElement( QStringLiteral(
"ContactInformation" ) );
298 if ( !contactPerson.isEmpty() ||
299 !contactOrganization.isEmpty() )
301 QDomElement contactPersonPrimaryElem = doc.createElement( QStringLiteral(
"ContactPersonPrimary" ) );
303 QDomText contactPersonText;
304 if ( !contactPerson.isEmpty() )
306 contactPersonText = doc.createTextNode( contactPerson );
310 contactPersonText = doc.createTextNode( QStringLiteral(
"unknown" ) );
312 QDomElement contactPersonElem = doc.createElement( QStringLiteral(
"ContactPerson" ) );
313 contactPersonElem.appendChild( contactPersonText );
314 contactPersonPrimaryElem.appendChild( contactPersonElem );
316 QDomText contactOrganizationText;
317 if ( !contactOrganization.isEmpty() )
319 contactOrganizationText = doc.createTextNode( contactOrganization );
323 contactOrganizationText = doc.createTextNode( QStringLiteral(
"unknown" ) );
325 QDomElement contactOrganizationElem = doc.createElement( QStringLiteral(
"ContactOrganization" ) );
326 contactOrganizationElem.appendChild( contactOrganizationText );
327 contactPersonPrimaryElem.appendChild( contactOrganizationElem );
329 contactInfoElem.appendChild( contactPersonPrimaryElem );
332 if ( !contactPosition.isEmpty() )
334 QDomElement contactPositionElem = doc.createElement( QStringLiteral(
"ContactPosition" ) );
335 QDomText contactPositionText = doc.createTextNode( contactPosition );
336 contactPositionElem.appendChild( contactPositionText );
337 contactInfoElem.appendChild( contactPositionElem );
340 if ( !contactPhone.isEmpty() )
342 QDomElement phoneElem = doc.createElement( QStringLiteral(
"ContactVoiceTelephone" ) );
343 QDomText phoneText = doc.createTextNode( contactPhone );
344 phoneElem.appendChild( phoneText );
345 contactInfoElem.appendChild( phoneElem );
348 if ( !contactMail.isEmpty() )
350 QDomElement mailElem = doc.createElement( QStringLiteral(
"ContactElectronicMailAddress" ) );
351 QDomText mailText = doc.createTextNode( contactMail );
352 mailElem.appendChild( mailText );
353 contactInfoElem.appendChild( mailElem );
356 serviceElem.appendChild( contactInfoElem );
359 QDomElement feesElem = doc.createElement( QStringLiteral(
"Fees" ) );
360 QDomText feesText = doc.createTextNode( QStringLiteral(
"None" ) );
362 if ( !fees.isEmpty() )
364 feesText = doc.createTextNode( fees );
366 feesElem.appendChild( feesText );
367 serviceElem.appendChild( feesElem );
369 QDomElement accessConstraintsElem = doc.createElement( QStringLiteral(
"AccessConstraints" ) );
370 QDomText accessConstraintsText = doc.createTextNode( QStringLiteral(
"None" ) );
372 if ( !accessConstraints.isEmpty() )
374 accessConstraintsText = doc.createTextNode( accessConstraints );
376 accessConstraintsElem.appendChild( accessConstraintsText );
377 serviceElem.appendChild( accessConstraintsElem );
384 QDomElement maxWidthElem = doc.createElement( QStringLiteral(
"MaxWidth" ) );
385 QDomText maxWidthText = doc.createTextNode( QString::number( maxWidth ) );
386 maxWidthElem.appendChild( maxWidthText );
387 serviceElem.appendChild( maxWidthElem );
393 QDomElement maxHeightElem = doc.createElement( QStringLiteral(
"MaxHeight" ) );
394 QDomText maxHeightText = doc.createTextNode( QString::number( maxHeight ) );
395 maxHeightElem.appendChild( maxHeightText );
396 serviceElem.appendChild( maxHeightElem );
413 QString hrefString = href.toString();
414 hrefString.append( href.hasQuery() ?
"&" :
"?" );
416 QDomElement capabilityElem = doc.createElement( QStringLiteral(
"Capability" ) );
419 QDomElement requestElem = doc.createElement( QStringLiteral(
"Request" ) );
420 capabilityElem.appendChild( requestElem );
422 QDomElement dcpTypeElem = doc.createElement( QStringLiteral(
"DCPType" ) );
423 QDomElement httpElem = doc.createElement( QStringLiteral(
"HTTP" ) );
424 dcpTypeElem.appendChild( httpElem );
427 std::function < void ( QDomElement &,
const QString & ) > appendFormat = [&doc]( QDomElement & elem,
const QString & format )
429 QDomElement formatElem = doc.createElement( QStringLiteral(
"Format" ) );
430 formatElem.appendChild( doc.createTextNode( format ) );
431 elem.appendChild( formatElem );
437 elem = doc.createElement( QStringLiteral(
"GetCapabilities" ) );
438 appendFormat( elem, ( version == QLatin1String(
"1.1.1" ) ?
"application/vnd.ogc.wms_xml" :
"text/xml" ) );
439 elem.appendChild( dcpTypeElem );
440 requestElem.appendChild( elem );
443 QDomElement getElem = doc.createElement( QStringLiteral(
"Get" ) );
444 httpElem.appendChild( getElem );
445 QDomElement olResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
446 olResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
447 olResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
448 olResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), hrefString );
449 getElem.appendChild( olResourceElem );
452 elem = doc.createElement( QStringLiteral(
"GetMap" ) );
453 appendFormat( elem, QStringLiteral(
"image/jpeg" ) );
454 appendFormat( elem, QStringLiteral(
"image/png" ) );
455 appendFormat( elem, QStringLiteral(
"image/png; mode=16bit" ) );
456 appendFormat( elem, QStringLiteral(
"image/png; mode=8bit" ) );
457 appendFormat( elem, QStringLiteral(
"image/png; mode=1bit" ) );
458 appendFormat( elem, QStringLiteral(
"application/dxf" ) );
459 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
460 requestElem.appendChild( elem );
463 elem = doc.createElement( QStringLiteral(
"GetFeatureInfo" ) );
464 appendFormat( elem, QStringLiteral(
"text/plain" ) );
465 appendFormat( elem, QStringLiteral(
"text/html" ) );
466 appendFormat( elem, QStringLiteral(
"text/xml" ) );
467 appendFormat( elem, QStringLiteral(
"application/vnd.ogc.gml" ) );
468 appendFormat( elem, QStringLiteral(
"application/vnd.ogc.gml/3.1.1" ) );
469 appendFormat( elem, QStringLiteral(
"application/json" ) );
470 appendFormat( elem, QStringLiteral(
"application/geo+json" ) );
471 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
472 requestElem.appendChild( elem );
475 elem = doc.createElement( ( version == QLatin1String(
"1.1.1" ) ?
"GetLegendGraphic" :
"sld:GetLegendGraphic" ) );
476 appendFormat( elem, QStringLiteral(
"image/jpeg" ) );
477 appendFormat( elem, QStringLiteral(
"image/png" ) );
478 appendFormat( elem, QStringLiteral(
"application/json" ) );
479 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
480 requestElem.appendChild( elem );
483 elem = doc.createElement( ( version == QLatin1String(
"1.1.1" ) ?
"DescribeLayer" :
"sld:DescribeLayer" ) );
484 appendFormat( elem, QStringLiteral(
"text/xml" ) );
485 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
486 requestElem.appendChild( elem );
489 elem = doc.createElement( ( version == QLatin1String(
"1.1.1" ) ?
"GetStyles" :
"qgs:GetStyles" ) );
490 appendFormat( elem, QStringLiteral(
"text/xml" ) );
491 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
492 requestElem.appendChild( elem );
498 elem = doc.createElement( QStringLiteral(
"GetPrint" ) );
499 appendFormat( elem, QStringLiteral(
"svg" ) );
500 appendFormat( elem, QStringLiteral(
"png" ) );
501 appendFormat( elem, QStringLiteral(
"pdf" ) );
502 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
503 requestElem.appendChild( elem );
507 elem = doc.createElement( QStringLiteral(
"Exception" ) );
508 appendFormat( elem, ( version == QLatin1String(
"1.1.1" ) ?
"application/vnd.ogc.se_xml" :
"XML" ) );
509 capabilityElem.appendChild( elem );
512 if ( version == QLatin1String(
"1.3.0" ) )
514 elem = doc.createElement( QStringLiteral(
"sld:UserDefinedSymbolization" ) );
515 elem.setAttribute( QStringLiteral(
"SupportSLD" ), QStringLiteral(
"1" ) );
516 elem.setAttribute( QStringLiteral(
"UserLayer" ), QStringLiteral(
"0" ) );
517 elem.setAttribute( QStringLiteral(
"UserStyle" ), QStringLiteral(
"1" ) );
518 elem.setAttribute( QStringLiteral(
"RemoteWFS" ), QStringLiteral(
"0" ) );
519 elem.setAttribute( QStringLiteral(
"InlineFeature" ), QStringLiteral(
"0" ) );
520 elem.setAttribute( QStringLiteral(
"RemoteWCS" ), QStringLiteral(
"0" ) );
521 capabilityElem.appendChild( elem );
529 return capabilityElem;
534 QDomElement inspireCapabilitiesElem;
537 return inspireCapabilitiesElem;
539 inspireCapabilitiesElem = doc.createElement( QStringLiteral(
"inspire_vs:ExtendedCapabilities" ) );
543 if ( !inspireMetadataUrl.isEmpty() )
545 QDomElement inspireCommonMetadataUrlElem = doc.createElement( QStringLiteral(
"inspire_common:MetadataUrl" ) );
546 inspireCommonMetadataUrlElem.setAttribute( QStringLiteral(
"xsi:type" ), QStringLiteral(
"inspire_common:resourceLocatorType" ) );
548 QDomElement inspireCommonMetadataUrlUrlElem = doc.createElement( QStringLiteral(
"inspire_common:URL" ) );
549 inspireCommonMetadataUrlUrlElem.appendChild( doc.createTextNode( inspireMetadataUrl ) );
550 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlUrlElem );
553 if ( !inspireMetadataUrlType.isNull() )
555 QDomElement inspireCommonMetadataUrlMediaTypeElem = doc.createElement( QStringLiteral(
"inspire_common:MediaType" ) );
556 inspireCommonMetadataUrlMediaTypeElem.appendChild( doc.createTextNode( inspireMetadataUrlType ) );
557 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlMediaTypeElem );
560 inspireCapabilitiesElem.appendChild( inspireCommonMetadataUrlElem );
564 QDomElement inspireCommonResourceTypeElem = doc.createElement( QStringLiteral(
"inspire_common:ResourceType" ) );
565 inspireCommonResourceTypeElem.appendChild( doc.createTextNode( QStringLiteral(
"service" ) ) );
566 inspireCapabilitiesElem.appendChild( inspireCommonResourceTypeElem );
568 QDomElement inspireCommonSpatialDataServiceTypeElem = doc.createElement( QStringLiteral(
"inspire_common:SpatialDataServiceType" ) );
569 inspireCommonSpatialDataServiceTypeElem.appendChild( doc.createTextNode( QStringLiteral(
"view" ) ) );
570 inspireCapabilitiesElem.appendChild( inspireCommonSpatialDataServiceTypeElem );
573 if ( !inspireTemporalReference.isNull() )
575 QDomElement inspireCommonTemporalReferenceElem = doc.createElement( QStringLiteral(
"inspire_common:TemporalReference" ) );
576 QDomElement inspireCommonDateOfLastRevisionElem = doc.createElement( QStringLiteral(
"inspire_common:DateOfLastRevision" ) );
577 inspireCommonDateOfLastRevisionElem.appendChild( doc.createTextNode( inspireTemporalReference ) );
578 inspireCommonTemporalReferenceElem.appendChild( inspireCommonDateOfLastRevisionElem );
579 inspireCapabilitiesElem.appendChild( inspireCommonTemporalReferenceElem );
582 QDomElement inspireCommonMetadataPointOfContactElem = doc.createElement( QStringLiteral(
"inspire_common:MetadataPointOfContact" ) );
585 QDomElement inspireCommonOrganisationNameElem = doc.createElement( QStringLiteral(
"inspire_common:OrganisationName" ) );
586 if ( !contactOrganization.isNull() )
588 inspireCommonOrganisationNameElem.appendChild( doc.createTextNode( contactOrganization ) );
590 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonOrganisationNameElem );
593 QDomElement inspireCommonEmailAddressElem = doc.createElement( QStringLiteral(
"inspire_common:EmailAddress" ) );
594 if ( !contactMail.isNull() )
596 inspireCommonEmailAddressElem.appendChild( doc.createTextNode( contactMail ) );
598 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonEmailAddressElem );
600 inspireCapabilitiesElem.appendChild( inspireCommonMetadataPointOfContactElem );
603 if ( !inspireMetadataDate.isNull() )
605 QDomElement inspireCommonMetadataDateElem = doc.createElement( QStringLiteral(
"inspire_common:MetadataDate" ) );
606 inspireCommonMetadataDateElem.appendChild( doc.createTextNode( inspireMetadataDate ) );
607 inspireCapabilitiesElem.appendChild( inspireCommonMetadataDateElem );
612 QDomElement inspireCommonSupportedLanguagesElem = doc.createElement( QStringLiteral(
"inspire_common:SupportedLanguages" ) );
613 inspireCommonSupportedLanguagesElem.setAttribute( QStringLiteral(
"xsi:type" ), QStringLiteral(
"inspire_common:supportedLanguagesType" ) );
615 QDomElement inspireCommonLanguageElem = doc.createElement( QStringLiteral(
"inspire_common:Language" ) );
618 QDomElement inspireCommonDefaultLanguageElem = doc.createElement( QStringLiteral(
"inspire_common:DefaultLanguage" ) );
619 inspireCommonDefaultLanguageElem.appendChild( inspireCommonLanguageElem );
620 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonDefaultLanguageElem );
624 QDomElement inspireCommonSupportedLanguageElem = doc.createElement(
"inspire_common:SupportedLanguage" );
625 inspireCommonSupportedLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
626 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonSupportedLanguageElem );
629 inspireCapabilitiesElem.appendChild( inspireCommonSupportedLanguagesElem );
631 QDomElement inspireCommonResponseLanguageElem = doc.createElement( QStringLiteral(
"inspire_common:ResponseLanguage" ) );
632 inspireCommonResponseLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
633 inspireCapabilitiesElem.appendChild( inspireCommonResponseLanguageElem );
635 return inspireCapabilitiesElem;
641 if ( projectComposers.size() == 0 )
642 return QDomElement();
646 QDomElement composerTemplatesElem = doc.createElement( QStringLiteral(
"ComposerTemplates" ) );
647 QList<QgsPrintLayout *>::const_iterator cIt = projectComposers.constBegin();
648 for ( ; cIt != projectComposers.constEnd(); ++cIt )
651 if ( restrictedComposers.contains( layout->
name() ) )
663 QDomElement composerTemplateElem = doc.createElement( QStringLiteral(
"ComposerTemplate" ) );
664 composerTemplateElem.setAttribute( QStringLiteral(
"name" ), layout->
name() );
667 composerTemplateElem.setAttribute( QStringLiteral(
"width" ), width.
length() );
668 composerTemplateElem.setAttribute( QStringLiteral(
"height" ), height.
length() );
672 if ( atlas && atlas->
enabled() )
674 composerTemplateElem.setAttribute( QStringLiteral(
"atlasEnabled" ), QStringLiteral(
"1" ) );
681 layerName = cLayer->
id();
683 else if ( layerName.isEmpty() )
685 layerName = cLayer->
name();
687 composerTemplateElem.setAttribute( QStringLiteral(
"atlasCoverageLayer" ), layerName );
692 QList<QgsLayoutItemMap *> layoutMapList;
694 QList<QgsLayoutItemMap *>::const_iterator cmIt = layoutMapList.constBegin();
697 for ( ; cmIt != layoutMapList.constEnd(); ++cmIt )
701 QDomElement composerMapElem = doc.createElement( QStringLiteral(
"ComposerMap" ) );
702 composerMapElem.setAttribute( QStringLiteral(
"name" ), QStringLiteral(
"map%1" ).arg( mapId ) );
703 composerMapElem.setAttribute( QStringLiteral(
"itemName" ), composerMap->
displayName() );
705 composerMapElem.setAttribute( QStringLiteral(
"width" ), composerMap->rect().width() );
706 composerMapElem.setAttribute( QStringLiteral(
"height" ), composerMap->rect().height() );
707 composerTemplateElem.appendChild( composerMapElem );
711 QList<QgsLayoutItemLabel *> composerLabelList;
713 QList<QgsLayoutItemLabel *>::const_iterator clIt = composerLabelList.constBegin();
714 for ( ; clIt != composerLabelList.constEnd(); ++clIt )
717 QString
id = composerLabel->
id();
721 QDomElement composerLabelElem = doc.createElement( QStringLiteral(
"ComposerLabel" ) );
722 composerLabelElem.setAttribute( QStringLiteral(
"name" ), id );
723 composerTemplateElem.appendChild( composerLabelElem );
727 QList<QgsLayoutItemHtml *> composerHtmlList;
729 QList<QgsLayoutItemHtml *>::const_iterator chIt = composerHtmlList.constBegin();
730 for ( ; chIt != composerHtmlList.constEnd(); ++chIt )
736 QString
id = composerHtml->
frame( 0 )->
id();
740 QDomElement composerHtmlElem = doc.createElement( QStringLiteral(
"ComposerHtml" ) );
741 composerHtmlElem.setAttribute( QStringLiteral(
"name" ), id );
742 composerTemplateElem.appendChild( composerHtmlElem );
745 composerTemplatesElem.appendChild( composerTemplateElem );
748 if ( composerTemplatesElem.childNodes().size() == 0 )
749 return QDomElement();
751 return composerTemplatesElem;
758 return QDomElement();
760 QDomElement wfsLayersElem = doc.createElement( QStringLiteral(
"WFSLayers" ) );
764 if ( ! layer || layer->
type() != Qgis::LayerType::Vector )
769 QDomElement wfsLayerElem = doc.createElement( QStringLiteral(
"WFSLayer" ) );
772 wfsLayerElem.setAttribute( QStringLiteral(
"name" ), layer->
id() );
776 wfsLayerElem.setAttribute( QStringLiteral(
"name" ), layer->
name() );
778 wfsLayersElem.appendChild( wfsLayerElem );
781 return wfsLayersElem;
785 QDomElement &parentLayer,
790 const QMap< QString, QgsWmsLayerInfos > &wmsLayerInfos,
791 bool projectSettings )
795 parentLayer.setAttribute(
796 QStringLiteral(
"queryable" ),
797 hasQueryableLayers( layerIds, wmsLayerInfos ) ? QStringLiteral(
"1" ) : QStringLiteral(
"0" )
801 QMap<QString, QgsRectangle> crsExtents =
combineCrsExtents( layerIds, wmsLayerInfos );
803 appendCrsElementsToLayer( doc, parentLayer, crsExtents.keys(), QStringList() );
804 appendLayerWgs84BoundingRect( doc, parentLayer, wgs84BoundingRect );
805 appendLayerCrsExtents( doc, parentLayer, crsExtents );
807 appendLayersFromTreeGroup( doc, parentLayer, serverIface, project, request, layerTreeGroup, wmsLayerInfos, projectSettings );
816 QDomElement layerParentElem = doc.createElement( QStringLiteral(
"Layer" ) );
820 if ( rootLayerName.isEmpty() && !project->
title().isEmpty() )
822 rootLayerName = project->
title();
825 if ( !rootLayerName.isEmpty() )
827 QDomElement layerParentNameElem = doc.createElement( QStringLiteral(
"Name" ) );
828 QDomText layerParentNameText = doc.createTextNode( rootLayerName );
829 layerParentNameElem.appendChild( layerParentNameText );
830 layerParentElem.appendChild( layerParentNameElem );
834 QDomElement layerParentTitleElem = doc.createElement( QStringLiteral(
"Title" ) );
836 layerParentTitleElem.appendChild( layerParentTitleText );
837 layerParentElem.appendChild( layerParentTitleElem );
841 if ( !rootLayerAbstract.isEmpty() )
843 QDomElement layerParentAbstElem = doc.createElement( QStringLiteral(
"Abstract" ) );
844 QDomText layerParentAbstText = doc.createCDATASection( rootLayerAbstract );
845 layerParentAbstElem.appendChild( layerParentAbstText );
846 layerParentElem.appendChild( layerParentAbstElem );
850 addKeywordListElement( project, doc, layerParentElem );
853 if ( projectSettings )
855 QDomElement treeNameElem = doc.createElement( QStringLiteral(
"TreeName" ) );
856 QDomText treeNameText = doc.createTextNode( project->
title() );
857 treeNameElem.appendChild( treeNameText );
858 layerParentElem.appendChild( treeNameElem );
864 auto outputCrsList = QList<QgsCoordinateReferenceSystem>();
870 outputCrsList.append(
crs );
894 QStringLiteral(
"Error transforming extent: %1" ).arg( cse.
what() ),
895 QStringLiteral(
"Server" ),
896 Qgis::MessageLevel::Warning
901 QMap< QString, QgsRectangle > wmsCrsExtents;
910 QgsMessageLog::logMessage( QStringLiteral(
"Error transforming extent: %1" ).arg( cse.
what() ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Warning );
913 layerParentElem.setAttribute(
914 QStringLiteral(
"queryable" ),
918 appendCrsElementsToLayer( doc, layerParentElem, wmsCrsExtents.keys(), QStringList() );
919 appendLayerWgs84BoundingRect( doc, layerParentElem, wmsWgs84BoundingRect );
920 appendLayerCrsExtents( doc, layerParentElem, wmsCrsExtents );
922 appendLayersFromTreeGroup( doc, layerParentElem, serverIface, project, request, projectLayerTreeRoot, wmsLayerInfos, projectSettings );
926 handleLayersFromTreeGroup( doc, layerParentElem, serverIface, project, request, projectLayerTreeRoot, wmsLayerInfos, projectSettings );
929 return layerParentElem;
935 void appendLayersFromTreeGroup( QDomDocument &doc,
936 QDomElement &parentLayer,
939 const QgsWmsRequest &request,
941 const QMap< QString, QgsWmsLayerInfos > &wmsLayerInfos,
942 bool projectSettings )
944 const QString version = request.wmsParameters().version();
949 QList< QgsLayerTreeNode * > layerTreeGroupChildren = layerTreeGroup->
children();
950 for (
int i = 0; i < layerTreeGroupChildren.size(); ++i )
953 QDomElement layerElem = doc.createElement( QStringLiteral(
"Layer" ) );
955 if ( projectSettings )
957 layerElem.setAttribute( QStringLiteral(
"visible" ), treeNode->
isVisible() );
959 layerElem.setAttribute( QStringLiteral(
"expanded" ), treeNode->
isExpanded() );
966 QString name = treeGroupChild->
name();
967 if ( restrictedLayers.contains( name ) )
972 if ( projectSettings )
974 layerElem.setAttribute( QStringLiteral(
"mutuallyExclusive" ), treeGroupChild->
isMutuallyExclusive() );
977 QString shortName = treeGroupChild->
customProperty( QStringLiteral(
"wmsShortName" ) ).toString();
978 QString title = treeGroupChild->
customProperty( QStringLiteral(
"wmsTitle" ) ).toString();
980 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
982 if ( !shortName.isEmpty() )
983 nameText = doc.createTextNode( shortName );
985 nameText = doc.createTextNode( name );
986 nameElem.appendChild( nameText );
987 layerElem.appendChild( nameElem );
989 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
991 if ( !title.isEmpty() )
992 titleText = doc.createTextNode( title );
994 titleText = doc.createTextNode( name );
995 titleElem.appendChild( titleText );
996 layerElem.appendChild( titleElem );
998 QString abstract = treeGroupChild->
customProperty( QStringLiteral(
"wmsAbstract" ) ).toString();
999 if ( !abstract.isEmpty() )
1001 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
1002 QDomText abstractText = doc.createTextNode( abstract );
1003 abstractElem.appendChild( abstractText );
1004 layerElem.appendChild( abstractElem );
1008 if ( projectSettings )
1010 QDomElement treeNameElem = doc.createElement( QStringLiteral(
"TreeName" ) );
1011 QDomText treeNameText = doc.createTextNode( name );
1012 treeNameElem.appendChild( treeNameText );
1013 layerElem.appendChild( treeNameElem );
1016 handleLayersFromTreeGroup( doc, layerElem, serverIface, project, request, treeGroupChild, wmsLayerInfos, projectSettings );
1019 if ( layerElem.elementsByTagName( QStringLiteral(
"Layer" ) ).length() == 0 )
1028 if ( !wmsLayerInfos.contains( treeLayer->
layerId() ) )
1035 layerElem.setAttribute(
1036 QStringLiteral(
"queryable" ),
1037 layerInfos.
queryable ? QStringLiteral(
"1" ) : QStringLiteral(
"0" )
1040 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
1041 QDomText nameText = doc.createTextNode( layerInfos.
name );
1042 nameElem.appendChild( nameText );
1043 layerElem.appendChild( nameElem );
1045 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
1046 QDomText titleText = doc.createTextNode( layerInfos.
title );
1047 titleElem.appendChild( titleText );
1048 layerElem.appendChild( titleElem );
1050 if ( ! layerInfos.
abstract.isEmpty() )
1052 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
1053 QDomText abstractText = doc.createTextNode( layerInfos.
abstract );
1054 abstractElem.appendChild( abstractText );
1055 layerElem.appendChild( abstractElem );
1059 if ( ! layerInfos.
keywords.isEmpty() )
1061 QDomElement keywordListElem = doc.createElement( QStringLiteral(
"KeywordList" ) );
1062 for (
const QString &keyword : std::as_const( layerInfos.
keywords ) )
1064 QDomElement keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1065 QDomText keywordText = doc.createTextNode( keyword.trimmed() );
1066 keywordElem.appendChild( keywordText );
1069 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"SIA_Geo405" ) );
1071 keywordListElem.appendChild( keywordElem );
1073 layerElem.appendChild( keywordListElem );
1079 appendCrsElementsToLayer( doc, layerElem, layerInfos.
crsExtents.keys(), QStringList() );
1083 appendLayerCrsExtents( doc, layerElem, layerInfos.
crsExtents );
1087 appendLayerStyles( doc, layerElem, layerInfos, project, request, serverIface->
serverSettings() );
1092 if ( version == QLatin1String(
"1.1.1" ) )
1095 double SCALE_TO_SCALEHINT =
OGC_PX_M * M_SQRT2;
1097 QDomElement scaleHintElem = doc.createElement( QStringLiteral(
"ScaleHint" ) );
1098 scaleHintElem.setAttribute( QStringLiteral(
"min" ), QString::number( layerInfos.
maxScale * SCALE_TO_SCALEHINT ) );
1099 scaleHintElem.setAttribute( QStringLiteral(
"max" ), QString::number( layerInfos.
minScale * SCALE_TO_SCALEHINT ) );
1100 layerElem.appendChild( scaleHintElem );
1104 QDomElement minScaleElem = doc.createElement( QStringLiteral(
"MinScaleDenominator" ) );
1105 QDomText minScaleText = doc.createTextNode( QString::number( layerInfos.
maxScale ) );
1106 minScaleElem.appendChild( minScaleText );
1107 layerElem.appendChild( minScaleElem );
1109 QDomElement maxScaleElem = doc.createElement( QStringLiteral(
"MaxScaleDenominator" ) );
1110 QDomText maxScaleText = doc.createTextNode( QString::number( layerInfos.
minScale ) );
1111 maxScaleElem.appendChild( maxScaleText );
1112 layerElem.appendChild( maxScaleElem );
1117 if ( !layerInfos.
dataUrl.isEmpty() )
1119 QDomElement dataUrlElem = doc.createElement( QStringLiteral(
"DataURL" ) );
1120 QDomElement dataUrlFormatElem = doc.createElement( QStringLiteral(
"Format" ) );
1122 QDomText dataUrlFormatText = doc.createTextNode( dataUrlFormat );
1123 dataUrlFormatElem.appendChild( dataUrlFormatText );
1124 dataUrlElem.appendChild( dataUrlFormatElem );
1125 QDomElement dataORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1126 dataORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1127 dataORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1128 dataORElem.setAttribute( QStringLiteral(
"xlink:href" ), layerInfos.
dataUrl );
1129 dataUrlElem.appendChild( dataORElem );
1130 layerElem.appendChild( dataUrlElem );
1136 QDomElement attribElem = doc.createElement( QStringLiteral(
"Attribution" ) );
1137 QDomElement attribTitleElem = doc.createElement( QStringLiteral(
"Title" ) );
1138 QDomText attribText = doc.createTextNode( layerInfos.
attribution );
1139 attribTitleElem.appendChild( attribText );
1140 attribElem.appendChild( attribTitleElem );
1143 QDomElement attribORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1144 attribORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1145 attribORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1146 attribORElem.setAttribute( QStringLiteral(
"xlink:href" ), layerInfos.
attributionUrl );
1147 attribElem.appendChild( attribORElem );
1149 layerElem.appendChild( attribElem );
1155 QDomElement metaUrlElem = doc.createElement( QStringLiteral(
"MetadataURL" ) );
1156 const QString metadataUrlType = metadataUrl.type;
1157 if ( version == QLatin1String(
"1.1.1" ) )
1159 metaUrlElem.setAttribute( QStringLiteral(
"type" ), metadataUrlType );
1161 else if ( metadataUrlType == QLatin1String(
"FGDC" ) )
1163 metaUrlElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"FGDC:1998" ) );
1165 else if ( metadataUrlType == QLatin1String(
"TC211" ) )
1167 metaUrlElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"ISO19115:2003" ) );
1171 metaUrlElem.setAttribute( QStringLiteral(
"type" ), metadataUrlType );
1173 const QString metadataUrlFormat = metadataUrl.format;
1174 if ( !metadataUrlFormat.isEmpty() )
1176 QDomElement metaUrlFormatElem = doc.createElement( QStringLiteral(
"Format" ) );
1177 QDomText metaUrlFormatText = doc.createTextNode( metadataUrlFormat );
1178 metaUrlFormatElem.appendChild( metaUrlFormatText );
1179 metaUrlElem.appendChild( metaUrlFormatElem );
1181 QDomElement metaUrlORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1182 metaUrlORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1183 metaUrlORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1184 metaUrlORElem.setAttribute( QStringLiteral(
"xlink:href" ), metadataUrl.url );
1185 metaUrlElem.appendChild( metaUrlORElem );
1186 layerElem.appendChild( metaUrlElem );
1189 bool timeDimensionAdded {
false };
1192 if ( l->
type() == Qgis::LayerType::Vector )
1196 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> wmsDims = serverProperties->
wmsDimensions();
1202 if ( fieldIndex == -1 )
1207 QSet<QVariant> uniqueValues = vl->
uniqueValues( fieldIndex );
1210 if ( !dim.endFieldName.isEmpty() )
1212 int endFieldIndex = vl->
fields().
indexOf( dim.endFieldName );
1214 if ( endFieldIndex == -1 )
1218 uniqueValues.unite( vl->
uniqueValues( endFieldIndex ) );
1221 QList<QVariant> values = qgis::setToList( uniqueValues );
1222 std::sort( values.begin(), values.end() );
1224 QDomElement dimElem = doc.createElement( QStringLiteral(
"Dimension" ) );
1225 dimElem.setAttribute( QStringLiteral(
"name" ), dim.name );
1227 if ( dim.name.toUpper() == QLatin1String(
"TIME" ) )
1229 timeDimensionAdded =
true;
1232 if ( !dim.units.isEmpty() )
1234 dimElem.setAttribute( QStringLiteral(
"units" ), dim.units );
1236 if ( !dim.unitSymbol.isEmpty() )
1238 dimElem.setAttribute( QStringLiteral(
"unitSymbol" ), dim.unitSymbol );
1242 dimElem.setAttribute( QStringLiteral(
"default" ), values.first().toString() );
1246 dimElem.setAttribute( QStringLiteral(
"default" ), values.last().toString() );
1250 dimElem.setAttribute( QStringLiteral(
"default" ), dim.referenceValue.toString() );
1252 dimElem.setAttribute( QStringLiteral(
"multipleValues" ), QStringLiteral(
"1" ) );
1253 dimElem.setAttribute( QStringLiteral(
"nearestValue" ), QStringLiteral(
"0" ) );
1254 if ( projectSettings )
1256 dimElem.setAttribute( QStringLiteral(
"fieldName" ), dim.fieldName );
1257 dimElem.setAttribute( QStringLiteral(
"endFieldName" ), dim.endFieldName );
1260 QStringList strValues;
1261 for (
const QVariant &v : values )
1263 strValues << v.toString();
1265 QDomText dimValuesText = doc.createTextNode( strValues.join( QLatin1String(
", " ) ) );
1266 dimElem.appendChild( dimValuesText );
1267 layerElem.appendChild( dimElem );
1272 if ( ! timeDimensionAdded
1277 QDomElement dimElem = doc.createElement( QStringLiteral(
"Dimension" ) );
1278 dimElem.setAttribute( QStringLiteral(
"name" ), QStringLiteral(
"TIME" ) );
1279 dimElem.setAttribute( QStringLiteral(
"units" ), QStringLiteral(
"ISO8601" ) );
1289 bool isDateList {
true };
1290 bool isInstantList {
true };
1292 QList<QDateTime> values;
1293 for (
const auto &r : std::as_const( allRanges ) )
1295 if ( r.isInstant() )
1297 if ( r.begin().time() != QTime( 0, 0, 0, 0 ) )
1301 values.append( r.begin() );
1305 isInstantList =
false;
1312 if ( isInstantList )
1315 QStringList strValues;
1316 for (
const auto &v : values )
1320 strValues << v.date().toString( Qt::DateFormat::ISODate );
1324 strValues << v.toString( Qt::DateFormat::ISODate );
1327 QDomText dimValuesText = doc.createTextNode( strValues.join( QChar(
',' ) ) );
1328 dimElem.appendChild( dimValuesText );
1331 layerElem.appendChild( dimElem );
1333 QDomElement timeExtentElem = doc.createElement( QStringLiteral(
"Extent" ) );
1334 timeExtentElem.setAttribute( QStringLiteral(
"name" ), QStringLiteral(
"TIME" ) );
1340 extent = QStringLiteral(
"%1/%2" ).arg( timeExtent.begin().date().toString( Qt::DateFormat::ISODate ), timeExtent.end().date().toString( Qt::DateFormat::ISODate ) );
1344 extent = QStringLiteral(
"%1/%2" ).arg( timeExtent.begin().toString( Qt::DateFormat::ISODate ), timeExtent.end().toString( Qt::DateFormat::ISODate ) );
1346 QDomText extentValueText = doc.createTextNode( extent );
1347 timeExtentElem.appendChild( extentValueText );
1348 layerElem.appendChild( timeExtentElem );
1352 if ( projectSettings )
1354 appendLayerProjectSettings( doc, layerElem, l );
1358 parentLayer.appendChild( layerElem );
1362 void appendLayerStyles( QDomDocument &doc, QDomElement &layerElem,
const QgsWmsLayerInfos &layerInfos,
1366 QUrl href =
serviceUrl( request, project, *settings );
1369 QString hrefString = href.toString();
1370 hrefString.append( href.hasQuery() ?
"&" :
"?" );
1371 for (
const QString &styleName : std::as_const( layerInfos.
styles ) )
1373 QDomElement styleElem = doc.createElement( QStringLiteral(
"Style" ) );
1374 QDomElement styleNameElem = doc.createElement( QStringLiteral(
"Name" ) );
1375 QDomText styleNameText = doc.createTextNode( styleName );
1376 styleNameElem.appendChild( styleNameText );
1377 QDomElement styleTitleElem = doc.createElement( QStringLiteral(
"Title" ) );
1378 QDomText styleTitleText = doc.createTextNode( styleName );
1379 styleTitleElem.appendChild( styleTitleText );
1380 styleElem.appendChild( styleNameElem );
1381 styleElem.appendChild( styleTitleElem );
1384 QDomElement getLayerLegendGraphicElem = doc.createElement( QStringLiteral(
"LegendURL" ) );
1386 QString customHrefString = layerInfos.
legendUrl;
1388 QStringList getLayerLegendGraphicFormats;
1389 if ( !customHrefString.isEmpty() )
1395 getLayerLegendGraphicFormats << QStringLiteral(
"image/png" );
1398 for (
const QString &getLayerLegendGraphicFormat : std::as_const( getLayerLegendGraphicFormats ) )
1400 QDomElement getLayerLegendGraphicFormatElem = doc.createElement( QStringLiteral(
"Format" ) );
1401 QDomText getLayerLegendGraphicFormatText = doc.createTextNode( getLayerLegendGraphicFormat );
1402 getLayerLegendGraphicFormatElem.appendChild( getLayerLegendGraphicFormatText );
1403 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicFormatElem );
1407 if ( customHrefString.isEmpty() )
1409 QUrl mapUrl( hrefString );
1410 QUrlQuery mapUrlQuery( mapUrl.query() );
1411 mapUrlQuery.addQueryItem( QStringLiteral(
"SERVICE" ), QStringLiteral(
"WMS" ) );
1412 mapUrlQuery.addQueryItem( QStringLiteral(
"VERSION" ), request.wmsParameters().version() );
1413 mapUrlQuery.addQueryItem( QStringLiteral(
"REQUEST" ), QStringLiteral(
"GetLegendGraphic" ) );
1414 mapUrlQuery.addQueryItem( QStringLiteral(
"LAYER" ), layerInfos.
name );
1415 mapUrlQuery.addQueryItem( QStringLiteral(
"FORMAT" ), QStringLiteral(
"image/png" ) );
1416 mapUrlQuery.addQueryItem( QStringLiteral(
"STYLE" ), styleName );
1417 if ( request.wmsParameters().version() == QLatin1String(
"1.3.0" ) )
1419 mapUrlQuery.addQueryItem( QStringLiteral(
"SLD_VERSION" ), QStringLiteral(
"1.1.0" ) );
1421 mapUrl.setQuery( mapUrlQuery );
1422 customHrefString = mapUrl.toString();
1425 QDomElement getLayerLegendGraphicORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1426 getLayerLegendGraphicORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1427 getLayerLegendGraphicORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1428 getLayerLegendGraphicORElem.setAttribute( QStringLiteral(
"xlink:href" ), customHrefString );
1429 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicORElem );
1430 styleElem.appendChild( getLayerLegendGraphicElem );
1432 layerElem.appendChild( styleElem );
1436 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
1437 const QStringList &crsList,
const QStringList &constrainedCrsList )
1439 if ( layerElement.isNull() )
1444 const QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1447 QDomElement titleElement = layerElement.firstChildElement( QStringLiteral(
"Title" ) );
1448 QDomElement abstractElement = layerElement.firstChildElement( QStringLiteral(
"Abstract" ) );
1449 QDomElement keywordListElement = layerElement.firstChildElement( QStringLiteral(
"KeywordList" ) );
1450 QDomElement CRSPrecedingElement = !keywordListElement.isNull() ? keywordListElement : !abstractElement.isNull() ? abstractElement : titleElement;
1452 if ( CRSPrecedingElement.isNull() )
1455 const QDomElement keyElement = layerElement.firstChildElement( QStringLiteral(
"KeywordList" ) );
1456 CRSPrecedingElement = keyElement;
1460 if ( !constrainedCrsList.isEmpty() )
1462 for (
int i = constrainedCrsList.size() - 1; i >= 0; --i )
1464 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, constrainedCrsList.at( i ) );
1469 for (
const QString &
crs : crsList )
1471 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement,
crs );
1477 if ( version == QLatin1String(
"1.3.0" ) )
1479 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, QString(
"CRS:84" ) );
1483 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
1484 const QString &crsText )
1486 if ( crsText.isEmpty() )
1488 const QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1489 QDomElement crsElement = doc.createElement( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS" );
1490 QDomText crsTextNode = doc.createTextNode( crsText );
1491 crsElement.appendChild( crsTextNode );
1492 layerElement.insertAfter( crsElement, precedingElement );
1495 void appendLayerWgs84BoundingRect( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &wgs84BoundingRect )
1498 if ( wgs84BoundingRect.
isNull() )
1504 QDomElement ExGeoBBoxElement;
1505 const int wgs84precision = 6;
1506 const QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1507 if ( version == QLatin1String(
"1.1.1" ) )
1509 ExGeoBBoxElement = doc.createElement( QStringLiteral(
"LatLonBoundingBox" ) );
1517 ExGeoBBoxElement = doc.createElement( QStringLiteral(
"EX_GeographicBoundingBox" ) );
1518 QDomElement wBoundLongitudeElement = doc.createElement( QStringLiteral(
"westBoundLongitude" ) );
1520 wBoundLongitudeElement.appendChild( wBoundLongitudeText );
1521 ExGeoBBoxElement.appendChild( wBoundLongitudeElement );
1522 QDomElement eBoundLongitudeElement = doc.createElement( QStringLiteral(
"eastBoundLongitude" ) );
1524 eBoundLongitudeElement.appendChild( eBoundLongitudeText );
1525 ExGeoBBoxElement.appendChild( eBoundLongitudeElement );
1526 QDomElement sBoundLatitudeElement = doc.createElement( QStringLiteral(
"southBoundLatitude" ) );
1528 sBoundLatitudeElement.appendChild( sBoundLatitudeText );
1529 ExGeoBBoxElement.appendChild( sBoundLatitudeElement );
1530 QDomElement nBoundLatitudeElement = doc.createElement( QStringLiteral(
"northBoundLatitude" ) );
1532 nBoundLatitudeElement.appendChild( nBoundLatitudeText );
1533 ExGeoBBoxElement.appendChild( nBoundLatitudeElement );
1536 const QDomElement lastCRSElem = layerElem.lastChildElement( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS" );
1537 if ( !lastCRSElem.isNull() )
1539 layerElem.insertAfter( ExGeoBBoxElement, lastCRSElem );
1543 layerElem.appendChild( ExGeoBBoxElement );
1547 void appendLayerCrsExtents( QDomDocument &doc, QDomElement &layerElem,
const QMap<QString, QgsRectangle> &crsExtents )
1549 const QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1551 const auto &keys = crsExtents.keys();
1552 for (
const QString &crsText : std::as_const( keys ) )
1557 if ( crsExtent.isNull() )
1569 QDomElement bBoxElement = doc.createElement( QStringLiteral(
"BoundingBox" ) );
1572 bBoxElement.setAttribute( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS",
crs.
authid() );
1585 QDomElement lastBBoxElem = layerElem.lastChildElement( QStringLiteral(
"BoundingBox" ) );
1586 if ( !lastBBoxElem.isNull() )
1588 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1592 lastBBoxElem = layerElem.lastChildElement( version == QLatin1String(
"1.1.1" ) ?
"LatLonBoundingBox" :
"EX_GeographicBoundingBox" );
1593 if ( !lastBBoxElem.isNull() )
1595 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1599 layerElem.appendChild( bBoxElement );
1605 void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem,
QgsServerInterface *serverIface,
1608#ifdef HAVE_SERVER_PYTHON_PLUGINS
1611 ( void )serverIface;
1616 QStringList layerList;
1619 QList< QgsMapLayer * > projectLayerOrder = projectLayerTreeRoot->
layerOrder();
1620 for (
int i = 0; i < projectLayerOrder.size(); ++i )
1624 if ( restrictedLayers.contains( l->
name() ) )
1628#ifdef HAVE_SERVER_PYTHON_PLUGINS
1634 QString wmsName = l->
name();
1644 layerList << wmsName;
1647 if ( !layerList.isEmpty() )
1649 QStringList reversedList;
1650 reversedList.reserve( layerList.size() );
1651 for (
int i = layerList.size() - 1; i >= 0; --i )
1652 reversedList << layerList[ i ];
1654 QDomElement layerDrawingOrderElem = doc.createElement( QStringLiteral(
"LayerDrawingOrder" ) );
1655 QDomText drawingOrderText = doc.createTextNode( reversedList.join(
',' ) );
1656 layerDrawingOrderElem.appendChild( drawingOrderText );
1657 parentElem.appendChild( layerDrawingOrderElem );
1661 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem,
QgsMapLayer *currentLayer )
1663 if ( !currentLayer )
1669 QDomElement treeNameElem = doc.createElement( QStringLiteral(
"TreeName" ) );
1670 QDomText treeNameText = doc.createTextNode( currentLayer->
name() );
1671 treeNameElem.appendChild( treeNameText );
1672 layerElem.appendChild( treeNameElem );
1674 switch ( currentLayer->
type() )
1676 case Qgis::LayerType::Vector:
1680 int displayFieldIdx = -1;
1681 QString displayField = QStringLiteral(
"maptip" );
1683 if ( exp.isField() )
1690 QDomElement attributesElem = doc.createElement( QStringLiteral(
"Attributes" ) );
1692 for (
int idx = 0; idx < layerFields.
count(); ++idx )
1700 if ( idx == displayFieldIdx )
1704 QDomElement attributeElem = doc.createElement( QStringLiteral(
"Attribute" ) );
1705 attributeElem.setAttribute( QStringLiteral(
"name" ),
field.
name() );
1706 attributeElem.setAttribute( QStringLiteral(
"type" ), QVariant::typeToName(
field.
type() ) );
1707 attributeElem.setAttribute( QStringLiteral(
"typeName" ),
field.
typeName() );
1709 if ( !alias.isEmpty() )
1711 attributeElem.setAttribute( QStringLiteral(
"alias" ), alias );
1715 attributeElem.setAttribute( QStringLiteral(
"editType" ), vLayer->
editorWidgetSetup( idx ).
type() );
1716 attributeElem.setAttribute( QStringLiteral(
"comment" ),
field.
comment() );
1717 attributeElem.setAttribute( QStringLiteral(
"length" ),
field.
length() );
1718 attributeElem.setAttribute( QStringLiteral(
"precision" ),
field.
precision() );
1719 attributesElem.appendChild( attributeElem );
1723 layerElem.setAttribute( QStringLiteral(
"displayField" ), displayField );
1727 if ( pkAttributes.size() > 0 )
1729 QDomElement pkElem = doc.createElement( QStringLiteral(
"PrimaryKey" ) );
1730 QgsAttributeList::const_iterator pkIt = pkAttributes.constBegin();
1731 for ( ; pkIt != pkAttributes.constEnd(); ++pkIt )
1733 QDomElement pkAttributeElem = doc.createElement( QStringLiteral(
"PrimaryKeyAttribute" ) );
1734 QDomText pkAttName = doc.createTextNode( layerFields.
at( *pkIt ).
name() );
1735 pkAttributeElem.appendChild( pkAttName );
1736 pkElem.appendChild( pkAttributeElem );
1738 layerElem.appendChild( pkElem );
1745 layerElem.setAttribute( QStringLiteral(
"opacity" ), QString::number( vLayer->
opacity() ) );
1747 layerElem.appendChild( attributesElem );
1751 case Qgis::LayerType::Raster:
1754 if ( provider && provider->
name() ==
"wms" )
1757 QVariant wmsBackgroundLayer = currentLayer->
customProperty( QStringLiteral(
"WMSBackgroundLayer" ), false );
1758 QDomElement wmsBackgroundLayerElem = doc.createElement(
"WMSBackgroundLayer" );
1759 QDomText wmsBackgroundLayerText = doc.createTextNode( wmsBackgroundLayer.toBool() ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
1760 wmsBackgroundLayerElem.appendChild( wmsBackgroundLayerText );
1761 layerElem.appendChild( wmsBackgroundLayerElem );
1764 QVariant wmsPublishDataSourceUrl = currentLayer->
customProperty( QStringLiteral(
"WMSPublishDataSourceUrl" ),
false );
1765 if ( wmsPublishDataSourceUrl.toBool() )
1767 bool tiled = qobject_cast< const QgsRasterDataProvider * >( provider )
1768 ? !qobject_cast< const QgsRasterDataProvider * >( provider )->nativeResolutions().isEmpty()
1771 QDomElement dataSourceElem = doc.createElement( tiled ? QStringLiteral(
"WMTSDataSource" ) : QStringLiteral(
"WMSDataSource" ) );
1772 QDomText dataSourceUri = doc.createTextNode( provider->
dataSourceUri() );
1773 dataSourceElem.appendChild( dataSourceUri );
1774 layerElem.appendChild( dataSourceElem );
1778 QVariant wmsPrintLayer = currentLayer->
customProperty( QStringLiteral(
"WMSPrintLayer" ) );
1779 if ( wmsPrintLayer.isValid() )
1781 QDomElement wmsPrintLayerElem = doc.createElement(
"WMSPrintLayer" );
1782 QDomText wmsPrintLayerText = doc.createTextNode( wmsPrintLayer.toString() );
1783 wmsPrintLayerElem.appendChild( wmsPrintLayerText );
1784 layerElem.appendChild( wmsPrintLayerElem );
1790 if ( rasterRenderer )
1792 layerElem.setAttribute( QStringLiteral(
"opacity" ), QString::number( rasterRenderer->
opacity() ) );
1797 case Qgis::LayerType::Mesh:
1798 case Qgis::LayerType::VectorTile:
1799 case Qgis::LayerType::Plugin:
1800 case Qgis::LayerType::Annotation:
1801 case Qgis::LayerType::PointCloud:
1802 case Qgis::LayerType::Group:
1807 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent )
1811 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"KeywordList" ) );
1813 QDomElement keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1814 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"ISO" ) );
1815 QDomText keywordText = doc.createTextNode( QStringLiteral(
"infoMapAccessService" ) );
1816 keywordElem.appendChild( keywordText );
1817 keywordsElem.appendChild( keywordElem );
1818 parent.appendChild( keywordsElem );
1820 for (
const QString &keyword : std::as_const( keywords ) )
1822 if ( !keyword.isEmpty() )
1824 keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1825 keywordText = doc.createTextNode( keyword );
1826 keywordElem.appendChild( keywordText );
1829 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"SIA_Geo405" ) );
1831 keywordsElem.appendChild( keywordElem );
1834 parent.appendChild( keywordsElem );
1838 bool hasQueryableLayers(
const QStringList &layerIds,
const QMap< QString, QgsWmsLayerInfos > &wmsLayerInfos )
1840 for (
const QString &
id : std::as_const( layerIds ) )
1842 if ( !wmsLayerInfos.contains(
id ) )
1846 if ( wmsLayerInfos[
id].queryable )
1859 for (
const QString &
id : std::as_const( layerIds ) )
1861 if ( !wmsLayerInfos.contains(
id ) )
1866 QgsRectangle rect = wmsLayerInfos[ id ].wgs84BoundingRect;
1891 QMap<QString, QgsRectangle>
combineCrsExtents(
const QStringList &layerIds,
const QMap< QString, QgsWmsLayerInfos > &wmsLayerInfos )
1893 QMap<QString, QgsRectangle> combined;
1895 for (
const QString &
id : std::as_const( layerIds ) )
1897 if ( !wmsLayerInfos.contains(
id ) )
1903 const auto keys = layerInfos.
crsExtents.keys();
1904 for (
const QString &
crs : std::as_const( keys ) )
1917 if ( !combined.contains(
crs ) )
1919 combined[
crs ] = rect;
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)
This class 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.
Abstract base class for spatial data provider implementations.
virtual QString name() const =0
Returns a provider name.
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
An expression node which takes it value from a feature's field.
Class for parsing and evaluation of expressions (formerly called "search strings").
Encapsulate a field in an attribute table or data source.
QString typeName() const
Gets the field type.
ConfigurationFlags configurationFlags
@ HideFromWms
Field is not available if layer is served as WMS from QGIS server.
Container of fields for a vector layer.
int indexOf(const QString &fieldName) const
Gets the field index from the field name.
int count() const
Returns number of items.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
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.
bool isMutuallyExclusive() const
Returns whether the group is mutually exclusive (only one child can be checked at a time)
Layer tree node points to a map layer.
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.
This class is a base class for nodes in a layer tree.
@ 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.
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer. Properties are stored in a map and saved in project file.
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.
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
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.
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
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.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
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.
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.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the 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)
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,...
QString title() const
Returns the project's title.
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
Represents a raster layer.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
Raster renderer pipe that applies colors to a raster.
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.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle.
bool isEmpty() const
Returns true if the rectangle is empty.
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.
QgsServerInterface Class defining 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.
QgsServerParameters serverParameters() const
Returns parameters.
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
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.
Represents a vector layer which manages a vector based data sets.
QString attributeDisplayName(int index) const
Convenience function that returns the attribute alias if defined or the field name else.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Q_INVOKABLE Qgis::WkbType wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
QString displayExpression
QgsEditorWidgetSetup editorWidgetSetup(int index) const
The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field ...
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 QString displayString(Qgis::WkbType type) SIP_HOLDGIL
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.
QString title
WMS layer title.
QStringList styles
WMS layer styles.
QStringList keywords
WMS layer keywords.
QString legendUrl
WMS layer legend URL.
QString abstract
WMS layer abstract.
static QgsRectangle transformExtent(const QgsRectangle &extent, const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination, const QgsCoordinateTransformContext &context, const bool &ballparkTransformsAreAppropriate=false)
Returns a transformed extent.
QString attribution
WMS layer attribution.
QString dataUrl
WMS layer dataUrl.
double maxScale
WMS layer maximum scale (if negative, no maximum scale is defined)
QMap< QString, QgsRectangle > crsExtents
WMS layer CRS extents (can be empty)
QString attributionUrl
WMS layer attribution URL.
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.
QList< QgsMapLayerServerProperties::MetadataUrl > metadataUrls
WMS layer metadata URLs.
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.
Class defining request interface passed to WMS service.
const QgsWmsParameters & wmsParameters() const
Returns the parameters interpreted for the WMS service.
SERVER_EXPORT QString wmsRootName(const QgsProject &project)
Returns the WMS root layer name defined in a QGIS project.
SERVER_EXPORT bool wmsInfoFormatSia2045(const QgsProject &project)
Returns if the info format is SIA20145.
SERVER_EXPORT QString wmsInspireMetadataUrl(const QgsProject &project)
Returns the Inspire metadata URL.
SERVER_EXPORT double ceilWithPrecision(double number, int places)
Returns a double greater than number to the specified number of places.
SERVER_EXPORT QStringList wmsRestrictedComposers(const QgsProject &project)
Returns the restricted composer list.
SERVER_EXPORT QgsRectangle wmsExtent(const QgsProject &project)
Returns the WMS Extent restriction.
SERVER_EXPORT bool wmsUseLayerIds(const QgsProject &project)
Returns if layer ids are used as name in WMS.
SERVER_EXPORT QString owsServiceAccessConstraints(const QgsProject &project)
Returns the owsService access constraints defined in project.
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
SERVER_EXPORT QString owsServiceOnlineResource(const QgsProject &project)
Returns the owsService online resource defined in project.
SERVER_EXPORT QString owsServiceFees(const QgsProject &project)
Returns the owsService fees defined in project.
SERVER_EXPORT QStringList owsServiceKeywords(const QgsProject &project)
Returns the owsService keywords defined in project.
SERVER_EXPORT QString owsServiceContactPosition(const QgsProject &project)
Returns the owsService contact position defined in project.
SERVER_EXPORT QString serviceUrl(const QString &service, const QgsServerRequest &request, const QgsServerSettings &settings)
Returns the service url defined in the environment variable or with HTTP header.
SERVER_EXPORT QString wmsInspireTemporalReference(const QgsProject &project)
Returns the Inspire temporal reference.
SERVER_EXPORT QStringList wmsOutputCrsList(const QgsProject &project)
Returns the WMS output CRS list.
SERVER_EXPORT QString wmsInspireMetadataDate(const QgsProject &project)
Returns the Inspire metadata date.
SERVER_EXPORT QString owsServiceContactOrganization(const QgsProject &project)
Returns the owsService contact organization defined in project.
SERVER_EXPORT QStringList wmsRestrictedLayers(const QgsProject &project)
Returns the restricted layer name list.
SERVER_EXPORT QString wmsInspireLanguage(const QgsProject &project)
Returns the Inspire language.
SERVER_EXPORT QString wmsInspireMetadataUrlType(const QgsProject &project)
Returns the Inspire metadata URL type.
SERVER_EXPORT bool wmsInspireActivate(const QgsProject &project)
Returns if Inspire is activated.
SERVER_EXPORT int wmsMaxWidth(const QgsProject &project)
Returns the maximum width for WMS images defined in a QGIS project.
SERVER_EXPORT QString owsServiceTitle(const QgsProject &project)
Returns the owsService title defined in project.
SERVER_EXPORT QString owsServiceContactMail(const QgsProject &project)
Returns the owsService contact mail defined in project.
SERVER_EXPORT QString owsServiceAbstract(const QgsProject &project)
Returns the owsService abstract defined in project.
SERVER_EXPORT double floorWithPrecision(double number, int places)
Returns a double less than number to the specified number of places.
SERVER_EXPORT int wmsMaxHeight(const QgsProject &project)
Returns the maximum height for WMS images defined in a QGIS project.
SERVER_EXPORT QString owsServiceContactPhone(const QgsProject &project)
Returns the owsService contact phone defined in project.
SERVER_EXPORT QString owsServiceContactPerson(const QgsProject &project)
Returns the owsService contact person defined in project.
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)
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.
CONSTLATIN1STRING geoEpsgCrsAuthId()
Geographic coord sys from EPSG authority.
QList< int > QgsAttributeList
const QgsCoordinateReferenceSystem & crs
Setting to define QGIS Server WMS Dimension.
@ MinValue
Add selection to current selection.
@ MaxValue
Modify current selection to include only select features which match.
@ ReferenceValue
Remove from current selection.