47 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem,
QgsMapLayer *currentLayer );
51 void appendLayerWgs84BoundingRect( QDomDocument &doc, QDomElement &layerElement,
const QgsRectangle &wgs84BoundingRect );
53 void appendLayerCrsExtents( QDomDocument &doc, QDomElement &layerElement,
const QMap<QString, QgsRectangle> &crsExtents );
55 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
const QString &crsText );
57 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
const QStringList &crsList,
const QStringList &constrainedCrsList );
61 void appendLayersFromTreeGroup( QDomDocument &doc, QDomElement &parentLayer,
QgsServerInterface *serverIface,
const QgsProject *project,
const QgsWmsRequest &request,
const QgsLayerTreeGroup *layerTreeGroup,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos,
bool projectSettings );
63 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent );
68#ifdef HAVE_SERVER_PYTHON_PLUGINS
73 const QDomDocument *capabilitiesDocument =
nullptr;
78 QStringList cacheKeyList;
79 cacheKeyList << ( projectSettings ? QStringLiteral(
"projectSettings" ) : request.
wmsParameters().
version() );
83#ifdef HAVE_SERVER_PYTHON_PLUGINS
87 QString cacheKey = cacheKeyList.join(
'-' );
89#ifdef HAVE_SERVER_PYTHON_PLUGINS
91 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
93 capabilitiesDocument = &doc;
96 if ( !capabilitiesDocument && cache )
101 if ( !capabilitiesDocument )
103 QgsMessageLog::logMessage( QStringLiteral(
"WMS capabilities document not found in cache" ), QStringLiteral(
"Server" ) );
105 doc =
getCapabilities( serverIface, project, request, projectSettings );
107#ifdef HAVE_SERVER_PYTHON_PLUGINS
108 if ( cacheManager && cacheManager->
setCachedDocument( &doc, project, request, accessControl ) )
110 capabilitiesDocument = &doc;
115 if ( !capabilitiesDocument )
120 if ( !capabilitiesDocument )
122 capabilitiesDocument = &doc;
134 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
135 response.
write( capabilitiesDocument->toByteArray() );
141 QDomElement wmsCapabilitiesElement;
147 QString hrefString = href.toString();
148 hrefString.append( href.hasQuery() ?
"&" :
"?" );
151 QDomProcessingInstruction xmlDeclaration = doc.createProcessingInstruction( QStringLiteral(
"xml" ), QStringLiteral(
"version=\"1.0\" encoding=\"utf-8\"" ) );
154 std::function<void( QDomElement &,
const QString & )> appendFormat = [&doc]( QDomElement &elem,
const QString &format ) {
155 QDomElement formatElem = doc.createElement( QStringLiteral(
"Format" ) );
156 formatElem.appendChild( doc.createTextNode( format ) );
157 elem.appendChild( formatElem );
162 doc = QDomDocument( QStringLiteral(
"WMT_MS_Capabilities SYSTEM 'http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd'" ) );
163 doc.appendChild( xmlDeclaration );
164 wmsCapabilitiesElement = doc.createElement( QStringLiteral(
"WMT_MS_Capabilities" ) );
168 doc.appendChild( xmlDeclaration );
169 wmsCapabilitiesElement = doc.createElement( QStringLiteral(
"WMS_Capabilities" ) );
170 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns" ), QStringLiteral(
"http://www.opengis.net/wms" ) );
171 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:sld" ), QStringLiteral(
"http://www.opengis.net/sld" ) );
172 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:qgs" ), QStringLiteral(
"http://www.qgis.org/wms" ) );
173 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
174 QString schemaLocation = QStringLiteral(
"http://www.opengis.net/wms" );
175 schemaLocation += QLatin1String(
" http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd" );
176 schemaLocation += QLatin1String(
" http://www.opengis.net/sld" );
177 schemaLocation += QLatin1String(
" http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd" );
181 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:inspire_common" ), QStringLiteral(
"http://inspire.ec.europa.eu/schemas/common/1.0" ) );
182 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:inspire_vs" ), QStringLiteral(
"http://inspire.ec.europa.eu/schemas/inspire_vs/1.0" ) );
183 schemaLocation += QLatin1String(
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0" );
184 schemaLocation += QLatin1String(
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0/inspire_vs.xsd" );
187 schemaLocation += QLatin1String(
" http://www.qgis.org/wms" );
188 schemaLocation +=
" " + hrefString +
"SERVICE=WMS&REQUEST=GetSchemaExtension";
190 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xsi:schemaLocation" ), schemaLocation );
192 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"version" ), request.
wmsParameters().
version() );
193 doc.appendChild( wmsCapabilitiesElement );
199 QDomElement capabilityElement =
getCapabilityElement( doc, project, request, projectSettings, serverIface );
200 wmsCapabilitiesElement.appendChild( capabilityElement );
202 if ( projectSettings )
211 capabilityElement.appendChild(
215 if ( projectSettings )
217 appendDrawingOrder( doc, capabilityElement, serverIface, project );
226 QDomElement serviceElem = doc.createElement( QStringLiteral(
"Service" ) );
229 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
230 QDomText nameText = doc.createTextNode( QStringLiteral(
"WMS" ) );
231 nameElem.appendChild( nameText );
232 serviceElem.appendChild( nameElem );
235 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
237 titleElem.appendChild( titleText );
238 serviceElem.appendChild( titleElem );
241 if ( !abstract.isEmpty() )
243 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
244 QDomText abstractText = doc.createCDATASection( abstract );
245 abstractElem.appendChild( abstractText );
246 serviceElem.appendChild( abstractElem );
249 addKeywordListElement( project, doc, serviceElem );
252 if ( onlineResource.isEmpty() )
254 onlineResource =
serviceUrl( request, project, *serverSettings ).toString();
256 QDomElement onlineResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
257 onlineResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
258 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
259 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), onlineResource );
260 serviceElem.appendChild( onlineResourceElem );
267 if ( !contactPerson.isEmpty() || !contactOrganization.isEmpty() || !contactPosition.isEmpty() || !contactMail.isEmpty() || !contactPhone.isEmpty() )
270 QDomElement contactInfoElem = doc.createElement( QStringLiteral(
"ContactInformation" ) );
273 if ( !contactPerson.isEmpty() || !contactOrganization.isEmpty() )
275 QDomElement contactPersonPrimaryElem = doc.createElement( QStringLiteral(
"ContactPersonPrimary" ) );
277 QDomText contactPersonText;
278 if ( !contactPerson.isEmpty() )
280 contactPersonText = doc.createTextNode( contactPerson );
284 contactPersonText = doc.createTextNode( QStringLiteral(
"unknown" ) );
286 QDomElement contactPersonElem = doc.createElement( QStringLiteral(
"ContactPerson" ) );
287 contactPersonElem.appendChild( contactPersonText );
288 contactPersonPrimaryElem.appendChild( contactPersonElem );
290 QDomText contactOrganizationText;
291 if ( !contactOrganization.isEmpty() )
293 contactOrganizationText = doc.createTextNode( contactOrganization );
297 contactOrganizationText = doc.createTextNode( QStringLiteral(
"unknown" ) );
299 QDomElement contactOrganizationElem = doc.createElement( QStringLiteral(
"ContactOrganization" ) );
300 contactOrganizationElem.appendChild( contactOrganizationText );
301 contactPersonPrimaryElem.appendChild( contactOrganizationElem );
303 contactInfoElem.appendChild( contactPersonPrimaryElem );
306 if ( !contactPosition.isEmpty() )
308 QDomElement contactPositionElem = doc.createElement( QStringLiteral(
"ContactPosition" ) );
309 QDomText contactPositionText = doc.createTextNode( contactPosition );
310 contactPositionElem.appendChild( contactPositionText );
311 contactInfoElem.appendChild( contactPositionElem );
314 if ( !contactPhone.isEmpty() )
316 QDomElement phoneElem = doc.createElement( QStringLiteral(
"ContactVoiceTelephone" ) );
317 QDomText phoneText = doc.createTextNode( contactPhone );
318 phoneElem.appendChild( phoneText );
319 contactInfoElem.appendChild( phoneElem );
322 if ( !contactMail.isEmpty() )
324 QDomElement mailElem = doc.createElement( QStringLiteral(
"ContactElectronicMailAddress" ) );
325 QDomText mailText = doc.createTextNode( contactMail );
326 mailElem.appendChild( mailText );
327 contactInfoElem.appendChild( mailElem );
330 serviceElem.appendChild( contactInfoElem );
333 QDomElement feesElem = doc.createElement( QStringLiteral(
"Fees" ) );
334 QDomText feesText = doc.createTextNode( QStringLiteral(
"None" ) );
336 if ( !fees.isEmpty() )
338 feesText = doc.createTextNode( fees );
340 feesElem.appendChild( feesText );
341 serviceElem.appendChild( feesElem );
343 QDomElement accessConstraintsElem = doc.createElement( QStringLiteral(
"AccessConstraints" ) );
344 QDomText accessConstraintsText = doc.createTextNode( QStringLiteral(
"None" ) );
346 if ( !accessConstraints.isEmpty() )
348 accessConstraintsText = doc.createTextNode( accessConstraints );
350 accessConstraintsElem.appendChild( accessConstraintsText );
351 serviceElem.appendChild( accessConstraintsElem );
358 QDomElement maxWidthElem = doc.createElement( QStringLiteral(
"MaxWidth" ) );
359 QDomText maxWidthText = doc.createTextNode( QString::number( maxWidth ) );
360 maxWidthElem.appendChild( maxWidthText );
361 serviceElem.appendChild( maxWidthElem );
367 QDomElement maxHeightElem = doc.createElement( QStringLiteral(
"MaxHeight" ) );
368 QDomText maxHeightText = doc.createTextNode( QString::number( maxHeight ) );
369 maxHeightElem.appendChild( maxHeightText );
370 serviceElem.appendChild( maxHeightElem );
385 QString hrefString = href.toString();
386 hrefString.append( href.hasQuery() ?
"&" :
"?" );
388 QDomElement capabilityElem = doc.createElement( QStringLiteral(
"Capability" ) );
391 QDomElement requestElem = doc.createElement( QStringLiteral(
"Request" ) );
392 capabilityElem.appendChild( requestElem );
394 QDomElement dcpTypeElem = doc.createElement( QStringLiteral(
"DCPType" ) );
395 QDomElement httpElem = doc.createElement( QStringLiteral(
"HTTP" ) );
396 dcpTypeElem.appendChild( httpElem );
399 std::function<void( QDomElement &,
const QString & )> appendFormat = [&doc]( QDomElement &elem,
const QString &format ) {
400 QDomElement formatElem = doc.createElement( QStringLiteral(
"Format" ) );
401 formatElem.appendChild( doc.createTextNode( format ) );
402 elem.appendChild( formatElem );
408 elem = doc.createElement( QStringLiteral(
"GetCapabilities" ) );
409 appendFormat( elem, ( version == QLatin1String(
"1.1.1" ) ?
"application/vnd.ogc.wms_xml" :
"text/xml" ) );
410 elem.appendChild( dcpTypeElem );
411 requestElem.appendChild( elem );
414 QDomElement getElem = doc.createElement( QStringLiteral(
"Get" ) );
415 httpElem.appendChild( getElem );
416 QDomElement olResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
417 olResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
418 olResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
419 olResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), hrefString );
420 getElem.appendChild( olResourceElem );
423 elem = doc.createElement( QStringLiteral(
"GetMap" ) );
424 appendFormat( elem, QStringLiteral(
"image/jpeg" ) );
425 appendFormat( elem, QStringLiteral(
"image/png" ) );
426 appendFormat( elem, QStringLiteral(
"image/png; mode=16bit" ) );
427 appendFormat( elem, QStringLiteral(
"image/png; mode=8bit" ) );
428 appendFormat( elem, QStringLiteral(
"image/png; mode=1bit" ) );
429 appendFormat( elem, QStringLiteral(
"application/dxf" ) );
430 appendFormat( elem, QStringLiteral(
"application/pdf" ) );
431 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
432 requestElem.appendChild( elem );
435 elem = doc.createElement( QStringLiteral(
"GetFeatureInfo" ) );
436 appendFormat( elem, QStringLiteral(
"text/plain" ) );
437 appendFormat( elem, QStringLiteral(
"text/html" ) );
438 appendFormat( elem, QStringLiteral(
"text/xml" ) );
439 appendFormat( elem, QStringLiteral(
"application/vnd.ogc.gml" ) );
440 appendFormat( elem, QStringLiteral(
"application/vnd.ogc.gml/3.1.1" ) );
441 appendFormat( elem, QStringLiteral(
"application/json" ) );
442 appendFormat( elem, QStringLiteral(
"application/geo+json" ) );
443 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
444 requestElem.appendChild( elem );
447 elem = doc.createElement( ( version == QLatin1String(
"1.1.1" ) ?
"GetLegendGraphic" :
"sld:GetLegendGraphic" ) );
448 appendFormat( elem, QStringLiteral(
"image/jpeg" ) );
449 appendFormat( elem, QStringLiteral(
"image/png" ) );
450 appendFormat( elem, QStringLiteral(
"application/json" ) );
451 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
452 requestElem.appendChild( elem );
455 elem = doc.createElement( ( version == QLatin1String(
"1.1.1" ) ?
"DescribeLayer" :
"sld:DescribeLayer" ) );
456 appendFormat( elem, QStringLiteral(
"text/xml" ) );
457 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
458 requestElem.appendChild( elem );
461 elem = doc.createElement( ( version == QLatin1String(
"1.1.1" ) ?
"GetStyles" :
"qgs:GetStyles" ) );
462 appendFormat( elem, QStringLiteral(
"text/xml" ) );
463 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
464 requestElem.appendChild( elem );
469 elem = doc.createElement( QStringLiteral(
"GetPrint" ) );
470 appendFormat( elem, QStringLiteral(
"svg" ) );
471 appendFormat( elem, QStringLiteral(
"png" ) );
472 appendFormat( elem, QStringLiteral(
"pdf" ) );
473 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
474 requestElem.appendChild( elem );
478 elem = doc.createElement( QStringLiteral(
"Exception" ) );
479 appendFormat( elem, ( version == QLatin1String(
"1.1.1" ) ?
"application/vnd.ogc.se_xml" :
"XML" ) );
480 capabilityElem.appendChild( elem );
483 if ( version == QLatin1String(
"1.3.0" ) )
485 elem = doc.createElement( QStringLiteral(
"sld:UserDefinedSymbolization" ) );
486 elem.setAttribute( QStringLiteral(
"SupportSLD" ), QStringLiteral(
"1" ) );
487 elem.setAttribute( QStringLiteral(
"UserLayer" ), QStringLiteral(
"0" ) );
488 elem.setAttribute( QStringLiteral(
"UserStyle" ), QStringLiteral(
"1" ) );
489 elem.setAttribute( QStringLiteral(
"RemoteWFS" ), QStringLiteral(
"0" ) );
490 elem.setAttribute( QStringLiteral(
"InlineFeature" ), QStringLiteral(
"0" ) );
491 elem.setAttribute( QStringLiteral(
"RemoteWCS" ), QStringLiteral(
"0" ) );
492 capabilityElem.appendChild( elem );
500 return capabilityElem;
505 QDomElement inspireCapabilitiesElem;
508 return inspireCapabilitiesElem;
510 inspireCapabilitiesElem = doc.createElement( QStringLiteral(
"inspire_vs:ExtendedCapabilities" ) );
514 if ( !inspireMetadataUrl.isEmpty() )
516 QDomElement inspireCommonMetadataUrlElem = doc.createElement( QStringLiteral(
"inspire_common:MetadataUrl" ) );
517 inspireCommonMetadataUrlElem.setAttribute( QStringLiteral(
"xsi:type" ), QStringLiteral(
"inspire_common:resourceLocatorType" ) );
519 QDomElement inspireCommonMetadataUrlUrlElem = doc.createElement( QStringLiteral(
"inspire_common:URL" ) );
520 inspireCommonMetadataUrlUrlElem.appendChild( doc.createTextNode( inspireMetadataUrl ) );
521 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlUrlElem );
524 if ( !inspireMetadataUrlType.isNull() )
526 QDomElement inspireCommonMetadataUrlMediaTypeElem = doc.createElement( QStringLiteral(
"inspire_common:MediaType" ) );
527 inspireCommonMetadataUrlMediaTypeElem.appendChild( doc.createTextNode( inspireMetadataUrlType ) );
528 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlMediaTypeElem );
531 inspireCapabilitiesElem.appendChild( inspireCommonMetadataUrlElem );
535 QDomElement inspireCommonResourceTypeElem = doc.createElement( QStringLiteral(
"inspire_common:ResourceType" ) );
536 inspireCommonResourceTypeElem.appendChild( doc.createTextNode( QStringLiteral(
"service" ) ) );
537 inspireCapabilitiesElem.appendChild( inspireCommonResourceTypeElem );
539 QDomElement inspireCommonSpatialDataServiceTypeElem = doc.createElement( QStringLiteral(
"inspire_common:SpatialDataServiceType" ) );
540 inspireCommonSpatialDataServiceTypeElem.appendChild( doc.createTextNode( QStringLiteral(
"view" ) ) );
541 inspireCapabilitiesElem.appendChild( inspireCommonSpatialDataServiceTypeElem );
544 if ( !inspireTemporalReference.isNull() )
546 QDomElement inspireCommonTemporalReferenceElem = doc.createElement( QStringLiteral(
"inspire_common:TemporalReference" ) );
547 QDomElement inspireCommonDateOfLastRevisionElem = doc.createElement( QStringLiteral(
"inspire_common:DateOfLastRevision" ) );
548 inspireCommonDateOfLastRevisionElem.appendChild( doc.createTextNode( inspireTemporalReference ) );
549 inspireCommonTemporalReferenceElem.appendChild( inspireCommonDateOfLastRevisionElem );
550 inspireCapabilitiesElem.appendChild( inspireCommonTemporalReferenceElem );
553 QDomElement inspireCommonMetadataPointOfContactElem = doc.createElement( QStringLiteral(
"inspire_common:MetadataPointOfContact" ) );
556 QDomElement inspireCommonOrganisationNameElem = doc.createElement( QStringLiteral(
"inspire_common:OrganisationName" ) );
557 if ( !contactOrganization.isNull() )
559 inspireCommonOrganisationNameElem.appendChild( doc.createTextNode( contactOrganization ) );
561 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonOrganisationNameElem );
564 QDomElement inspireCommonEmailAddressElem = doc.createElement( QStringLiteral(
"inspire_common:EmailAddress" ) );
565 if ( !contactMail.isNull() )
567 inspireCommonEmailAddressElem.appendChild( doc.createTextNode( contactMail ) );
569 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonEmailAddressElem );
571 inspireCapabilitiesElem.appendChild( inspireCommonMetadataPointOfContactElem );
574 if ( !inspireMetadataDate.isNull() )
576 QDomElement inspireCommonMetadataDateElem = doc.createElement( QStringLiteral(
"inspire_common:MetadataDate" ) );
577 inspireCommonMetadataDateElem.appendChild( doc.createTextNode( inspireMetadataDate ) );
578 inspireCapabilitiesElem.appendChild( inspireCommonMetadataDateElem );
583 QDomElement inspireCommonSupportedLanguagesElem = doc.createElement( QStringLiteral(
"inspire_common:SupportedLanguages" ) );
584 inspireCommonSupportedLanguagesElem.setAttribute( QStringLiteral(
"xsi:type" ), QStringLiteral(
"inspire_common:supportedLanguagesType" ) );
586 QDomElement inspireCommonLanguageElem = doc.createElement( QStringLiteral(
"inspire_common:Language" ) );
589 QDomElement inspireCommonDefaultLanguageElem = doc.createElement( QStringLiteral(
"inspire_common:DefaultLanguage" ) );
590 inspireCommonDefaultLanguageElem.appendChild( inspireCommonLanguageElem );
591 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonDefaultLanguageElem );
595 QDomElement inspireCommonSupportedLanguageElem = doc.createElement(
"inspire_common:SupportedLanguage" );
596 inspireCommonSupportedLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
597 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonSupportedLanguageElem );
600 inspireCapabilitiesElem.appendChild( inspireCommonSupportedLanguagesElem );
602 QDomElement inspireCommonResponseLanguageElem = doc.createElement( QStringLiteral(
"inspire_common:ResponseLanguage" ) );
603 inspireCommonResponseLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
604 inspireCapabilitiesElem.appendChild( inspireCommonResponseLanguageElem );
606 return inspireCapabilitiesElem;
612 if ( projectComposers.size() == 0 )
613 return QDomElement();
617 QDomElement composerTemplatesElem = doc.createElement( QStringLiteral(
"ComposerTemplates" ) );
618 QList<QgsPrintLayout *>::const_iterator cIt = projectComposers.constBegin();
619 for ( ; cIt != projectComposers.constEnd(); ++cIt )
622 if ( restrictedComposers.contains( layout->
name() ) )
634 QDomElement composerTemplateElem = doc.createElement( QStringLiteral(
"ComposerTemplate" ) );
635 composerTemplateElem.setAttribute( QStringLiteral(
"name" ), layout->
name() );
638 composerTemplateElem.setAttribute( QStringLiteral(
"width" ), width.
length() );
639 composerTemplateElem.setAttribute( QStringLiteral(
"height" ), height.
length() );
643 if ( atlas && atlas->
enabled() )
645 composerTemplateElem.setAttribute( QStringLiteral(
"atlasEnabled" ), QStringLiteral(
"1" ) );
652 layerName = cLayer->
id();
654 else if ( layerName.isEmpty() )
656 layerName = cLayer->
name();
658 composerTemplateElem.setAttribute( QStringLiteral(
"atlasCoverageLayer" ), layerName );
663 QList<QgsLayoutItemMap *> layoutMapList;
665 QList<QgsLayoutItemMap *>::const_iterator cmIt = layoutMapList.constBegin();
668 for ( ; cmIt != layoutMapList.constEnd(); ++cmIt )
672 QDomElement composerMapElem = doc.createElement( QStringLiteral(
"ComposerMap" ) );
673 composerMapElem.setAttribute( QStringLiteral(
"name" ), QStringLiteral(
"map%1" ).arg( mapId ) );
674 composerMapElem.setAttribute( QStringLiteral(
"itemName" ), composerMap->
displayName() );
676 composerMapElem.setAttribute( QStringLiteral(
"width" ), composerMap->rect().width() );
677 composerMapElem.setAttribute( QStringLiteral(
"height" ), composerMap->rect().height() );
678 composerTemplateElem.appendChild( composerMapElem );
682 QList<QgsLayoutItemLabel *> composerLabelList;
684 QList<QgsLayoutItemLabel *>::const_iterator clIt = composerLabelList.constBegin();
685 for ( ; clIt != composerLabelList.constEnd(); ++clIt )
688 QString
id = composerLabel->
id();
692 QDomElement composerLabelElem = doc.createElement( QStringLiteral(
"ComposerLabel" ) );
693 composerLabelElem.setAttribute( QStringLiteral(
"name" ), id );
694 composerTemplateElem.appendChild( composerLabelElem );
698 QList<QgsLayoutItemHtml *> composerHtmlList;
700 QList<QgsLayoutItemHtml *>::const_iterator chIt = composerHtmlList.constBegin();
701 for ( ; chIt != composerHtmlList.constEnd(); ++chIt )
707 QString
id = composerHtml->
frame( 0 )->
id();
711 QDomElement composerHtmlElem = doc.createElement( QStringLiteral(
"ComposerHtml" ) );
712 composerHtmlElem.setAttribute( QStringLiteral(
"name" ), id );
713 composerTemplateElem.appendChild( composerHtmlElem );
716 composerTemplatesElem.appendChild( composerTemplateElem );
719 if ( composerTemplatesElem.childNodes().size() == 0 )
720 return QDomElement();
722 return composerTemplatesElem;
728 if ( wfsLayerIds.size() == 0 )
729 return QDomElement();
731 QDomElement wfsLayersElem = doc.createElement( QStringLiteral(
"WFSLayers" ) );
732 for (
int i = 0; i < wfsLayerIds.size(); ++i )
740 QDomElement wfsLayerElem = doc.createElement( QStringLiteral(
"WFSLayer" ) );
743 wfsLayerElem.setAttribute( QStringLiteral(
"name" ), layer->
id() );
747 wfsLayerElem.setAttribute( QStringLiteral(
"name" ), layer->
name() );
749 wfsLayersElem.appendChild( wfsLayerElem );
752 return wfsLayersElem;
759 parentLayer.setAttribute(
760 QStringLiteral(
"queryable" ),
761 hasQueryableLayers( layerIds, wmsLayerInfos ) ? QStringLiteral(
"1" ) : QStringLiteral(
"0" )
765 QMap<QString, QgsRectangle> crsExtents =
combineCrsExtents( layerIds, wmsLayerInfos );
767 appendCrsElementsToLayer( doc, parentLayer, crsExtents.keys(), QStringList() );
768 appendLayerWgs84BoundingRect( doc, parentLayer, wgs84BoundingRect );
769 appendLayerCrsExtents( doc, parentLayer, crsExtents );
771 appendLayersFromTreeGroup( doc, parentLayer, serverIface, project, request, layerTreeGroup, wmsLayerInfos, projectSettings );
778 QDomElement layerParentElem = doc.createElement( QStringLiteral(
"Layer" ) );
782 if ( rootLayerName.isEmpty() && !project->
title().isEmpty() )
784 rootLayerName = project->
title();
787 if ( !rootLayerName.isEmpty() )
789 QDomElement layerParentNameElem = doc.createElement( QStringLiteral(
"Name" ) );
790 QDomText layerParentNameText = doc.createTextNode( rootLayerName );
791 layerParentNameElem.appendChild( layerParentNameText );
792 layerParentElem.appendChild( layerParentNameElem );
796 QDomElement layerParentTitleElem = doc.createElement( QStringLiteral(
"Title" ) );
798 layerParentTitleElem.appendChild( layerParentTitleText );
799 layerParentElem.appendChild( layerParentTitleElem );
803 if ( !rootLayerAbstract.isEmpty() )
805 QDomElement layerParentAbstElem = doc.createElement( QStringLiteral(
"Abstract" ) );
806 QDomText layerParentAbstText = doc.createCDATASection( rootLayerAbstract );
807 layerParentAbstElem.appendChild( layerParentAbstText );
808 layerParentElem.appendChild( layerParentAbstElem );
812 addKeywordListElement( project, doc, layerParentElem );
815 if ( projectSettings )
817 QDomElement treeNameElem = doc.createElement( QStringLiteral(
"TreeName" ) );
818 QDomText treeNameText = doc.createTextNode( project->
title() );
819 treeNameElem.appendChild( treeNameText );
820 layerParentElem.appendChild( treeNameElem );
826 auto outputCrsList = QList<QgsCoordinateReferenceSystem>();
832 outputCrsList.append(
crs );
856 QStringLiteral(
"Error transforming extent: %1" ).arg( cse.
what() ),
857 QStringLiteral(
"Server" ),
863 QMap<QString, QgsRectangle> wmsCrsExtents;
875 layerParentElem.setAttribute(
876 QStringLiteral(
"queryable" ),
880 appendCrsElementsToLayer( doc, layerParentElem, wmsCrsExtents.keys(), QStringList() );
881 appendLayerWgs84BoundingRect( doc, layerParentElem, wmsWgs84BoundingRect );
882 appendLayerCrsExtents( doc, layerParentElem, wmsCrsExtents );
884 appendLayersFromTreeGroup( doc, layerParentElem, serverIface, project, request, projectLayerTreeRoot, wmsLayerInfos, projectSettings );
888 handleLayersFromTreeGroup( doc, layerParentElem, serverIface, project, request, projectLayerTreeRoot, wmsLayerInfos, projectSettings );
891 return layerParentElem;
897 void appendLayersFromTreeGroup( QDomDocument &doc, QDomElement &parentLayer,
QgsServerInterface *serverIface,
const QgsProject *project,
const QgsWmsRequest &request,
const QgsLayerTreeGroup *layerTreeGroup,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos,
bool projectSettings )
899 const QString version = request.wmsParameters().version();
905 QList<QgsLayerTreeNode *> layerTreeGroupChildren = layerTreeGroup->
children();
906 for (
int i = 0; i < layerTreeGroupChildren.size(); ++i )
909 QDomElement layerElem = doc.createElement( QStringLiteral(
"Layer" ) );
911 if ( projectSettings )
913 layerElem.setAttribute( QStringLiteral(
"visible" ), treeNode->
isVisible() );
915 layerElem.setAttribute( QStringLiteral(
"expanded" ), treeNode->
isExpanded() );
922 QString name = treeGroupChild->
name();
923 if ( restrictedLayers.contains( name ) )
928 if ( projectSettings )
930 layerElem.setAttribute( QStringLiteral(
"mutuallyExclusive" ), treeGroupChild->
isMutuallyExclusive() );
933 QString shortName = treeGroupChild->
customProperty( QStringLiteral(
"wmsShortName" ) ).toString();
934 QString title = treeGroupChild->
customProperty( QStringLiteral(
"wmsTitle" ) ).toString();
936 if ( !skipNameForGroup )
938 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
940 if ( !shortName.isEmpty() )
941 nameText = doc.createTextNode( shortName );
943 nameText = doc.createTextNode( name );
944 nameElem.appendChild( nameText );
945 layerElem.appendChild( nameElem );
948 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
950 if ( !title.isEmpty() )
951 titleText = doc.createTextNode( title );
953 titleText = doc.createTextNode( name );
954 titleElem.appendChild( titleText );
955 layerElem.appendChild( titleElem );
957 QString abstract = treeGroupChild->
customProperty( QStringLiteral(
"wmsAbstract" ) ).toString();
958 if ( !abstract.isEmpty() )
960 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
961 QDomText abstractText = doc.createTextNode( abstract );
962 abstractElem.appendChild( abstractText );
963 layerElem.appendChild( abstractElem );
967 if ( projectSettings )
969 QDomElement treeNameElem = doc.createElement( QStringLiteral(
"TreeName" ) );
970 QDomText treeNameText = doc.createTextNode( name );
971 treeNameElem.appendChild( treeNameText );
972 layerElem.appendChild( treeNameElem );
975 handleLayersFromTreeGroup( doc, layerElem, serverIface, project, request, treeGroupChild, wmsLayerInfos, projectSettings );
978 if ( layerElem.elementsByTagName( QStringLiteral(
"Layer" ) ).length() == 0 )
987 if ( !wmsLayerInfos.contains( treeLayer->
layerId() ) )
994 layerElem.setAttribute(
995 QStringLiteral(
"queryable" ),
996 layerInfos.
queryable ? QStringLiteral(
"1" ) : QStringLiteral(
"0" )
999 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
1000 QDomText nameText = doc.createTextNode( layerInfos.
name );
1001 nameElem.appendChild( nameText );
1002 layerElem.appendChild( nameElem );
1004 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
1005 QDomText titleText = doc.createTextNode( layerInfos.
title );
1006 titleElem.appendChild( titleText );
1007 layerElem.appendChild( titleElem );
1009 if ( !layerInfos.
abstract.isEmpty() )
1011 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
1012 QDomText abstractText = doc.createTextNode( layerInfos.
abstract );
1013 abstractElem.appendChild( abstractText );
1014 layerElem.appendChild( abstractElem );
1018 if ( !layerInfos.
keywords.isEmpty() )
1020 QDomElement keywordListElem = doc.createElement( QStringLiteral(
"KeywordList" ) );
1021 for (
const QString &keyword : std::as_const( layerInfos.keywords ) )
1023 QDomElement keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1024 QDomText keywordText = doc.createTextNode( keyword.trimmed() );
1025 keywordElem.appendChild( keywordText );
1028 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"SIA_Geo405" ) );
1030 keywordListElem.appendChild( keywordElem );
1032 layerElem.appendChild( keywordListElem );
1038 appendCrsElementsToLayer( doc, layerElem, layerInfos.
crsExtents.keys(), QStringList() );
1042 appendLayerCrsExtents( doc, layerElem, layerInfos.
crsExtents );
1046 appendLayerStyles( doc, layerElem, layerInfos, project, request, serverIface->
serverSettings() );
1051 if ( version == QLatin1String(
"1.1.1" ) )
1054 double SCALE_TO_SCALEHINT =
OGC_PX_M * M_SQRT2;
1056 QDomElement scaleHintElem = doc.createElement( QStringLiteral(
"ScaleHint" ) );
1057 scaleHintElem.setAttribute( QStringLiteral(
"min" ), QString::number( layerInfos.
maxScale * SCALE_TO_SCALEHINT ) );
1058 scaleHintElem.setAttribute( QStringLiteral(
"max" ), QString::number( layerInfos.
minScale * SCALE_TO_SCALEHINT ) );
1059 layerElem.appendChild( scaleHintElem );
1063 QDomElement minScaleElem = doc.createElement( QStringLiteral(
"MinScaleDenominator" ) );
1064 QDomText minScaleText = doc.createTextNode( QString::number( layerInfos.
maxScale ) );
1065 minScaleElem.appendChild( minScaleText );
1066 layerElem.appendChild( minScaleElem );
1068 QDomElement maxScaleElem = doc.createElement( QStringLiteral(
"MaxScaleDenominator" ) );
1069 QDomText maxScaleText = doc.createTextNode( QString::number( layerInfos.
minScale ) );
1070 maxScaleElem.appendChild( maxScaleText );
1071 layerElem.appendChild( maxScaleElem );
1076 if ( !layerInfos.
dataUrl.isEmpty() )
1078 QDomElement dataUrlElem = doc.createElement( QStringLiteral(
"DataURL" ) );
1079 QDomElement dataUrlFormatElem = doc.createElement( QStringLiteral(
"Format" ) );
1081 QDomText dataUrlFormatText = doc.createTextNode( dataUrlFormat );
1082 dataUrlFormatElem.appendChild( dataUrlFormatText );
1083 dataUrlElem.appendChild( dataUrlFormatElem );
1084 QDomElement dataORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1085 dataORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1086 dataORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1087 dataORElem.setAttribute( QStringLiteral(
"xlink:href" ), layerInfos.
dataUrl );
1088 dataUrlElem.appendChild( dataORElem );
1089 layerElem.appendChild( dataUrlElem );
1095 QDomElement attribElem = doc.createElement( QStringLiteral(
"Attribution" ) );
1096 QDomElement attribTitleElem = doc.createElement( QStringLiteral(
"Title" ) );
1097 QDomText attribText = doc.createTextNode( layerInfos.
attribution );
1098 attribTitleElem.appendChild( attribText );
1099 attribElem.appendChild( attribTitleElem );
1102 QDomElement attribORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1103 attribORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1104 attribORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1105 attribORElem.setAttribute( QStringLiteral(
"xlink:href" ), layerInfos.
attributionUrl );
1106 attribElem.appendChild( attribORElem );
1108 layerElem.appendChild( attribElem );
1114 QDomElement metaUrlElem = doc.createElement( QStringLiteral(
"MetadataURL" ) );
1115 const QString metadataUrlType = metadataUrl.type;
1116 if ( version == QLatin1String(
"1.1.1" ) )
1118 metaUrlElem.setAttribute( QStringLiteral(
"type" ), metadataUrlType );
1120 else if ( metadataUrlType == QLatin1String(
"FGDC" ) )
1122 metaUrlElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"FGDC:1998" ) );
1124 else if ( metadataUrlType == QLatin1String(
"TC211" ) )
1126 metaUrlElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"ISO19115:2003" ) );
1130 metaUrlElem.setAttribute( QStringLiteral(
"type" ), metadataUrlType );
1132 const QString metadataUrlFormat = metadataUrl.format;
1133 if ( !metadataUrlFormat.isEmpty() )
1135 QDomElement metaUrlFormatElem = doc.createElement( QStringLiteral(
"Format" ) );
1136 QDomText metaUrlFormatText = doc.createTextNode( metadataUrlFormat );
1137 metaUrlFormatElem.appendChild( metaUrlFormatText );
1138 metaUrlElem.appendChild( metaUrlFormatElem );
1140 QDomElement metaUrlORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1141 metaUrlORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1142 metaUrlORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1143 metaUrlORElem.setAttribute( QStringLiteral(
"xlink:href" ), metadataUrl.url );
1144 metaUrlElem.appendChild( metaUrlORElem );
1145 layerElem.appendChild( metaUrlElem );
1148 bool timeDimensionAdded {
false };
1155 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> wmsDims = serverProperties->
wmsDimensions();
1160 if ( fieldIndex == -1 )
1165 QSet<QVariant> uniqueValues = vl->
uniqueValues( fieldIndex );
1168 if ( !dim.endFieldName.isEmpty() )
1170 int endFieldIndex = vl->
fields().
indexOf( dim.endFieldName );
1172 if ( endFieldIndex == -1 )
1176 uniqueValues.unite( vl->
uniqueValues( endFieldIndex ) );
1179 QList<QVariant> values = qgis::setToList( uniqueValues );
1180 std::sort( values.begin(), values.end() );
1182 QDomElement dimElem = doc.createElement( QStringLiteral(
"Dimension" ) );
1183 dimElem.setAttribute( QStringLiteral(
"name" ), dim.name );
1185 if ( dim.name.toUpper() == QLatin1String(
"TIME" ) )
1187 timeDimensionAdded =
true;
1190 if ( !dim.units.isEmpty() )
1192 dimElem.setAttribute( QStringLiteral(
"units" ), dim.units );
1194 if ( !dim.unitSymbol.isEmpty() )
1196 dimElem.setAttribute( QStringLiteral(
"unitSymbol" ), dim.unitSymbol );
1198 if ( !values.isEmpty() && dim.defaultDisplayType == QgsMapLayerServerProperties::WmsDimensionInfo::MinValue )
1200 dimElem.setAttribute( QStringLiteral(
"default" ), values.first().toString() );
1202 else if ( !values.isEmpty() && dim.defaultDisplayType == QgsMapLayerServerProperties::WmsDimensionInfo::MaxValue )
1204 dimElem.setAttribute( QStringLiteral(
"default" ), values.last().toString() );
1206 else if ( dim.defaultDisplayType == QgsMapLayerServerProperties::WmsDimensionInfo::ReferenceValue )
1208 dimElem.setAttribute( QStringLiteral(
"default" ), dim.referenceValue.toString() );
1210 dimElem.setAttribute( QStringLiteral(
"multipleValues" ), QStringLiteral(
"1" ) );
1211 dimElem.setAttribute( QStringLiteral(
"nearestValue" ), QStringLiteral(
"0" ) );
1212 if ( projectSettings )
1214 dimElem.setAttribute( QStringLiteral(
"fieldName" ), dim.fieldName );
1215 dimElem.setAttribute( QStringLiteral(
"endFieldName" ), dim.endFieldName );
1218 QStringList strValues;
1219 for (
const QVariant &v : values )
1221 strValues << v.toString();
1223 QDomText dimValuesText = doc.createTextNode( strValues.join( QLatin1String(
", " ) ) );
1224 dimElem.appendChild( dimValuesText );
1225 layerElem.appendChild( dimElem );
1230 if ( !timeDimensionAdded
1234 QDomElement dimElem = doc.createElement( QStringLiteral(
"Dimension" ) );
1235 dimElem.setAttribute( QStringLiteral(
"name" ), QStringLiteral(
"TIME" ) );
1236 dimElem.setAttribute( QStringLiteral(
"units" ), QStringLiteral(
"ISO8601" ) );
1246 bool isDateList {
true };
1247 bool isInstantList {
true };
1249 QList<QDateTime> values;
1250 for (
const auto &r : std::as_const( allRanges ) )
1252 if ( r.isInstant() )
1254 if ( r.begin().time() != QTime( 0, 0, 0, 0 ) )
1258 values.append( r.begin() );
1262 isInstantList =
false;
1269 if ( isInstantList )
1272 QStringList strValues;
1273 for (
const auto &v : values )
1277 strValues << v.date().toString( Qt::DateFormat::ISODate );
1281 strValues << v.toString( Qt::DateFormat::ISODate );
1284 QDomText dimValuesText = doc.createTextNode( strValues.join( QChar(
',' ) ) );
1285 dimElem.appendChild( dimValuesText );
1288 layerElem.appendChild( dimElem );
1290 QDomElement timeExtentElem = doc.createElement( QStringLiteral(
"Extent" ) );
1291 timeExtentElem.setAttribute( QStringLiteral(
"name" ), QStringLiteral(
"TIME" ) );
1297 extent = QStringLiteral(
"%1/%2" ).arg( timeExtent.begin().date().toString( Qt::DateFormat::ISODate ), timeExtent.end().date().toString( Qt::DateFormat::ISODate ) );
1301 extent = QStringLiteral(
"%1/%2" ).arg( timeExtent.begin().toString( Qt::DateFormat::ISODate ), timeExtent.end().toString( Qt::DateFormat::ISODate ) );
1303 QDomText extentValueText = doc.createTextNode( extent );
1304 timeExtentElem.appendChild( extentValueText );
1305 layerElem.appendChild( timeExtentElem );
1308 if ( projectSettings )
1310 appendLayerProjectSettings( doc, layerElem, l );
1314 parentLayer.appendChild( layerElem );
1321 QUrl href =
serviceUrl( request, project, *settings );
1324 QString hrefString = href.toString();
1325 hrefString.append( href.hasQuery() ?
"&" :
"?" );
1326 for (
const QString &styleName : std::as_const( layerInfos.styles ) )
1328 QDomElement styleElem = doc.createElement( QStringLiteral(
"Style" ) );
1329 QDomElement styleNameElem = doc.createElement( QStringLiteral(
"Name" ) );
1330 QDomText styleNameText = doc.createTextNode( styleName );
1331 styleNameElem.appendChild( styleNameText );
1332 QDomElement styleTitleElem = doc.createElement( QStringLiteral(
"Title" ) );
1333 QDomText styleTitleText = doc.createTextNode( styleName );
1334 styleTitleElem.appendChild( styleTitleText );
1335 styleElem.appendChild( styleNameElem );
1336 styleElem.appendChild( styleTitleElem );
1339 QDomElement getLayerLegendGraphicElem = doc.createElement( QStringLiteral(
"LegendURL" ) );
1341 QString customHrefString = layerInfos.
legendUrl;
1343 QStringList getLayerLegendGraphicFormats;
1344 if ( !customHrefString.isEmpty() )
1350 getLayerLegendGraphicFormats << QStringLiteral(
"image/png" );
1353 for (
const QString &getLayerLegendGraphicFormat : std::as_const( getLayerLegendGraphicFormats ) )
1355 QDomElement getLayerLegendGraphicFormatElem = doc.createElement( QStringLiteral(
"Format" ) );
1356 QDomText getLayerLegendGraphicFormatText = doc.createTextNode( getLayerLegendGraphicFormat );
1357 getLayerLegendGraphicFormatElem.appendChild( getLayerLegendGraphicFormatText );
1358 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicFormatElem );
1362 if ( customHrefString.isEmpty() )
1364 QUrl mapUrl( hrefString );
1365 QUrlQuery mapUrlQuery( mapUrl.query() );
1366 mapUrlQuery.addQueryItem( QStringLiteral(
"SERVICE" ), QStringLiteral(
"WMS" ) );
1367 mapUrlQuery.addQueryItem( QStringLiteral(
"VERSION" ), request.wmsParameters().version() );
1368 mapUrlQuery.addQueryItem( QStringLiteral(
"REQUEST" ), QStringLiteral(
"GetLegendGraphic" ) );
1369 mapUrlQuery.addQueryItem( QStringLiteral(
"LAYER" ), layerInfos.
name );
1370 mapUrlQuery.addQueryItem( QStringLiteral(
"FORMAT" ), QStringLiteral(
"image/png" ) );
1371 mapUrlQuery.addQueryItem( QStringLiteral(
"STYLE" ), styleName );
1372 if ( request.wmsParameters().version() == QLatin1String(
"1.3.0" ) )
1374 mapUrlQuery.addQueryItem( QStringLiteral(
"SLD_VERSION" ), QStringLiteral(
"1.1.0" ) );
1376 mapUrl.setQuery( mapUrlQuery );
1377 customHrefString = mapUrl.toString();
1380 QDomElement getLayerLegendGraphicORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1381 getLayerLegendGraphicORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1382 getLayerLegendGraphicORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1383 getLayerLegendGraphicORElem.setAttribute( QStringLiteral(
"xlink:href" ), customHrefString );
1384 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicORElem );
1385 styleElem.appendChild( getLayerLegendGraphicElem );
1387 layerElem.appendChild( styleElem );
1391 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
const QStringList &crsList,
const QStringList &constrainedCrsList )
1393 if ( layerElement.isNull() )
1398 const QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1401 QDomElement titleElement = layerElement.firstChildElement( QStringLiteral(
"Title" ) );
1402 QDomElement abstractElement = layerElement.firstChildElement( QStringLiteral(
"Abstract" ) );
1403 QDomElement keywordListElement = layerElement.firstChildElement( QStringLiteral(
"KeywordList" ) );
1404 QDomElement CRSPrecedingElement = !keywordListElement.isNull() ? keywordListElement : !abstractElement.isNull() ? abstractElement
1407 if ( CRSPrecedingElement.isNull() )
1410 const QDomElement keyElement = layerElement.firstChildElement( QStringLiteral(
"KeywordList" ) );
1411 CRSPrecedingElement = keyElement;
1415 if ( !constrainedCrsList.isEmpty() )
1417 for (
int i = constrainedCrsList.size() - 1; i >= 0; --i )
1419 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, constrainedCrsList.at( i ) );
1424 for (
const QString &
crs : crsList )
1426 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement,
crs );
1432 if ( version == QLatin1String(
"1.3.0" ) )
1434 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, QString(
"CRS:84" ) );
1438 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
const QString &crsText )
1440 if ( crsText.isEmpty() )
1442 const QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1443 QDomElement crsElement = doc.createElement( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS" );
1444 QDomText crsTextNode = doc.createTextNode( crsText );
1445 crsElement.appendChild( crsTextNode );
1446 layerElement.insertAfter( crsElement, precedingElement );
1449 void appendLayerWgs84BoundingRect( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &wgs84BoundingRect )
1452 if ( wgs84BoundingRect.
isNull() )
1458 QDomElement ExGeoBBoxElement;
1459 const int wgs84precision = 6;
1460 const QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1461 if ( version == QLatin1String(
"1.1.1" ) )
1463 ExGeoBBoxElement = doc.createElement( QStringLiteral(
"LatLonBoundingBox" ) );
1471 ExGeoBBoxElement = doc.createElement( QStringLiteral(
"EX_GeographicBoundingBox" ) );
1472 QDomElement wBoundLongitudeElement = doc.createElement( QStringLiteral(
"westBoundLongitude" ) );
1474 wBoundLongitudeElement.appendChild( wBoundLongitudeText );
1475 ExGeoBBoxElement.appendChild( wBoundLongitudeElement );
1476 QDomElement eBoundLongitudeElement = doc.createElement( QStringLiteral(
"eastBoundLongitude" ) );
1478 eBoundLongitudeElement.appendChild( eBoundLongitudeText );
1479 ExGeoBBoxElement.appendChild( eBoundLongitudeElement );
1480 QDomElement sBoundLatitudeElement = doc.createElement( QStringLiteral(
"southBoundLatitude" ) );
1482 sBoundLatitudeElement.appendChild( sBoundLatitudeText );
1483 ExGeoBBoxElement.appendChild( sBoundLatitudeElement );
1484 QDomElement nBoundLatitudeElement = doc.createElement( QStringLiteral(
"northBoundLatitude" ) );
1486 nBoundLatitudeElement.appendChild( nBoundLatitudeText );
1487 ExGeoBBoxElement.appendChild( nBoundLatitudeElement );
1490 const QDomElement lastCRSElem = layerElem.lastChildElement( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS" );
1491 if ( !lastCRSElem.isNull() )
1493 layerElem.insertAfter( ExGeoBBoxElement, lastCRSElem );
1497 layerElem.appendChild( ExGeoBBoxElement );
1501 void appendLayerCrsExtents( QDomDocument &doc, QDomElement &layerElem,
const QMap<QString, QgsRectangle> &crsExtents )
1503 const QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1505 const auto &keys = crsExtents.keys();
1506 for (
const QString &crsText : std::as_const( keys ) )
1511 if ( crsExtent.isNull() )
1523 QDomElement bBoxElement = doc.createElement( QStringLiteral(
"BoundingBox" ) );
1526 bBoxElement.setAttribute( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS",
crs.authid() );
1539 QDomElement lastBBoxElem = layerElem.lastChildElement( QStringLiteral(
"BoundingBox" ) );
1540 if ( !lastBBoxElem.isNull() )
1542 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1546 lastBBoxElem = layerElem.lastChildElement( version == QLatin1String(
"1.1.1" ) ?
"LatLonBoundingBox" :
"EX_GeographicBoundingBox" );
1547 if ( !lastBBoxElem.isNull() )
1549 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1553 layerElem.appendChild( bBoxElement );
1561#ifdef HAVE_SERVER_PYTHON_PLUGINS
1564 ( void ) serverIface;
1569 QStringList layerList;
1572 QList<QgsMapLayer *> projectLayerOrder = projectLayerTreeRoot->
layerOrder();
1573 for (
int i = 0; i < projectLayerOrder.size(); ++i )
1577 if ( restrictedLayers.contains( l->
name() ) )
1581#ifdef HAVE_SERVER_PYTHON_PLUGINS
1587 QString wmsName = l->
name();
1597 layerList << wmsName;
1600 if ( !layerList.isEmpty() )
1602 QStringList reversedList;
1603 reversedList.reserve( layerList.size() );
1604 for (
int i = layerList.size() - 1; i >= 0; --i )
1605 reversedList << layerList[i];
1607 QDomElement layerDrawingOrderElem = doc.createElement( QStringLiteral(
"LayerDrawingOrder" ) );
1608 QDomText drawingOrderText = doc.createTextNode( reversedList.join(
',' ) );
1609 layerDrawingOrderElem.appendChild( drawingOrderText );
1610 parentElem.appendChild( layerDrawingOrderElem );
1614 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem,
QgsMapLayer *currentLayer )
1616 if ( !currentLayer )
1622 QDomElement treeNameElem = doc.createElement( QStringLiteral(
"TreeName" ) );
1623 QDomText treeNameText = doc.createTextNode( currentLayer->
name() );
1624 treeNameElem.appendChild( treeNameText );
1625 layerElem.appendChild( treeNameElem );
1627 switch ( currentLayer->
type() )
1633 int displayFieldIdx = -1;
1634 QString displayField = QStringLiteral(
"maptip" );
1636 if ( exp.isField() )
1643 QDomElement attributesElem = doc.createElement( QStringLiteral(
"Attributes" ) );
1645 for (
int idx = 0; idx < layerFields.
count(); ++idx )
1653 if ( idx == displayFieldIdx )
1657 QDomElement attributeElem = doc.createElement( QStringLiteral(
"Attribute" ) );
1658 attributeElem.setAttribute( QStringLiteral(
"name" ), field.
name() );
1659 attributeElem.setAttribute( QStringLiteral(
"type" ), QVariant::typeToName( field.
type() ) );
1660 attributeElem.setAttribute( QStringLiteral(
"typeName" ), field.
typeName() );
1661 QString alias = field.
alias();
1662 if ( !alias.isEmpty() )
1664 attributeElem.setAttribute( QStringLiteral(
"alias" ), alias );
1668 attributeElem.setAttribute( QStringLiteral(
"editType" ), vLayer->
editorWidgetSetup( idx ).
type() );
1669 attributeElem.setAttribute( QStringLiteral(
"comment" ), field.
comment() );
1670 attributeElem.setAttribute( QStringLiteral(
"length" ), field.
length() );
1671 attributeElem.setAttribute( QStringLiteral(
"precision" ), field.
precision() );
1672 attributesElem.appendChild( attributeElem );
1676 layerElem.setAttribute( QStringLiteral(
"displayField" ), displayField );
1680 if ( pkAttributes.size() > 0 )
1682 QDomElement pkElem = doc.createElement( QStringLiteral(
"PrimaryKey" ) );
1683 QgsAttributeList::const_iterator pkIt = pkAttributes.constBegin();
1684 for ( ; pkIt != pkAttributes.constEnd(); ++pkIt )
1686 QDomElement pkAttributeElem = doc.createElement( QStringLiteral(
"PrimaryKeyAttribute" ) );
1687 QDomText pkAttName = doc.createTextNode( layerFields.
at( *pkIt ).
name() );
1688 pkAttributeElem.appendChild( pkAttName );
1689 pkElem.appendChild( pkAttributeElem );
1691 layerElem.appendChild( pkElem );
1698 layerElem.setAttribute( QStringLiteral(
"opacity" ), QString::number( vLayer->
opacity() ) );
1700 layerElem.appendChild( attributesElem );
1707 if ( provider && provider->
name() ==
"wms" )
1710 QVariant wmsBackgroundLayer = currentLayer->
customProperty( QStringLiteral(
"WMSBackgroundLayer" ), false );
1711 QDomElement wmsBackgroundLayerElem = doc.createElement(
"WMSBackgroundLayer" );
1712 QDomText wmsBackgroundLayerText = doc.createTextNode( wmsBackgroundLayer.toBool() ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
1713 wmsBackgroundLayerElem.appendChild( wmsBackgroundLayerText );
1714 layerElem.appendChild( wmsBackgroundLayerElem );
1717 QVariant wmsPublishDataSourceUrl = currentLayer->
customProperty( QStringLiteral(
"WMSPublishDataSourceUrl" ),
false );
1718 if ( wmsPublishDataSourceUrl.toBool() )
1720 bool tiled = qobject_cast<const QgsRasterDataProvider *>( provider )
1721 ? !qobject_cast<const QgsRasterDataProvider *>( provider )->nativeResolutions().isEmpty()
1724 QDomElement dataSourceElem = doc.createElement( tiled ? QStringLiteral(
"WMTSDataSource" ) : QStringLiteral(
"WMSDataSource" ) );
1725 QDomText dataSourceUri = doc.createTextNode( provider->
dataSourceUri() );
1726 dataSourceElem.appendChild( dataSourceUri );
1727 layerElem.appendChild( dataSourceElem );
1731 QVariant wmsPrintLayer = currentLayer->
customProperty( QStringLiteral(
"WMSPrintLayer" ) );
1732 if ( wmsPrintLayer.isValid() )
1734 QDomElement wmsPrintLayerElem = doc.createElement(
"WMSPrintLayer" );
1735 QDomText wmsPrintLayerText = doc.createTextNode( wmsPrintLayer.toString() );
1736 wmsPrintLayerElem.appendChild( wmsPrintLayerText );
1737 layerElem.appendChild( wmsPrintLayerElem );
1743 if ( rasterRenderer )
1745 layerElem.setAttribute( QStringLiteral(
"opacity" ), QString::number( rasterRenderer->
opacity() ) );
1761 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent )
1765 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"KeywordList" ) );
1767 QDomElement keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1768 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"ISO" ) );
1769 QDomText keywordText = doc.createTextNode( QStringLiteral(
"infoMapAccessService" ) );
1770 keywordElem.appendChild( keywordText );
1771 keywordsElem.appendChild( keywordElem );
1772 parent.appendChild( keywordsElem );
1774 for (
const QString &keyword : std::as_const( keywords ) )
1776 if ( !keyword.isEmpty() )
1778 keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1779 keywordText = doc.createTextNode( keyword );
1780 keywordElem.appendChild( keywordText );
1783 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"SIA_Geo405" ) );
1785 keywordsElem.appendChild( keywordElem );
1788 parent.appendChild( keywordsElem );
1792 bool hasQueryableLayers(
const QStringList &layerIds,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos )
1794 for (
const QString &
id : std::as_const( layerIds ) )
1796 if ( !wmsLayerInfos.contains(
id ) )
1800 if ( wmsLayerInfos[
id].queryable )
1813 for (
const QString &
id : std::as_const( layerIds ) )
1815 if ( !wmsLayerInfos.contains(
id ) )
1820 QgsRectangle rect = wmsLayerInfos[id].wgs84BoundingRect;
1845 QMap<QString, QgsRectangle>
combineCrsExtents(
const QStringList &layerIds,
const QMap<QString, QgsWmsLayerInfos> &wmsLayerInfos )
1847 QMap<QString, QgsRectangle> combined;
1849 for (
const QString &
id : std::as_const( layerIds ) )
1851 if ( !wmsLayerInfos.contains(
id ) )
1857 const auto keys = layerInfos.
crsExtents.keys();
1858 for (
const QString &
crs : std::as_const( keys ) )
1871 if ( !combined.contains(
crs ) )
1873 combined[
crs] = 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.
@ 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)
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.
Qgis::FieldConfigurationFlags configurationFlags
Container of fields for a vector layer.
Q_INVOKABLE int indexOf(const QString &fieldName) const
Gets the field index from the field name.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
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.
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.
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 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)
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.
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.
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.
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 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.
QString title
WMS layer title.
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.
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 bool wmsSkipNameForGroup(const QgsProject &project)
Returns if name attribute should be skipped for groups in WMS capabilities document.
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.