51 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem,
QgsMapLayer *currentLayer );
53 void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem,
QgsServerInterface *serverIface,
56 void combineExtentAndCrsOfGroupChildren( QDomDocument &doc, QDomElement &groupElem,
const QgsProject *project,
57 bool considerMapExtent =
false );
59 bool crsSetFromLayerElement(
const QDomElement &layerElement, QSet<QString> &crsSet );
61 QgsRectangle layerBoundingBoxInProjectCrs(
const QDomDocument &doc,
const QDomElement &layerElem,
64 void appendLayerBoundingBox( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &layerExtent,
68 void appendLayerBoundingBoxes( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &lExtent,
70 const QStringList &constrainedCrsList,
const QgsProject *project );
72 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
73 const QString &crsText );
75 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
76 const QStringList &crsList,
const QStringList &constrainedCrsList );
78 void appendLayerStyles( QDomDocument &doc, QDomElement &layerElem,
QgsMapLayer *currentLayer,
81 void appendLayersFromTreeGroup( QDomDocument &doc,
82 QDomElement &parentLayer,
85 const QString &version,
88 bool projectSettings );
90 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent );
97 #ifdef HAVE_SERVER_PYTHON_PLUGINS
102 const QDomDocument *capabilitiesDocument =
nullptr;
107 QStringList cacheKeyList;
108 cacheKeyList << ( projectSettings ? QStringLiteral(
"projectSettings" ) : version );
109 cacheKeyList << request.
url().host();
112 #ifdef HAVE_SERVER_PYTHON_PLUGINS
116 QString cacheKey = cacheKeyList.join(
'-' );
118 #ifdef HAVE_SERVER_PYTHON_PLUGINS
120 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
122 capabilitiesDocument = &doc;
125 if ( !capabilitiesDocument && cache )
130 if ( !capabilitiesDocument )
132 QgsMessageLog::logMessage( QStringLiteral(
"WMS capabilities document not found in cache" ), QStringLiteral(
"Server" ) );
134 doc =
getCapabilities( serverIface, project, version, request, projectSettings );
136 #ifdef HAVE_SERVER_PYTHON_PLUGINS
140 capabilitiesDocument = &doc;
145 if ( !capabilitiesDocument )
150 if ( !capabilitiesDocument )
152 capabilitiesDocument = &doc;
164 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
165 response.
write( capabilitiesDocument->toByteArray() );
170 bool projectSettings )
173 QDomElement wmsCapabilitiesElement;
179 QString hrefString = href.toString();
180 hrefString.append( href.hasQuery() ?
"&" :
"?" );
183 QDomProcessingInstruction xmlDeclaration = doc.createProcessingInstruction( QStringLiteral(
"xml" ),
184 QStringLiteral(
"version=\"1.0\" encoding=\"utf-8\"" ) );
187 std::function < void ( QDomElement &,
const QString & ) > appendFormat = [&doc]( QDomElement & elem,
const QString & format )
189 QDomElement formatElem = doc.createElement( QStringLiteral(
"Format" ) );
190 formatElem.appendChild( doc.createTextNode( format ) );
191 elem.appendChild( formatElem );
194 if ( version == QLatin1String(
"1.1.1" ) )
196 doc = QDomDocument( QStringLiteral(
"WMT_MS_Capabilities SYSTEM 'http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd'" ) );
197 doc.appendChild( xmlDeclaration );
198 wmsCapabilitiesElement = doc.createElement( QStringLiteral(
"WMT_MS_Capabilities" ) );
202 doc.appendChild( xmlDeclaration );
203 wmsCapabilitiesElement = doc.createElement( QStringLiteral(
"WMS_Capabilities" ) );
204 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns" ), QStringLiteral(
"http://www.opengis.net/wms" ) );
205 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:sld" ), QStringLiteral(
"http://www.opengis.net/sld" ) );
206 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:qgs" ), QStringLiteral(
"http://www.qgis.org/wms" ) );
207 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
208 QString schemaLocation = QStringLiteral(
"http://www.opengis.net/wms" );
209 schemaLocation += QLatin1String(
" http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd" );
210 schemaLocation += QLatin1String(
" http://www.opengis.net/sld" );
211 schemaLocation += QLatin1String(
" http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd" );
215 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:inspire_common" ), QStringLiteral(
"http://inspire.ec.europa.eu/schemas/common/1.0" ) );
216 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:inspire_vs" ), QStringLiteral(
"http://inspire.ec.europa.eu/schemas/inspire_vs/1.0" ) );
217 schemaLocation += QLatin1String(
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0" );
218 schemaLocation += QLatin1String(
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0/inspire_vs.xsd" );
221 schemaLocation += QLatin1String(
" http://www.qgis.org/wms" );
222 schemaLocation +=
" " + hrefString +
"SERVICE=WMS&REQUEST=GetSchemaExtension";
224 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xsi:schemaLocation" ), schemaLocation );
226 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"version" ), version );
227 doc.appendChild( wmsCapabilitiesElement );
230 wmsCapabilitiesElement.appendChild(
getServiceElement( doc, project, version, request ) );
233 QDomElement capabilityElement =
getCapabilityElement( doc, project, version, request, projectSettings, serverIface );
234 wmsCapabilitiesElement.appendChild( capabilityElement );
236 if ( projectSettings )
245 capabilityElement.appendChild(
249 if ( projectSettings )
251 appendDrawingOrder( doc, capabilityElement, serverIface, project );
261 QDomElement serviceElem = doc.createElement( QStringLiteral(
"Service" ) );
264 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
265 QDomText nameText = doc.createTextNode( QStringLiteral(
"WMS" ) );
266 nameElem.appendChild( nameText );
267 serviceElem.appendChild( nameElem );
270 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
272 titleElem.appendChild( titleText );
273 serviceElem.appendChild( titleElem );
276 if ( !
abstract.isEmpty() )
278 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
279 QDomText abstractText = doc.createCDATASection(
abstract );
280 abstractElem.appendChild( abstractText );
281 serviceElem.appendChild( abstractElem );
284 addKeywordListElement( project, doc, serviceElem );
287 if ( onlineResource.isEmpty() )
289 onlineResource =
serviceUrl( request, project ).toString();
291 QDomElement onlineResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
292 onlineResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
293 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
294 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), onlineResource );
295 serviceElem.appendChild( onlineResourceElem );
302 if ( !contactPerson.isEmpty() ||
303 !contactOrganization.isEmpty() ||
304 !contactPosition.isEmpty() ||
305 !contactMail.isEmpty() ||
306 !contactPhone.isEmpty() )
309 QDomElement contactInfoElem = doc.createElement( QStringLiteral(
"ContactInformation" ) );
312 if ( !contactPerson.isEmpty() ||
313 !contactOrganization.isEmpty() )
315 QDomElement contactPersonPrimaryElem = doc.createElement( QStringLiteral(
"ContactPersonPrimary" ) );
317 QDomText contactPersonText;
318 if ( !contactPerson.isEmpty() )
320 contactPersonText = doc.createTextNode( contactPerson );
324 contactPersonText = doc.createTextNode( QStringLiteral(
"unknown" ) );
326 QDomElement contactPersonElem = doc.createElement( QStringLiteral(
"ContactPerson" ) );
327 contactPersonElem.appendChild( contactPersonText );
328 contactPersonPrimaryElem.appendChild( contactPersonElem );
330 QDomText contactOrganizationText;
331 if ( !contactOrganization.isEmpty() )
333 contactOrganizationText = doc.createTextNode( contactOrganization );
337 contactOrganizationText = doc.createTextNode( QStringLiteral(
"unknown" ) );
339 QDomElement contactOrganizationElem = doc.createElement( QStringLiteral(
"ContactOrganization" ) );
340 contactOrganizationElem.appendChild( contactOrganizationText );
341 contactPersonPrimaryElem.appendChild( contactOrganizationElem );
343 contactInfoElem.appendChild( contactPersonPrimaryElem );
346 if ( !contactPosition.isEmpty() )
348 QDomElement contactPositionElem = doc.createElement( QStringLiteral(
"ContactPosition" ) );
349 QDomText contactPositionText = doc.createTextNode( contactPosition );
350 contactPositionElem.appendChild( contactPositionText );
351 contactInfoElem.appendChild( contactPositionElem );
354 if ( !contactPhone.isEmpty() )
356 QDomElement phoneElem = doc.createElement( QStringLiteral(
"ContactVoiceTelephone" ) );
357 QDomText phoneText = doc.createTextNode( contactPhone );
358 phoneElem.appendChild( phoneText );
359 contactInfoElem.appendChild( phoneElem );
362 if ( !contactMail.isEmpty() )
364 QDomElement mailElem = doc.createElement( QStringLiteral(
"ContactElectronicMailAddress" ) );
365 QDomText mailText = doc.createTextNode( contactMail );
366 mailElem.appendChild( mailText );
367 contactInfoElem.appendChild( mailElem );
370 serviceElem.appendChild( contactInfoElem );
373 QDomElement feesElem = doc.createElement( QStringLiteral(
"Fees" ) );
374 QDomText feesText = doc.createTextNode( QStringLiteral(
"None" ) );
376 if ( !fees.isEmpty() )
378 feesText = doc.createTextNode( fees );
380 feesElem.appendChild( feesText );
381 serviceElem.appendChild( feesElem );
383 QDomElement accessConstraintsElem = doc.createElement( QStringLiteral(
"AccessConstraints" ) );
384 QDomText accessConstraintsText = doc.createTextNode( QStringLiteral(
"None" ) );
386 if ( !accessConstraints.isEmpty() )
388 accessConstraintsText = doc.createTextNode( accessConstraints );
390 accessConstraintsElem.appendChild( accessConstraintsText );
391 serviceElem.appendChild( accessConstraintsElem );
393 if ( version == QLatin1String(
"1.3.0" ) )
398 QDomElement maxWidthElem = doc.createElement( QStringLiteral(
"MaxWidth" ) );
399 QDomText maxWidthText = doc.createTextNode( QString::number( maxWidth ) );
400 maxWidthElem.appendChild( maxWidthText );
401 serviceElem.appendChild( maxWidthElem );
407 QDomElement maxHeightElem = doc.createElement( QStringLiteral(
"MaxHeight" ) );
408 QDomText maxHeightText = doc.createTextNode( QString::number( maxHeight ) );
409 maxHeightElem.appendChild( maxHeightText );
410 serviceElem.appendChild( maxHeightElem );
427 QString hrefString = href.toString();
428 hrefString.append( href.hasQuery() ?
"&" :
"?" );
430 QDomElement capabilityElem = doc.createElement( QStringLiteral(
"Capability" ) );
433 QDomElement requestElem = doc.createElement( QStringLiteral(
"Request" ) );
434 capabilityElem.appendChild( requestElem );
436 QDomElement dcpTypeElem = doc.createElement( QStringLiteral(
"DCPType" ) );
437 QDomElement httpElem = doc.createElement( QStringLiteral(
"HTTP" ) );
438 dcpTypeElem.appendChild( httpElem );
441 std::function < void ( QDomElement &,
const QString & ) > appendFormat = [&doc]( QDomElement & elem,
const QString & format )
443 QDomElement formatElem = doc.createElement( QStringLiteral(
"Format" ) );
444 formatElem.appendChild( doc.createTextNode( format ) );
445 elem.appendChild( formatElem );
451 elem = doc.createElement( QStringLiteral(
"GetCapabilities" ) );
452 appendFormat( elem, ( version == QLatin1String(
"1.1.1" ) ?
"application/vnd.ogc.wms_xml" :
"text/xml" ) );
453 elem.appendChild( dcpTypeElem );
454 requestElem.appendChild( elem );
459 if ( parameters.value( QStringLiteral(
"SERVICE" ) ).compare( QLatin1String(
"WMS" ), Qt::CaseInsensitive ) != 0 )
461 QDomElement soapElem = doc.createElement( QStringLiteral(
"SOAP" ) );
462 httpElem.appendChild( soapElem );
463 QDomElement soapResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
464 soapResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
465 soapResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
466 soapResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), hrefString );
467 soapElem.appendChild( soapResourceElem );
471 QDomElement getElem = doc.createElement( QStringLiteral(
"Get" ) );
472 httpElem.appendChild( getElem );
473 QDomElement olResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
474 olResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
475 olResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
476 olResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), hrefString );
477 getElem.appendChild( olResourceElem );
480 elem = doc.createElement( QStringLiteral(
"GetMap" ) );
481 appendFormat( elem, QStringLiteral(
"image/jpeg" ) );
482 appendFormat( elem, QStringLiteral(
"image/png" ) );
483 appendFormat( elem, QStringLiteral(
"image/png; mode=16bit" ) );
484 appendFormat( elem, QStringLiteral(
"image/png; mode=8bit" ) );
485 appendFormat( elem, QStringLiteral(
"image/png; mode=1bit" ) );
486 appendFormat( elem, QStringLiteral(
"application/dxf" ) );
487 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
488 requestElem.appendChild( elem );
491 elem = doc.createElement( QStringLiteral(
"GetFeatureInfo" ) );
492 appendFormat( elem, QStringLiteral(
"text/plain" ) );
493 appendFormat( elem, QStringLiteral(
"text/html" ) );
494 appendFormat( elem, QStringLiteral(
"text/xml" ) );
495 appendFormat( elem, QStringLiteral(
"application/vnd.ogc.gml" ) );
496 appendFormat( elem, QStringLiteral(
"application/vnd.ogc.gml/3.1.1" ) );
497 appendFormat( elem, QStringLiteral(
"application/json" ) );
498 appendFormat( elem, QStringLiteral(
"application/geo+json" ) );
499 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
500 requestElem.appendChild( elem );
503 elem = doc.createElement( ( version == QLatin1String(
"1.1.1" ) ?
"GetLegendGraphic" :
"sld:GetLegendGraphic" ) );
504 appendFormat( elem, QStringLiteral(
"image/jpeg" ) );
505 appendFormat( elem, QStringLiteral(
"image/png" ) );
506 appendFormat( elem, QStringLiteral(
"application/json" ) );
507 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
508 requestElem.appendChild( elem );
511 elem = doc.createElement( ( version == QLatin1String(
"1.1.1" ) ?
"DescribeLayer" :
"sld:DescribeLayer" ) );
512 appendFormat( elem, QStringLiteral(
"text/xml" ) );
513 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
514 requestElem.appendChild( elem );
517 elem = doc.createElement( ( version == QLatin1String(
"1.1.1" ) ?
"GetStyles" :
"qgs:GetStyles" ) );
518 appendFormat( elem, QStringLiteral(
"text/xml" ) );
519 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
520 requestElem.appendChild( elem );
526 elem = doc.createElement( QStringLiteral(
"GetPrint" ) );
527 appendFormat( elem, QStringLiteral(
"svg" ) );
528 appendFormat( elem, QStringLiteral(
"png" ) );
529 appendFormat( elem, QStringLiteral(
"pdf" ) );
530 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
531 requestElem.appendChild( elem );
535 elem = doc.createElement( QStringLiteral(
"Exception" ) );
536 appendFormat( elem, ( version == QLatin1String(
"1.1.1" ) ?
"application/vnd.ogc.se_xml" :
"XML" ) );
537 capabilityElem.appendChild( elem );
540 if ( version == QLatin1String(
"1.3.0" ) )
542 elem = doc.createElement( QStringLiteral(
"sld:UserDefinedSymbolization" ) );
543 elem.setAttribute( QStringLiteral(
"SupportSLD" ), QStringLiteral(
"1" ) );
544 elem.setAttribute( QStringLiteral(
"UserLayer" ), QStringLiteral(
"0" ) );
545 elem.setAttribute( QStringLiteral(
"UserStyle" ), QStringLiteral(
"1" ) );
546 elem.setAttribute( QStringLiteral(
"RemoteWFS" ), QStringLiteral(
"0" ) );
547 elem.setAttribute( QStringLiteral(
"InlineFeature" ), QStringLiteral(
"0" ) );
548 elem.setAttribute( QStringLiteral(
"RemoteWCS" ), QStringLiteral(
"0" ) );
549 capabilityElem.appendChild( elem );
557 return capabilityElem;
562 QDomElement inspireCapabilitiesElem;
565 return inspireCapabilitiesElem;
567 inspireCapabilitiesElem = doc.createElement( QStringLiteral(
"inspire_vs:ExtendedCapabilities" ) );
571 if ( !inspireMetadataUrl.isEmpty() )
573 QDomElement inspireCommonMetadataUrlElem = doc.createElement( QStringLiteral(
"inspire_common:MetadataUrl" ) );
574 inspireCommonMetadataUrlElem.setAttribute( QStringLiteral(
"xsi:type" ), QStringLiteral(
"inspire_common:resourceLocatorType" ) );
576 QDomElement inspireCommonMetadataUrlUrlElem = doc.createElement( QStringLiteral(
"inspire_common:URL" ) );
577 inspireCommonMetadataUrlUrlElem.appendChild( doc.createTextNode( inspireMetadataUrl ) );
578 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlUrlElem );
581 if ( !inspireMetadataUrlType.isNull() )
583 QDomElement inspireCommonMetadataUrlMediaTypeElem = doc.createElement( QStringLiteral(
"inspire_common:MediaType" ) );
584 inspireCommonMetadataUrlMediaTypeElem.appendChild( doc.createTextNode( inspireMetadataUrlType ) );
585 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlMediaTypeElem );
588 inspireCapabilitiesElem.appendChild( inspireCommonMetadataUrlElem );
592 QDomElement inspireCommonResourceTypeElem = doc.createElement( QStringLiteral(
"inspire_common:ResourceType" ) );
593 inspireCommonResourceTypeElem.appendChild( doc.createTextNode( QStringLiteral(
"service" ) ) );
594 inspireCapabilitiesElem.appendChild( inspireCommonResourceTypeElem );
596 QDomElement inspireCommonSpatialDataServiceTypeElem = doc.createElement( QStringLiteral(
"inspire_common:SpatialDataServiceType" ) );
597 inspireCommonSpatialDataServiceTypeElem.appendChild( doc.createTextNode( QStringLiteral(
"view" ) ) );
598 inspireCapabilitiesElem.appendChild( inspireCommonSpatialDataServiceTypeElem );
601 if ( !inspireTemporalReference.isNull() )
603 QDomElement inspireCommonTemporalReferenceElem = doc.createElement( QStringLiteral(
"inspire_common:TemporalReference" ) );
604 QDomElement inspireCommonDateOfLastRevisionElem = doc.createElement( QStringLiteral(
"inspire_common:DateOfLastRevision" ) );
605 inspireCommonDateOfLastRevisionElem.appendChild( doc.createTextNode( inspireTemporalReference ) );
606 inspireCommonTemporalReferenceElem.appendChild( inspireCommonDateOfLastRevisionElem );
607 inspireCapabilitiesElem.appendChild( inspireCommonTemporalReferenceElem );
610 QDomElement inspireCommonMetadataPointOfContactElem = doc.createElement( QStringLiteral(
"inspire_common:MetadataPointOfContact" ) );
613 QDomElement inspireCommonOrganisationNameElem = doc.createElement( QStringLiteral(
"inspire_common:OrganisationName" ) );
614 if ( !contactOrganization.isNull() )
616 inspireCommonOrganisationNameElem.appendChild( doc.createTextNode( contactOrganization ) );
618 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonOrganisationNameElem );
621 QDomElement inspireCommonEmailAddressElem = doc.createElement( QStringLiteral(
"inspire_common:EmailAddress" ) );
622 if ( !contactMail.isNull() )
624 inspireCommonEmailAddressElem.appendChild( doc.createTextNode( contactMail ) );
626 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonEmailAddressElem );
628 inspireCapabilitiesElem.appendChild( inspireCommonMetadataPointOfContactElem );
631 if ( !inspireMetadataDate.isNull() )
633 QDomElement inspireCommonMetadataDateElem = doc.createElement( QStringLiteral(
"inspire_common:MetadataDate" ) );
634 inspireCommonMetadataDateElem.appendChild( doc.createTextNode( inspireMetadataDate ) );
635 inspireCapabilitiesElem.appendChild( inspireCommonMetadataDateElem );
640 QDomElement inspireCommonSupportedLanguagesElem = doc.createElement( QStringLiteral(
"inspire_common:SupportedLanguages" ) );
641 inspireCommonSupportedLanguagesElem.setAttribute( QStringLiteral(
"xsi:type" ), QStringLiteral(
"inspire_common:supportedLanguagesType" ) );
643 QDomElement inspireCommonLanguageElem = doc.createElement( QStringLiteral(
"inspire_common:Language" ) );
646 QDomElement inspireCommonDefaultLanguageElem = doc.createElement( QStringLiteral(
"inspire_common:DefaultLanguage" ) );
647 inspireCommonDefaultLanguageElem.appendChild( inspireCommonLanguageElem );
648 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonDefaultLanguageElem );
652 QDomElement inspireCommonSupportedLanguageElem = doc.createElement(
"inspire_common:SupportedLanguage" );
653 inspireCommonSupportedLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
654 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonSupportedLanguageElem );
657 inspireCapabilitiesElem.appendChild( inspireCommonSupportedLanguagesElem );
659 QDomElement inspireCommonResponseLanguageElem = doc.createElement( QStringLiteral(
"inspire_common:ResponseLanguage" ) );
660 inspireCommonResponseLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
661 inspireCapabilitiesElem.appendChild( inspireCommonResponseLanguageElem );
663 return inspireCapabilitiesElem;
669 if ( projectComposers.size() == 0 )
670 return QDomElement();
674 QDomElement composerTemplatesElem = doc.createElement( QStringLiteral(
"ComposerTemplates" ) );
675 QList<QgsPrintLayout *>::const_iterator cIt = projectComposers.constBegin();
676 for ( ; cIt != projectComposers.constEnd(); ++cIt )
679 if ( restrictedComposers.contains( layout->
name() ) )
691 QDomElement composerTemplateElem = doc.createElement( QStringLiteral(
"ComposerTemplate" ) );
692 composerTemplateElem.setAttribute( QStringLiteral(
"name" ), layout->
name() );
695 composerTemplateElem.setAttribute( QStringLiteral(
"width" ), width.
length() );
696 composerTemplateElem.setAttribute( QStringLiteral(
"height" ), height.
length() );
700 if ( atlas && atlas->
enabled() )
702 composerTemplateElem.setAttribute( QStringLiteral(
"atlasEnabled" ), QStringLiteral(
"1" ) );
709 layerName = cLayer->
id();
711 else if ( layerName.isEmpty() )
713 layerName = cLayer->
name();
715 composerTemplateElem.setAttribute( QStringLiteral(
"atlasCoverageLayer" ), layerName );
720 QList<QgsLayoutItemMap *> layoutMapList;
722 QList<QgsLayoutItemMap *>::const_iterator cmIt = layoutMapList.constBegin();
725 for ( ; cmIt != layoutMapList.constEnd(); ++cmIt )
729 QDomElement composerMapElem = doc.createElement( QStringLiteral(
"ComposerMap" ) );
730 composerMapElem.setAttribute( QStringLiteral(
"name" ), QStringLiteral(
"map%1" ).arg( mapId ) );
732 composerMapElem.setAttribute( QStringLiteral(
"width" ), composerMap->rect().width() );
733 composerMapElem.setAttribute( QStringLiteral(
"height" ), composerMap->rect().height() );
734 composerTemplateElem.appendChild( composerMapElem );
738 QList<QgsLayoutItemLabel *> composerLabelList;
740 QList<QgsLayoutItemLabel *>::const_iterator clIt = composerLabelList.constBegin();
741 for ( ; clIt != composerLabelList.constEnd(); ++clIt )
744 QString
id = composerLabel->
id();
748 QDomElement composerLabelElem = doc.createElement( QStringLiteral(
"ComposerLabel" ) );
749 composerLabelElem.setAttribute( QStringLiteral(
"name" ), id );
750 composerTemplateElem.appendChild( composerLabelElem );
754 QList<QgsLayoutItemHtml *> composerHtmlList;
756 QList<QgsLayoutItemHtml *>::const_iterator chIt = composerHtmlList.constBegin();
757 for ( ; chIt != composerHtmlList.constEnd(); ++chIt )
763 QString
id = composerHtml->
frame( 0 )->
id();
767 QDomElement composerHtmlElem = doc.createElement( QStringLiteral(
"ComposerHtml" ) );
768 composerHtmlElem.setAttribute( QStringLiteral(
"name" ), id );
769 composerTemplateElem.appendChild( composerHtmlElem );
772 composerTemplatesElem.appendChild( composerTemplateElem );
775 if ( composerTemplatesElem.childNodes().size() == 0 )
776 return QDomElement();
778 return composerTemplatesElem;
785 return QDomElement();
787 QDomElement wfsLayersElem = doc.createElement( QStringLiteral(
"WFSLayers" ) );
796 QDomElement wfsLayerElem = doc.createElement( QStringLiteral(
"WFSLayer" ) );
799 wfsLayerElem.setAttribute( QStringLiteral(
"name" ), layer->
id() );
803 wfsLayerElem.setAttribute( QStringLiteral(
"name" ), layer->
name() );
805 wfsLayersElem.appendChild( wfsLayerElem );
808 return wfsLayersElem;
812 const QgsProject *project,
const QString &version,
817 QDomElement layerParentElem = doc.createElement( QStringLiteral(
"Layer" ) );
821 if ( rootLayerName.isEmpty() && !project->
title().isEmpty() )
823 rootLayerName = project->
title();
826 if ( !rootLayerName.isEmpty() )
828 QDomElement layerParentNameElem = doc.createElement( QStringLiteral(
"Name" ) );
829 QDomText layerParentNameText = doc.createTextNode( rootLayerName );
830 layerParentNameElem.appendChild( layerParentNameText );
831 layerParentElem.appendChild( layerParentNameElem );
835 QDomElement layerParentTitleElem = doc.createElement( QStringLiteral(
"Title" ) );
837 layerParentTitleElem.appendChild( layerParentTitleText );
838 layerParentElem.appendChild( layerParentTitleElem );
842 if ( !rootLayerAbstract.isEmpty() )
844 QDomElement layerParentAbstElem = doc.createElement( QStringLiteral(
"Abstract" ) );
845 QDomText layerParentAbstText = doc.createCDATASection( rootLayerAbstract );
846 layerParentAbstElem.appendChild( layerParentAbstText );
847 layerParentElem.appendChild( layerParentAbstElem );
851 addKeywordListElement( project, doc, layerParentElem );
854 if ( projectSettings )
856 QDomElement treeNameElem = doc.createElement( QStringLiteral(
"TreeName" ) );
857 QDomText treeNameText = doc.createTextNode( project->
title() );
858 treeNameElem.appendChild( treeNameText );
859 layerParentElem.appendChild( treeNameElem );
864 layerParentElem.setAttribute( QStringLiteral(
"queryable" ), QStringLiteral(
"1" ) );
868 layerParentElem.setAttribute( QStringLiteral(
"queryable" ), QStringLiteral(
"0" ) );
871 appendLayersFromTreeGroup( doc, layerParentElem, serverIface, project, version, request, projectLayerTreeRoot, projectSettings );
873 combineExtentAndCrsOfGroupChildren( doc, layerParentElem, project,
true );
875 return layerParentElem;
881 void appendLayersFromTreeGroup( QDomDocument &doc,
882 QDomElement &parentLayer,
885 const QString &version,
888 bool projectSettings )
894 QList< QgsLayerTreeNode * > layerTreeGroupChildren = layerTreeGroup->
children();
895 for (
int i = 0; i < layerTreeGroupChildren.size(); ++i )
898 QDomElement layerElem = doc.createElement( QStringLiteral(
"Layer" ) );
900 if ( projectSettings )
902 layerElem.setAttribute( QStringLiteral(
"visible" ), treeNode->
isVisible() );
904 layerElem.setAttribute( QStringLiteral(
"expanded" ), treeNode->
isExpanded() );
911 QString name = treeGroupChild->
name();
912 if ( restrictedLayers.contains( name ) )
917 if ( projectSettings )
919 layerElem.setAttribute( QStringLiteral(
"mutuallyExclusive" ), treeGroupChild->
isMutuallyExclusive() );
922 QString shortName = treeGroupChild->
customProperty( QStringLiteral(
"wmsShortName" ) ).toString();
923 QString title = treeGroupChild->
customProperty( QStringLiteral(
"wmsTitle" ) ).toString();
925 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
927 if ( !shortName.isEmpty() )
928 nameText = doc.createTextNode( shortName );
930 nameText = doc.createTextNode( name );
931 nameElem.appendChild( nameText );
932 layerElem.appendChild( nameElem );
934 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
936 if ( !title.isEmpty() )
937 titleText = doc.createTextNode( title );
939 titleText = doc.createTextNode( name );
940 titleElem.appendChild( titleText );
941 layerElem.appendChild( titleElem );
943 QString
abstract = treeGroupChild->
customProperty( QStringLiteral(
"wmsAbstract" ) ).toString();
944 if ( !
abstract.isEmpty() )
946 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
947 QDomText abstractText = doc.createTextNode(
abstract );
948 abstractElem.appendChild( abstractText );
949 layerElem.appendChild( abstractElem );
953 if ( projectSettings )
955 QDomElement treeNameElem = doc.createElement( QStringLiteral(
"TreeName" ) );
956 QDomText treeNameText = doc.createTextNode( name );
957 treeNameElem.appendChild( treeNameText );
958 layerElem.appendChild( treeNameElem );
964 layerElem.setAttribute( QStringLiteral(
"queryable" ), QStringLiteral(
"1" ) );
968 layerElem.setAttribute( QStringLiteral(
"queryable" ), QStringLiteral(
"0" ) );
971 appendLayersFromTreeGroup( doc, layerElem, serverIface, project, version, request, treeGroupChild, projectSettings );
973 combineExtentAndCrsOfGroupChildren( doc, layerElem, project );
979 if ( !l || restrictedLayers.contains( l->
name() ) )
984 #ifdef HAVE_SERVER_PYTHON_PLUGINS
991 QString wmsName = l->
name();
1004 layerElem.setAttribute( QStringLiteral(
"queryable" ), QStringLiteral(
"0" ) );
1008 layerElem.setAttribute( QStringLiteral(
"queryable" ), QStringLiteral(
"1" ) );
1011 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
1012 QDomText nameText = doc.createTextNode( wmsName );
1013 nameElem.appendChild( nameText );
1014 layerElem.appendChild( nameElem );
1016 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
1017 QString title = l->
title();
1018 if ( title.isEmpty() )
1022 QDomText titleText = doc.createTextNode( title );
1023 titleElem.appendChild( titleText );
1024 layerElem.appendChild( titleElem );
1027 if ( !
abstract.isEmpty() )
1029 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
1030 QDomText abstractText = doc.createTextNode(
abstract );
1031 abstractElem.appendChild( abstractText );
1032 layerElem.appendChild( abstractElem );
1038 QStringList keywordStringList = l->
keywordList().split(
',' );
1040 QDomElement keywordListElem = doc.createElement( QStringLiteral(
"KeywordList" ) );
1041 for (
int i = 0; i < keywordStringList.size(); ++i )
1043 QDomElement keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1044 QDomText keywordText = doc.createTextNode( keywordStringList.at( i ).trimmed() );
1045 keywordElem.appendChild( keywordText );
1048 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"SIA_Geo405" ) );
1050 keywordListElem.appendChild( keywordElem );
1052 layerElem.appendChild( keywordListElem );
1056 bool geometryLayer =
true;
1064 geometryLayer =
false;
1070 if ( geometryLayer )
1072 QStringList crsList;
1075 appendCrsElementsToLayer( doc, layerElem, crsList, outputCrsList );
1093 else if ( vl->
crs() != project->
crs() )
1098 extent = ct.transform( extent );
1102 QgsMessageLog::logMessage( QStringLiteral(
"Error transforming extent for layer %1: %2" ).arg( vl->
name() ).arg( cse.
what() ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Warning );
1109 appendLayerBoundingBoxes( doc, layerElem, extent, l->
crs(), crsList, outputCrsList, project );
1113 appendLayerStyles( doc, layerElem, l, project, version, request );
1118 if ( version == QLatin1String(
"1.1.1" ) )
1121 double SCALE_TO_SCALEHINT =
OGC_PX_M * M_SQRT2;
1123 QDomElement scaleHintElem = doc.createElement( QStringLiteral(
"ScaleHint" ) );
1124 scaleHintElem.setAttribute( QStringLiteral(
"min" ), QString::number( l->
maximumScale() * SCALE_TO_SCALEHINT ) );
1125 scaleHintElem.setAttribute( QStringLiteral(
"max" ), QString::number( l->
minimumScale() * SCALE_TO_SCALEHINT ) );
1126 layerElem.appendChild( scaleHintElem );
1130 QString minScaleString = QString::number( l->
maximumScale() );
1131 QDomElement minScaleElem = doc.createElement( QStringLiteral(
"MinScaleDenominator" ) );
1132 QDomText minScaleText = doc.createTextNode( minScaleString );
1133 minScaleElem.appendChild( minScaleText );
1134 layerElem.appendChild( minScaleElem );
1136 QString maxScaleString = QString::number( l->
minimumScale() );
1137 QDomElement maxScaleElem = doc.createElement( QStringLiteral(
"MaxScaleDenominator" ) );
1138 QDomText maxScaleText = doc.createTextNode( maxScaleString );
1139 maxScaleElem.appendChild( maxScaleText );
1140 layerElem.appendChild( maxScaleElem );
1145 QString dataUrl = l->
dataUrl();
1146 if ( !dataUrl.isEmpty() )
1148 QDomElement dataUrlElem = doc.createElement( QStringLiteral(
"DataURL" ) );
1149 QDomElement dataUrlFormatElem = doc.createElement( QStringLiteral(
"Format" ) );
1151 QDomText dataUrlFormatText = doc.createTextNode( dataUrlFormat );
1152 dataUrlFormatElem.appendChild( dataUrlFormatText );
1153 dataUrlElem.appendChild( dataUrlFormatElem );
1154 QDomElement dataORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1155 dataORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1156 dataORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1157 dataORElem.setAttribute( QStringLiteral(
"xlink:href" ), dataUrl );
1158 dataUrlElem.appendChild( dataORElem );
1159 layerElem.appendChild( dataUrlElem );
1164 if ( !attribution.isEmpty() )
1166 QDomElement attribElem = doc.createElement( QStringLiteral(
"Attribution" ) );
1167 QDomElement attribTitleElem = doc.createElement( QStringLiteral(
"Title" ) );
1168 QDomText attribText = doc.createTextNode( attribution );
1169 attribTitleElem.appendChild( attribText );
1170 attribElem.appendChild( attribTitleElem );
1172 if ( !attributionUrl.isEmpty() )
1174 QDomElement attribORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1175 attribORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1176 attribORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1177 attribORElem.setAttribute( QStringLiteral(
"xlink:href" ), attributionUrl );
1178 attribElem.appendChild( attribORElem );
1180 layerElem.appendChild( attribElem );
1185 if ( !metadataUrl.isEmpty() )
1187 QDomElement metaUrlElem = doc.createElement( QStringLiteral(
"MetadataURL" ) );
1189 if ( version == QLatin1String(
"1.1.1" ) )
1191 metaUrlElem.setAttribute( QStringLiteral(
"type" ), metadataUrlType );
1193 else if ( metadataUrlType == QLatin1String(
"FGDC" ) )
1195 metaUrlElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"FGDC:1998" ) );
1197 else if ( metadataUrlType == QLatin1String(
"TC211" ) )
1199 metaUrlElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"ISO19115:2003" ) );
1203 metaUrlElem.setAttribute( QStringLiteral(
"type" ), metadataUrlType );
1206 if ( !metadataUrlFormat.isEmpty() )
1208 QDomElement metaUrlFormatElem = doc.createElement( QStringLiteral(
"Format" ) );
1209 QDomText metaUrlFormatText = doc.createTextNode( metadataUrlFormat );
1210 metaUrlFormatElem.appendChild( metaUrlFormatText );
1211 metaUrlElem.appendChild( metaUrlFormatElem );
1213 QDomElement metaUrlORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1214 metaUrlORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1215 metaUrlORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1216 metaUrlORElem.setAttribute( QStringLiteral(
"xlink:href" ), metadataUrl );
1217 metaUrlElem.appendChild( metaUrlORElem );
1218 layerElem.appendChild( metaUrlElem );
1230 if ( fieldIndex == -1 )
1235 QSet<QVariant> uniqueValues = vl->
uniqueValues( fieldIndex );
1238 if ( !dim.endFieldName.isEmpty() )
1240 int endFieldIndex = vl->
fields().
indexOf( dim.endFieldName );
1242 if ( endFieldIndex == -1 )
1246 uniqueValues.unite( vl->
uniqueValues( endFieldIndex ) );
1249 QList<QVariant> values = qgis::setToList( uniqueValues );
1250 std::sort( values.begin(), values.end() );
1252 QDomElement dimElem = doc.createElement( QStringLiteral(
"Dimension" ) );
1253 dimElem.setAttribute( QStringLiteral(
"name" ), dim.name );
1254 if ( !dim.units.isEmpty() )
1256 dimElem.setAttribute( QStringLiteral(
"units" ), dim.units );
1258 if ( !dim.unitSymbol.isEmpty() )
1260 dimElem.setAttribute( QStringLiteral(
"unitSymbol" ), dim.unitSymbol );
1264 dimElem.setAttribute( QStringLiteral(
"default" ), values.first().toString() );
1268 dimElem.setAttribute( QStringLiteral(
"default" ), values.last().toString() );
1272 dimElem.setAttribute( QStringLiteral(
"default" ), dim.referenceValue.toString() );
1274 dimElem.setAttribute( QStringLiteral(
"multipleValues" ), QStringLiteral(
"1" ) );
1275 dimElem.setAttribute( QStringLiteral(
"nearestValue" ), QStringLiteral(
"0" ) );
1277 QStringList strValues;
1278 for (
const QVariant &v : values )
1280 strValues << v.toString();
1282 QDomText dimValuesText = doc.createTextNode( strValues.join( QLatin1String(
", " ) ) );
1283 dimElem.appendChild( dimValuesText );
1284 layerElem.appendChild( dimElem );
1288 if ( projectSettings )
1290 appendLayerProjectSettings( doc, layerElem, l );
1294 parentLayer.appendChild( layerElem );
1298 void appendLayerStyles( QDomDocument &doc, QDomElement &layerElem,
QgsMapLayer *currentLayer,
1305 QString hrefString = href.toString();
1306 hrefString.append( href.hasQuery() ?
"&" :
"?" );
1309 QDomElement styleElem = doc.createElement( QStringLiteral(
"Style" ) );
1310 QDomElement styleNameElem = doc.createElement( QStringLiteral(
"Name" ) );
1311 QDomText styleNameText = doc.createTextNode( styleName );
1312 styleNameElem.appendChild( styleNameText );
1313 QDomElement styleTitleElem = doc.createElement( QStringLiteral(
"Title" ) );
1314 QDomText styleTitleText = doc.createTextNode( styleName );
1315 styleTitleElem.appendChild( styleTitleText );
1316 styleElem.appendChild( styleNameElem );
1317 styleElem.appendChild( styleTitleElem );
1320 QDomElement getLayerLegendGraphicElem = doc.createElement( QStringLiteral(
"LegendURL" ) );
1322 QString customHrefString = currentLayer->
legendUrl();
1324 QStringList getLayerLegendGraphicFormats;
1325 if ( !customHrefString.isEmpty() )
1331 getLayerLegendGraphicFormats << QStringLiteral(
"image/png" );
1334 for (
int i = 0; i < getLayerLegendGraphicFormats.size(); ++i )
1336 QDomElement getLayerLegendGraphicFormatElem = doc.createElement( QStringLiteral(
"Format" ) );
1337 QString getLayerLegendGraphicFormat = getLayerLegendGraphicFormats[i];
1338 QDomText getLayerLegendGraphicFormatText = doc.createTextNode( getLayerLegendGraphicFormat );
1339 getLayerLegendGraphicFormatElem.appendChild( getLayerLegendGraphicFormatText );
1340 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicFormatElem );
1344 if ( customHrefString.isEmpty() )
1346 QString layerName = currentLayer->
name();
1348 layerName = currentLayer->
id();
1349 else if ( !currentLayer->
shortName().isEmpty() )
1351 QUrlQuery mapUrl( hrefString );
1352 mapUrl.addQueryItem( QStringLiteral(
"SERVICE" ), QStringLiteral(
"WMS" ) );
1353 mapUrl.addQueryItem( QStringLiteral(
"VERSION" ), version );
1354 mapUrl.addQueryItem( QStringLiteral(
"REQUEST" ), QStringLiteral(
"GetLegendGraphic" ) );
1355 mapUrl.addQueryItem( QStringLiteral(
"LAYER" ), layerName );
1356 mapUrl.addQueryItem( QStringLiteral(
"FORMAT" ), QStringLiteral(
"image/png" ) );
1357 mapUrl.addQueryItem( QStringLiteral(
"STYLE" ), styleNameText.data() );
1358 if ( version == QLatin1String(
"1.3.0" ) )
1360 mapUrl.addQueryItem( QStringLiteral(
"SLD_VERSION" ), QStringLiteral(
"1.1.0" ) );
1362 customHrefString = mapUrl.toString();
1365 QDomElement getLayerLegendGraphicORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1366 getLayerLegendGraphicORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1367 getLayerLegendGraphicORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1368 getLayerLegendGraphicORElem.setAttribute( QStringLiteral(
"xlink:href" ), customHrefString );
1369 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicORElem );
1370 styleElem.appendChild( getLayerLegendGraphicElem );
1372 layerElem.appendChild( styleElem );
1376 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
1377 const QStringList &crsList,
const QStringList &constrainedCrsList )
1379 if ( layerElement.isNull() )
1385 QDomElement titleElement = layerElement.firstChildElement( QStringLiteral(
"Title" ) );
1386 QDomElement abstractElement = layerElement.firstChildElement( QStringLiteral(
"Abstract" ) );
1387 QDomElement keywordListElement = layerElement.firstChildElement( QStringLiteral(
"KeywordList" ) );
1388 QDomElement CRSPrecedingElement = !keywordListElement.isNull() ? keywordListElement : !abstractElement.isNull() ? abstractElement : titleElement;
1390 if ( CRSPrecedingElement.isNull() )
1393 const QDomElement keyElement = layerElement.firstChildElement( QStringLiteral(
"KeywordList" ) );
1394 CRSPrecedingElement = keyElement;
1398 if ( !constrainedCrsList.isEmpty() )
1400 for (
int i = constrainedCrsList.size() - 1; i >= 0; --i )
1402 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, constrainedCrsList.at( i ) );
1407 for (
const QString &
crs : crsList )
1409 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement,
crs );
1414 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, QString(
"CRS:84" ) );
1417 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
1418 const QString &crsText )
1420 if ( crsText.isEmpty() )
1422 QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1423 QDomElement crsElement = doc.createElement( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS" );
1424 QDomText crsTextNode = doc.createTextNode( crsText );
1425 crsElement.appendChild( crsTextNode );
1426 layerElement.insertAfter( crsElement, precedingElement );
1429 void appendLayerBoundingBoxes( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &lExtent,
1431 const QStringList &constrainedCrsList,
const QgsProject *project )
1433 if ( layerElem.isNull() )
1442 layerExtent.
grow( 0.000001 );
1446 int wgs84precision = 6;
1448 QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1451 QDomElement ExGeoBBoxElement;
1454 if ( !layerExtent.
isNull() )
1459 wgs84BoundingRect = exGeoTransform.transformBoundingBox( layerExtent );
1463 QgsMessageLog::logMessage( QStringLiteral(
"Error transforming extent: %1" ).arg( cse.
what() ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Warning );
1468 if ( version == QLatin1String(
"1.1.1" ) )
1470 ExGeoBBoxElement = doc.createElement( QStringLiteral(
"LatLonBoundingBox" ) );
1478 ExGeoBBoxElement = doc.createElement( QStringLiteral(
"EX_GeographicBoundingBox" ) );
1479 QDomElement wBoundLongitudeElement = doc.createElement( QStringLiteral(
"westBoundLongitude" ) );
1481 wBoundLongitudeElement.appendChild( wBoundLongitudeText );
1482 ExGeoBBoxElement.appendChild( wBoundLongitudeElement );
1483 QDomElement eBoundLongitudeElement = doc.createElement( QStringLiteral(
"eastBoundLongitude" ) );
1485 eBoundLongitudeElement.appendChild( eBoundLongitudeText );
1486 ExGeoBBoxElement.appendChild( eBoundLongitudeElement );
1487 QDomElement sBoundLatitudeElement = doc.createElement( QStringLiteral(
"southBoundLatitude" ) );
1489 sBoundLatitudeElement.appendChild( sBoundLatitudeText );
1490 ExGeoBBoxElement.appendChild( sBoundLatitudeElement );
1491 QDomElement nBoundLatitudeElement = doc.createElement( QStringLiteral(
"northBoundLatitude" ) );
1493 nBoundLatitudeElement.appendChild( nBoundLatitudeText );
1494 ExGeoBBoxElement.appendChild( nBoundLatitudeElement );
1497 if ( !wgs84BoundingRect.
isNull() )
1499 QDomElement lastCRSElem = layerElem.lastChildElement( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS" );
1500 if ( !lastCRSElem.isNull() )
1502 layerElem.insertAfter( ExGeoBBoxElement, lastCRSElem );
1506 layerElem.appendChild( ExGeoBBoxElement );
1511 if ( !constrainedCrsList.isEmpty() )
1513 for (
int i = constrainedCrsList.size() - 1; i >= 0; --i )
1515 appendLayerBoundingBox( doc, layerElem, layerExtent, layerCRS, constrainedCrsList.at( i ), project );
1520 for (
const QString &
crs : crsList )
1522 appendLayerBoundingBox( doc, layerElem, layerExtent, layerCRS,
crs, project );
1528 void appendLayerBoundingBox( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &layerExtent,
1532 if ( layerElem.isNull() )
1537 if ( crsText.isEmpty() )
1542 QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1548 if ( !layerExtent.
isNull() )
1553 crsExtent = crsTransform.transformBoundingBox( layerExtent );
1557 QgsMessageLog::logMessage( QStringLiteral(
"Error transforming extent: %1" ).arg( cse.
what() ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Warning );
1562 if ( crsExtent.
isNull() )
1574 QDomElement bBoxElement = doc.createElement( QStringLiteral(
"BoundingBox" ) );
1577 bBoxElement.setAttribute( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS",
crs.
authid() );
1590 QDomElement lastBBoxElem = layerElem.lastChildElement( QStringLiteral(
"BoundingBox" ) );
1591 if ( !lastBBoxElem.isNull() )
1593 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1597 lastBBoxElem = layerElem.lastChildElement( version == QLatin1String(
"1.1.1" ) ?
"LatLonBoundingBox" :
"EX_GeographicBoundingBox" );
1598 if ( !lastBBoxElem.isNull() )
1600 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1604 layerElem.appendChild( bBoxElement );
1609 QgsRectangle layerBoundingBoxInProjectCrs(
const QDomDocument &doc,
const QDomElement &layerElem,
1613 if ( layerElem.isNull() )
1619 QDomElement boundingBoxElem = layerElem.firstChildElement( QStringLiteral(
"BoundingBox" ) );
1620 if ( boundingBoxElem.isNull() )
1625 double minx, miny, maxx, maxy;
1627 minx = boundingBoxElem.attribute( QStringLiteral(
"minx" ) ).toDouble( &conversionOk );
1628 if ( !conversionOk )
1632 miny = boundingBoxElem.attribute( QStringLiteral(
"miny" ) ).toDouble( &conversionOk );
1633 if ( !conversionOk )
1637 maxx = boundingBoxElem.attribute( QStringLiteral(
"maxx" ) ).toDouble( &conversionOk );
1638 if ( !conversionOk )
1642 maxy = boundingBoxElem.attribute( QStringLiteral(
"maxy" ) ).toDouble( &conversionOk );
1643 if ( !conversionOk )
1649 QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1663 if ( version != QLatin1String(
"1.1.1" ) && layerCrs.
hasAxisInverted() )
1674 BBox = t.transformBoundingBox( BBox );
1678 QgsMessageLog::logMessage( QStringLiteral(
"Error transforming extent: %1" ).arg( cse.
what() ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Warning );
1685 bool crsSetFromLayerElement(
const QDomElement &layerElement, QSet<QString> &crsSet )
1687 if ( layerElement.isNull() )
1694 QDomNodeList crsNodeList;
1695 crsNodeList = layerElement.elementsByTagName( QStringLiteral(
"CRS" ) );
1696 for (
int i = 0; i < crsNodeList.size(); ++i )
1698 crsSet.insert( crsNodeList.at( i ).toElement().text() );
1701 crsNodeList = layerElement.elementsByTagName( QStringLiteral(
"SRS" ) );
1702 for (
int i = 0; i < crsNodeList.size(); ++i )
1704 crsSet.insert( crsNodeList.at( i ).toElement().text() );
1710 void combineExtentAndCrsOfGroupChildren( QDomDocument &doc, QDomElement &groupElem,
const QgsProject *project,
1711 bool considerMapExtent )
1714 QSet<QString> combinedCRSSet;
1715 bool firstBBox =
true;
1716 bool firstCRSSet =
true;
1718 QDomNodeList layerChildren = groupElem.childNodes();
1719 for (
int j = 0; j < layerChildren.size(); ++j )
1721 QDomElement childElem = layerChildren.at( j ).toElement();
1723 if ( childElem.tagName() != QLatin1String(
"Layer" ) )
1726 QgsRectangle bbox = layerBoundingBoxInProjectCrs( doc, childElem, project );
1736 combinedBBox = bbox;
1746 QSet<QString> crsSet;
1747 if ( crsSetFromLayerElement( childElem, crsSet ) )
1751 combinedCRSSet = crsSet;
1752 firstCRSSet =
false;
1756 combinedCRSSet.intersect( crsSet );
1762 appendCrsElementsToLayer( doc, groupElem, qgis::setToList( combinedCRSSet ), outputCrsList );
1765 if ( considerMapExtent )
1770 combinedBBox = mapRect;
1773 appendLayerBoundingBoxes( doc, groupElem, combinedBBox, groupCRS, qgis::setToList( combinedCRSSet ), outputCrsList, project );
1777 void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem,
QgsServerInterface *serverIface,
1780 #ifdef HAVE_SERVER_PYTHON_PLUGINS
1783 ( void )serverIface;
1788 QStringList layerList;
1791 QList< QgsMapLayer * > projectLayerOrder = projectLayerTreeRoot->
layerOrder();
1792 for (
int i = 0; i < projectLayerOrder.size(); ++i )
1796 if ( restrictedLayers.contains( l->
name() ) )
1800 #ifdef HAVE_SERVER_PYTHON_PLUGINS
1806 QString wmsName = l->
name();
1816 layerList << wmsName;
1819 if ( !layerList.isEmpty() )
1821 QStringList reversedList;
1822 reversedList.reserve( layerList.size() );
1823 for (
int i = layerList.size() - 1; i >= 0; --i )
1824 reversedList << layerList[ i ];
1826 QDomElement layerDrawingOrderElem = doc.createElement( QStringLiteral(
"LayerDrawingOrder" ) );
1827 QDomText drawingOrderText = doc.createTextNode( reversedList.join(
',' ) );
1828 layerDrawingOrderElem.appendChild( drawingOrderText );
1829 parentElem.appendChild( layerDrawingOrderElem );
1833 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem,
QgsMapLayer *currentLayer )
1835 if ( !currentLayer )
1841 QDomElement treeNameElem = doc.createElement( QStringLiteral(
"TreeName" ) );
1842 QDomText treeNameText = doc.createTextNode( currentLayer->
name() );
1843 treeNameElem.appendChild( treeNameText );
1844 layerElem.appendChild( treeNameElem );
1846 switch ( currentLayer->
type() )
1852 int displayFieldIdx = -1;
1853 QString displayField = QStringLiteral(
"maptip" );
1855 if ( exp.isField() )
1862 QDomElement attributesElem = doc.createElement( QStringLiteral(
"Attributes" ) );
1864 for (
int idx = 0; idx < layerFields.
count(); ++idx )
1872 if ( idx == displayFieldIdx )
1876 QDomElement attributeElem = doc.createElement( QStringLiteral(
"Attribute" ) );
1877 attributeElem.setAttribute( QStringLiteral(
"name" ),
field.
name() );
1878 attributeElem.setAttribute( QStringLiteral(
"type" ), QVariant::typeToName(
field.
type() ) );
1879 attributeElem.setAttribute( QStringLiteral(
"typeName" ),
field.
typeName() );
1881 if ( !alias.isEmpty() )
1883 attributeElem.setAttribute( QStringLiteral(
"alias" ), alias );
1887 attributeElem.setAttribute( QStringLiteral(
"editType" ), vLayer->
editorWidgetSetup( idx ).
type() );
1888 attributeElem.setAttribute( QStringLiteral(
"comment" ),
field.
comment() );
1889 attributeElem.setAttribute( QStringLiteral(
"length" ),
field.
length() );
1890 attributeElem.setAttribute( QStringLiteral(
"precision" ),
field.
precision() );
1891 attributesElem.appendChild( attributeElem );
1895 layerElem.setAttribute( QStringLiteral(
"displayField" ), displayField );
1899 if ( pkAttributes.size() > 0 )
1901 QDomElement pkElem = doc.createElement( QStringLiteral(
"PrimaryKey" ) );
1902 QgsAttributeList::const_iterator pkIt = pkAttributes.constBegin();
1903 for ( ; pkIt != pkAttributes.constEnd(); ++pkIt )
1905 QDomElement pkAttributeElem = doc.createElement( QStringLiteral(
"PrimaryKeyAttribute" ) );
1906 QDomText pkAttName = doc.createTextNode( layerFields.
at( *pkIt ).
name() );
1907 pkAttributeElem.appendChild( pkAttName );
1908 pkElem.appendChild( pkAttributeElem );
1910 layerElem.appendChild( pkElem );
1917 layerElem.setAttribute( QStringLiteral(
"opacity" ), QString::number( vLayer->
opacity() ) );
1919 layerElem.appendChild( attributesElem );
1926 if ( provider && provider->
name() ==
"wms" )
1929 QVariant wmsBackgroundLayer = currentLayer->
customProperty( QStringLiteral(
"WMSBackgroundLayer" ), false );
1930 QDomElement wmsBackgroundLayerElem = doc.createElement(
"WMSBackgroundLayer" );
1931 QDomText wmsBackgroundLayerText = doc.createTextNode( wmsBackgroundLayer.toBool() ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
1932 wmsBackgroundLayerElem.appendChild( wmsBackgroundLayerText );
1933 layerElem.appendChild( wmsBackgroundLayerElem );
1936 QVariant wmsPublishDataSourceUrl = currentLayer->
customProperty( QStringLiteral(
"WMSPublishDataSourceUrl" ),
false );
1937 if ( wmsPublishDataSourceUrl.toBool() )
1939 bool tiled = qobject_cast< const QgsRasterDataProvider * >( provider )
1940 ? !qobject_cast< const QgsRasterDataProvider * >( provider )->nativeResolutions().isEmpty()
1943 QDomElement dataSourceElem = doc.createElement( tiled ? QStringLiteral(
"WMTSDataSource" ) : QStringLiteral(
"WMSDataSource" ) );
1944 QDomText dataSourceUri = doc.createTextNode( provider->
dataSourceUri() );
1945 dataSourceElem.appendChild( dataSourceUri );
1946 layerElem.appendChild( dataSourceElem );
1950 QVariant wmsPrintLayer = currentLayer->
customProperty( QStringLiteral(
"WMSPrintLayer" ) );
1951 if ( wmsPrintLayer.isValid() )
1953 QDomElement wmsPrintLayerElem = doc.createElement(
"WMSPrintLayer" );
1954 QDomText wmsPrintLayerText = doc.createTextNode( wmsPrintLayer.toString() );
1955 wmsPrintLayerElem.appendChild( wmsPrintLayerText );
1956 layerElem.appendChild( wmsPrintLayerElem );
1962 if ( rasterRenderer )
1964 layerElem.setAttribute( QStringLiteral(
"opacity" ), QString::number( rasterRenderer->
opacity() ) );
1978 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent )
1982 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"KeywordList" ) );
1984 QDomElement keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1985 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"ISO" ) );
1986 QDomText keywordText = doc.createTextNode( QStringLiteral(
"infoMapAccessService" ) );
1987 keywordElem.appendChild( keywordText );
1988 keywordsElem.appendChild( keywordElem );
1989 parent.appendChild( keywordsElem );
1991 for (
const QString &keyword : qgis::as_const( keywords ) )
1993 if ( !keyword.isEmpty() )
1995 keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1996 keywordText = doc.createTextNode( keyword );
1997 keywordElem.appendChild( keywordText );
2000 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"SIA_Geo405" ) );
2002 keywordsElem.appendChild( keywordElem );
2005 parent.appendChild( keywordsElem );
2013 for (
int j = 0; j < childNode->
children().size(); ++j )
2023 const auto l { treeLayer->
layer() };
2030 QgsMessageLog::logMessage( QStringLiteral(
"Broken/corrupted layer tree, layer '%1' does not exist: check your project!" ).arg( treeLayer->
name() ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Warning );
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.
QgsRectangle bounds() const
Returns the approximate bounds for the region the CRS is usable within.
QString authid() const
Returns the authority identifier for the CRS.
bool hasAxisInverted() const
Returns whether axis is inverted (e.g., for WMS 1.3) for the CRS.
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
Fields is 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
Gets 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.
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 name() const override
Returns the layer's name.
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.
@ NodeLayer
Leaf node pointing to a layer.
bool isVisible() const
Returns whether a node is really visible (ie checked and all its ancestors checked as well)
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...
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
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 ...
QgsVectorLayer * coverageLayer() const
Returns the coverage layer used for the atlas features.
bool enabled() const
Returns whether the atlas generation is enabled.
A layout multiframe subclass for HTML content.
A layout item subclass for text labels.
Layout graphical items for displaying a map.
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, QgsUnitTypes::LayoutUnit unit) const
Converts a length measurement from the layout's native units to a specified target unit.
QStringList styles() const
Returns list of all defined style names.
Base class for all map layer types.
QString legendUrlFormat() const
Returns the format for a URL based layer legend.
virtual QgsRectangle extent() const
Returns the extent of the layer.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
QgsCoordinateReferenceSystem crs
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request.
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
QString metadataUrlFormat() const
Returns the metadata format of the layer used by QGIS Server in GetCapabilities request.
QString metadataUrl() const
Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request.
@ Identifiable
If the layer is identifiable using the identify map tool and as a WMS layer.
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
double minimumScale() const
Returns the minimum map scale (i.e.
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
QString legendUrl() const
Returns the URL for the layer's legend.
virtual Q_INVOKABLE QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be nullptr.
QString metadataUrlType() const
Returns the metadata type of the layer used by QGIS Server in GetCapabilities request.
double maximumScale() const
Returns the maximum map scale (i.e.
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::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).
void setYMinimum(double y) SIP_HOLDGIL
Set the minimum y value.
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
void setXMaximum(double x) SIP_HOLDGIL
Set the maximum x value.
void setXMinimum(double x) SIP_HOLDGIL
Set the minimum x value.
void grow(double delta)
Grows the rectangle in place by the specified amount.
void setYMaximum(double y) SIP_HOLDGIL
Set the maximum y value.
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.
void invert()
Swap x/y coordinates in the 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 QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
virtual QgsServerCacheManager * cacheManager() const =0
Gets the registered server cache filters.
virtual QString configFilePath()=0
Returns the configuration file path.
virtual QgsServerSettings * serverSettings()=0
Returns the server settings.
virtual QgsCapabilitiesCache * capabilitiesCache()=0
Gets pointer to the capabiblities cache.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
QMap< QString, QString > 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...
bool getPrintDisabled() const
Returns true if WMS GetPrint request is disabled and the project's reading flag QgsProject::ReadFlag:...
const QList< QgsVectorLayerServerProperties::WmsDimensionInfo > wmsDimensions() const
Returns the QGIS Server WMS Dimension list.
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 QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
QgsVectorLayerServerProperties * serverProperties() const
Returns QGIS Server Properties of the vector layer.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
QString displayExpression
QgsEditorWidgetSetup editorWidgetSetup(int index) const
The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field ...
long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
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(Type type) SIP_HOLDGIL
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
@ PointCloudLayer
Added in 3.18.
@ VectorTileLayer
Added in 3.14.
@ AnnotationLayer
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
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 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.
QDomDocument getCapabilities(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, bool projectSettings)
Creates the WMS GetCapabilities XML document.
QDomElement getWFSLayersElement(QDomDocument &doc, const QgsProject *project)
Create WFSLayers element for get capabilities document.
QDomElement getServiceElement(QDomDocument &doc, const QgsProject *project, const QString &version, const QgsServerRequest &request)
Create Service element for get capabilities document.
void writeGetCapabilities(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response, bool projectSettings)
Output GetCapabilities response.
QDomElement getInspireCapabilitiesElement(QDomDocument &doc, const QgsProject *project)
Create InspireCapabilities element for get capabilities document.
QDomElement getCapabilityElement(QDomDocument &doc, const QgsProject *project, const QString &version, const QgsServerRequest &request, bool projectSettings, QgsServerInterface *serverIface)
Create Capability element for get capabilities document.
QUrl serviceUrl(const QgsServerRequest &request, const QgsProject *project)
Returns WMS service URL.
QDomElement getComposerTemplatesElement(QDomDocument &doc, const QgsProject *project)
Create ComposerTemplates element for get capabilities document.
bool hasQueryableChildren(const QgsLayerTreeNode *childNode, const QStringList &wmsRestrictedLayers)
QDomElement getLayersAndStylesCapabilitiesElement(QDomDocument &doc, QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, bool projectSettings)
Create element for get capabilities document.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
CONSTLATIN1STRING geoEpsgCrsAuthId()
Geographic coord sys from EPSG authority.
QList< int > QgsAttributeList
const QgsCoordinateReferenceSystem & crs
Setting to define QGIS Server WMS Dimension.
@ MaxValue
Modify current selection to include only select features which match.
@ ReferenceValue
Remove from current selection.
@ MinValue
Add selection to current selection.