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;
144 if ( !capabilitiesDocument )
149 if ( !capabilitiesDocument )
151 capabilitiesDocument = &doc;
163 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
164 response.
write( capabilitiesDocument->toByteArray() );
169 bool projectSettings )
172 QDomElement wmsCapabilitiesElement;
178 QString hrefString = href.toString();
179 hrefString.append( href.hasQuery() ?
"&" :
"?" );
182 QDomProcessingInstruction xmlDeclaration = doc.createProcessingInstruction( QStringLiteral(
"xml" ),
183 QStringLiteral(
"version=\"1.0\" encoding=\"utf-8\"" ) );
186 std::function < void ( QDomElement &, const QString & ) > appendFormat = [&doc]( QDomElement & elem,
const QString & format )
188 QDomElement formatElem = doc.createElement( QStringLiteral(
"Format" ) );
189 formatElem.appendChild( doc.createTextNode( format ) );
190 elem.appendChild( formatElem );
193 if ( version == QLatin1String(
"1.1.1" ) )
195 doc = QDomDocument( QStringLiteral(
"WMT_MS_Capabilities SYSTEM 'http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd'" ) );
196 doc.appendChild( xmlDeclaration );
197 wmsCapabilitiesElement = doc.createElement( QStringLiteral(
"WMT_MS_Capabilities" ) );
201 doc.appendChild( xmlDeclaration );
202 wmsCapabilitiesElement = doc.createElement( QStringLiteral(
"WMS_Capabilities" ) );
203 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns" ), QStringLiteral(
"http://www.opengis.net/wms" ) );
204 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:sld" ), QStringLiteral(
"http://www.opengis.net/sld" ) );
205 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:qgs" ), QStringLiteral(
"http://www.qgis.org/wms" ) );
206 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
207 QString schemaLocation = QStringLiteral(
"http://www.opengis.net/wms" );
208 schemaLocation += QLatin1String(
" http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd" );
209 schemaLocation += QLatin1String(
" http://www.opengis.net/sld" );
210 schemaLocation += QLatin1String(
" http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd" );
214 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:inspire_common" ), QStringLiteral(
"http://inspire.ec.europa.eu/schemas/common/1.0" ) );
215 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:inspire_vs" ), QStringLiteral(
"http://inspire.ec.europa.eu/schemas/inspire_vs/1.0" ) );
216 schemaLocation += QLatin1String(
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0" );
217 schemaLocation += QLatin1String(
" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0/inspire_vs.xsd" );
220 schemaLocation += QLatin1String(
" http://www.qgis.org/wms" );
221 schemaLocation +=
" " + hrefString +
"SERVICE=WMS&REQUEST=GetSchemaExtension";
223 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"xsi:schemaLocation" ), schemaLocation );
225 wmsCapabilitiesElement.setAttribute( QStringLiteral(
"version" ), version );
226 doc.appendChild( wmsCapabilitiesElement );
229 wmsCapabilitiesElement.appendChild(
getServiceElement( doc, project, version, request ) );
232 QDomElement capabilityElement =
getCapabilityElement( doc, project, version, request, projectSettings );
233 wmsCapabilitiesElement.appendChild( capabilityElement );
235 if ( projectSettings )
244 capabilityElement.appendChild(
248 if ( projectSettings )
250 appendDrawingOrder( doc, capabilityElement, serverIface, project );
260 QDomElement serviceElem = doc.createElement( QStringLiteral(
"Service" ) );
263 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
264 QDomText nameText = doc.createTextNode( QStringLiteral(
"WMS" ) );
265 nameElem.appendChild( nameText );
266 serviceElem.appendChild( nameElem );
269 if ( !title.isEmpty() )
271 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
272 QDomText titleText = doc.createTextNode( title );
273 titleElem.appendChild( titleText );
274 serviceElem.appendChild( titleElem );
278 if ( !
abstract.isEmpty() )
280 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
281 QDomText abstractText = doc.createCDATASection(
abstract );
282 abstractElem.appendChild( abstractText );
283 serviceElem.appendChild( abstractElem );
286 addKeywordListElement( project, doc, serviceElem );
289 if ( onlineResource.isEmpty() )
291 onlineResource =
serviceUrl( request, project ).toString();
293 QDomElement onlineResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
294 onlineResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
295 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
296 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), onlineResource );
297 serviceElem.appendChild( onlineResourceElem );
304 if ( !contactPerson.isEmpty() ||
305 !contactOrganization.isEmpty() ||
306 !contactPosition.isEmpty() ||
307 !contactMail.isEmpty() ||
308 !contactPhone.isEmpty() )
311 QDomElement contactInfoElem = doc.createElement( QStringLiteral(
"ContactInformation" ) );
314 if ( !contactPerson.isEmpty() ||
315 !contactOrganization.isEmpty() ||
316 !contactPosition.isEmpty() )
318 QDomElement contactPersonPrimaryElem = doc.createElement( QStringLiteral(
"ContactPersonPrimary" ) );
320 if ( !contactPerson.isEmpty() )
322 QDomElement contactPersonElem = doc.createElement( QStringLiteral(
"ContactPerson" ) );
323 QDomText contactPersonText = doc.createTextNode( contactPerson );
324 contactPersonElem.appendChild( contactPersonText );
325 contactPersonPrimaryElem.appendChild( contactPersonElem );
328 if ( !contactOrganization.isEmpty() )
330 QDomElement contactOrganizationElem = doc.createElement( QStringLiteral(
"ContactOrganization" ) );
331 QDomText contactOrganizationText = doc.createTextNode( contactOrganization );
332 contactOrganizationElem.appendChild( contactOrganizationText );
333 contactPersonPrimaryElem.appendChild( contactOrganizationElem );
336 if ( !contactPosition.isEmpty() )
338 QDomElement contactPositionElem = doc.createElement( QStringLiteral(
"ContactPosition" ) );
339 QDomText contactPositionText = doc.createTextNode( contactPosition );
340 contactPositionElem.appendChild( contactPositionText );
341 contactPersonPrimaryElem.appendChild( contactPositionElem );
344 contactInfoElem.appendChild( contactPersonPrimaryElem );
347 if ( !contactPhone.isEmpty() )
349 QDomElement phoneElem = doc.createElement( QStringLiteral(
"ContactVoiceTelephone" ) );
350 QDomText phoneText = doc.createTextNode( contactPhone );
351 phoneElem.appendChild( phoneText );
352 contactInfoElem.appendChild( phoneElem );
355 if ( !contactMail.isEmpty() )
357 QDomElement mailElem = doc.createElement( QStringLiteral(
"ContactElectronicMailAddress" ) );
358 QDomText mailText = doc.createTextNode( contactMail );
359 mailElem.appendChild( mailText );
360 contactInfoElem.appendChild( mailElem );
363 serviceElem.appendChild( contactInfoElem );
366 QDomElement feesElem = doc.createElement( QStringLiteral(
"Fees" ) );
367 QDomText feesText = doc.createTextNode( QStringLiteral(
"None" ) );
369 if ( !fees.isEmpty() )
371 feesText = doc.createTextNode( fees );
373 feesElem.appendChild( feesText );
374 serviceElem.appendChild( feesElem );
376 QDomElement accessConstraintsElem = doc.createElement( QStringLiteral(
"AccessConstraints" ) );
377 QDomText accessConstraintsText = doc.createTextNode( QStringLiteral(
"None" ) );
379 if ( !accessConstraints.isEmpty() )
381 accessConstraintsText = doc.createTextNode( accessConstraints );
383 accessConstraintsElem.appendChild( accessConstraintsText );
384 serviceElem.appendChild( accessConstraintsElem );
386 if ( version == QLatin1String(
"1.3.0" ) )
391 QDomElement maxWidthElem = doc.createElement( QStringLiteral(
"MaxWidth" ) );
392 QDomText maxWidthText = doc.createTextNode( QString::number( maxWidth ) );
393 maxWidthElem.appendChild( maxWidthText );
394 serviceElem.appendChild( maxWidthElem );
400 QDomElement maxHeightElem = doc.createElement( QStringLiteral(
"MaxHeight" ) );
401 QDomText maxHeightText = doc.createTextNode( QString::number( maxHeight ) );
402 maxHeightElem.appendChild( maxHeightText );
403 serviceElem.appendChild( maxHeightElem );
412 bool projectSettings )
420 QString hrefString = href.toString();
421 hrefString.append( href.hasQuery() ?
"&" :
"?" );
423 QDomElement capabilityElem = doc.createElement( QStringLiteral(
"Capability" ) );
426 QDomElement requestElem = doc.createElement( QStringLiteral(
"Request" ) );
427 capabilityElem.appendChild( requestElem );
429 QDomElement dcpTypeElem = doc.createElement( QStringLiteral(
"DCPType" ) );
430 QDomElement httpElem = doc.createElement( QStringLiteral(
"HTTP" ) );
431 dcpTypeElem.appendChild( httpElem );
434 std::function < void ( QDomElement &, const QString & ) > appendFormat = [&doc]( QDomElement & elem,
const QString & format )
436 QDomElement formatElem = doc.createElement( QStringLiteral(
"Format" ) );
437 formatElem.appendChild( doc.createTextNode( format ) );
438 elem.appendChild( formatElem );
444 elem = doc.createElement( QStringLiteral(
"GetCapabilities" ) );
445 appendFormat( elem, ( version == QLatin1String(
"1.1.1" ) ?
"application/vnd.ogc.wms_xml" :
"text/xml" ) );
446 elem.appendChild( dcpTypeElem );
447 requestElem.appendChild( elem );
452 if ( parameters.value( QStringLiteral(
"SERVICE" ) ).compare( QLatin1String(
"WMS" ), Qt::CaseInsensitive ) != 0 )
454 QDomElement soapElem = doc.createElement( QStringLiteral(
"SOAP" ) );
455 httpElem.appendChild( soapElem );
456 QDomElement soapResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
457 soapResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
458 soapResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
459 soapResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), hrefString );
460 soapElem.appendChild( soapResourceElem );
464 QDomElement getElem = doc.createElement( QStringLiteral(
"Get" ) );
465 httpElem.appendChild( getElem );
466 QDomElement olResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
467 olResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
468 olResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
469 olResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), hrefString );
470 getElem.appendChild( olResourceElem );
473 elem = doc.createElement( QStringLiteral(
"GetMap" ) );
474 appendFormat( elem, QStringLiteral(
"image/jpeg" ) );
475 appendFormat( elem, QStringLiteral(
"image/png" ) );
476 appendFormat( elem, QStringLiteral(
"image/png; mode=16bit" ) );
477 appendFormat( elem, QStringLiteral(
"image/png; mode=8bit" ) );
478 appendFormat( elem, QStringLiteral(
"image/png; mode=1bit" ) );
479 appendFormat( elem, QStringLiteral(
"application/dxf" ) );
480 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
481 requestElem.appendChild( elem );
484 elem = doc.createElement( QStringLiteral(
"GetFeatureInfo" ) );
485 appendFormat( elem, QStringLiteral(
"text/plain" ) );
486 appendFormat( elem, QStringLiteral(
"text/html" ) );
487 appendFormat( elem, QStringLiteral(
"text/xml" ) );
488 appendFormat( elem, QStringLiteral(
"application/vnd.ogc.gml" ) );
489 appendFormat( elem, QStringLiteral(
"application/vnd.ogc.gml/3.1.1" ) );
490 appendFormat( elem, QStringLiteral(
"application/json" ) );
491 appendFormat( elem, QStringLiteral(
"application/geo+json" ) );
492 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
493 requestElem.appendChild( elem );
496 elem = doc.createElement( ( version == QLatin1String(
"1.1.1" ) ?
"GetLegendGraphic" :
"sld:GetLegendGraphic" ) );
497 appendFormat( elem, QStringLiteral(
"image/jpeg" ) );
498 appendFormat( elem, QStringLiteral(
"image/png" ) );
499 appendFormat( elem, QStringLiteral(
"application/json" ) );
500 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
501 requestElem.appendChild( elem );
504 elem = doc.createElement( ( version == QLatin1String(
"1.1.1" ) ?
"DescribeLayer" :
"sld:DescribeLayer" ) );
505 appendFormat( elem, QStringLiteral(
"text/xml" ) );
506 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
507 requestElem.appendChild( elem );
510 elem = doc.createElement( ( version == QLatin1String(
"1.1.1" ) ?
"GetStyles" :
"qgs:GetStyles" ) );
511 appendFormat( elem, QStringLiteral(
"text/xml" ) );
512 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
513 requestElem.appendChild( elem );
515 if ( projectSettings )
518 elem = doc.createElement( QStringLiteral(
"GetPrint" ) );
519 appendFormat( elem, QStringLiteral(
"svg" ) );
520 appendFormat( elem, QStringLiteral(
"png" ) );
521 appendFormat( elem, QStringLiteral(
"pdf" ) );
522 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
523 requestElem.appendChild( elem );
527 elem = doc.createElement( QStringLiteral(
"Exception" ) );
528 appendFormat( elem, ( version == QLatin1String(
"1.1.1" ) ?
"application/vnd.ogc.se_xml" :
"XML" ) );
529 capabilityElem.appendChild( elem );
532 if ( version == QLatin1String(
"1.3.0" ) )
534 elem = doc.createElement( QStringLiteral(
"sld:UserDefinedSymbolization" ) );
535 elem.setAttribute( QStringLiteral(
"SupportSLD" ), QStringLiteral(
"1" ) );
536 elem.setAttribute( QStringLiteral(
"UserLayer" ), QStringLiteral(
"0" ) );
537 elem.setAttribute( QStringLiteral(
"UserStyle" ), QStringLiteral(
"1" ) );
538 elem.setAttribute( QStringLiteral(
"RemoteWFS" ), QStringLiteral(
"0" ) );
539 elem.setAttribute( QStringLiteral(
"InlineFeature" ), QStringLiteral(
"0" ) );
540 elem.setAttribute( QStringLiteral(
"RemoteWCS" ), QStringLiteral(
"0" ) );
541 capabilityElem.appendChild( elem );
549 return capabilityElem;
554 QDomElement inspireCapabilitiesElem;
557 return inspireCapabilitiesElem;
559 inspireCapabilitiesElem = doc.createElement( QStringLiteral(
"inspire_vs:ExtendedCapabilities" ) );
563 if ( !inspireMetadataUrl.isEmpty() )
565 QDomElement inspireCommonMetadataUrlElem = doc.createElement( QStringLiteral(
"inspire_common:MetadataUrl" ) );
566 inspireCommonMetadataUrlElem.setAttribute( QStringLiteral(
"xsi:type" ), QStringLiteral(
"inspire_common:resourceLocatorType" ) );
568 QDomElement inspireCommonMetadataUrlUrlElem = doc.createElement( QStringLiteral(
"inspire_common:URL" ) );
569 inspireCommonMetadataUrlUrlElem.appendChild( doc.createTextNode( inspireMetadataUrl ) );
570 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlUrlElem );
573 if ( !inspireMetadataUrlType.isNull() )
575 QDomElement inspireCommonMetadataUrlMediaTypeElem = doc.createElement( QStringLiteral(
"inspire_common:MediaType" ) );
576 inspireCommonMetadataUrlMediaTypeElem.appendChild( doc.createTextNode( inspireMetadataUrlType ) );
577 inspireCommonMetadataUrlElem.appendChild( inspireCommonMetadataUrlMediaTypeElem );
580 inspireCapabilitiesElem.appendChild( inspireCommonMetadataUrlElem );
584 QDomElement inspireCommonResourceTypeElem = doc.createElement( QStringLiteral(
"inspire_common:ResourceType" ) );
585 inspireCommonResourceTypeElem.appendChild( doc.createTextNode( QStringLiteral(
"service" ) ) );
586 inspireCapabilitiesElem.appendChild( inspireCommonResourceTypeElem );
588 QDomElement inspireCommonSpatialDataServiceTypeElem = doc.createElement( QStringLiteral(
"inspire_common:SpatialDataServiceType" ) );
589 inspireCommonSpatialDataServiceTypeElem.appendChild( doc.createTextNode( QStringLiteral(
"view" ) ) );
590 inspireCapabilitiesElem.appendChild( inspireCommonSpatialDataServiceTypeElem );
593 if ( !inspireTemporalReference.isNull() )
595 QDomElement inspireCommonTemporalReferenceElem = doc.createElement( QStringLiteral(
"inspire_common:TemporalReference" ) );
596 QDomElement inspireCommonDateOfLastRevisionElem = doc.createElement( QStringLiteral(
"inspire_common:DateOfLastRevision" ) );
597 inspireCommonDateOfLastRevisionElem.appendChild( doc.createTextNode( inspireTemporalReference ) );
598 inspireCommonTemporalReferenceElem.appendChild( inspireCommonDateOfLastRevisionElem );
599 inspireCapabilitiesElem.appendChild( inspireCommonTemporalReferenceElem );
602 QDomElement inspireCommonMetadataPointOfContactElem = doc.createElement( QStringLiteral(
"inspire_common:MetadataPointOfContact" ) );
605 QDomElement inspireCommonOrganisationNameElem = doc.createElement( QStringLiteral(
"inspire_common:OrganisationName" ) );
606 if ( !contactOrganization.isNull() )
608 inspireCommonOrganisationNameElem.appendChild( doc.createTextNode( contactOrganization ) );
610 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonOrganisationNameElem );
613 QDomElement inspireCommonEmailAddressElem = doc.createElement( QStringLiteral(
"inspire_common:EmailAddress" ) );
614 if ( !contactMail.isNull() )
616 inspireCommonEmailAddressElem.appendChild( doc.createTextNode( contactMail ) );
618 inspireCommonMetadataPointOfContactElem.appendChild( inspireCommonEmailAddressElem );
620 inspireCapabilitiesElem.appendChild( inspireCommonMetadataPointOfContactElem );
623 if ( !inspireMetadataDate.isNull() )
625 QDomElement inspireCommonMetadataDateElem = doc.createElement( QStringLiteral(
"inspire_common:MetadataDate" ) );
626 inspireCommonMetadataDateElem.appendChild( doc.createTextNode( inspireMetadataDate ) );
627 inspireCapabilitiesElem.appendChild( inspireCommonMetadataDateElem );
632 QDomElement inspireCommonSupportedLanguagesElem = doc.createElement( QStringLiteral(
"inspire_common:SupportedLanguages" ) );
633 inspireCommonSupportedLanguagesElem.setAttribute( QStringLiteral(
"xsi:type" ), QStringLiteral(
"inspire_common:supportedLanguagesType" ) );
635 QDomElement inspireCommonLanguageElem = doc.createElement( QStringLiteral(
"inspire_common:Language" ) );
638 QDomElement inspireCommonDefaultLanguageElem = doc.createElement( QStringLiteral(
"inspire_common:DefaultLanguage" ) );
639 inspireCommonDefaultLanguageElem.appendChild( inspireCommonLanguageElem );
640 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonDefaultLanguageElem );
644 QDomElement inspireCommonSupportedLanguageElem = doc.createElement(
"inspire_common:SupportedLanguage" );
645 inspireCommonSupportedLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
646 inspireCommonSupportedLanguagesElem.appendChild( inspireCommonSupportedLanguageElem );
649 inspireCapabilitiesElem.appendChild( inspireCommonSupportedLanguagesElem );
651 QDomElement inspireCommonResponseLanguageElem = doc.createElement( QStringLiteral(
"inspire_common:ResponseLanguage" ) );
652 inspireCommonResponseLanguageElem.appendChild( inspireCommonLanguageElem.cloneNode().toElement() );
653 inspireCapabilitiesElem.appendChild( inspireCommonResponseLanguageElem );
655 return inspireCapabilitiesElem;
661 if ( projectComposers.size() == 0 )
662 return QDomElement();
666 QDomElement composerTemplatesElem = doc.createElement( QStringLiteral(
"ComposerTemplates" ) );
667 QList<QgsPrintLayout *>::const_iterator cIt = projectComposers.constBegin();
668 for ( ; cIt != projectComposers.constEnd(); ++cIt )
671 if ( restrictedComposers.contains( layout->
name() ) )
683 QDomElement composerTemplateElem = doc.createElement( QStringLiteral(
"ComposerTemplate" ) );
684 composerTemplateElem.setAttribute( QStringLiteral(
"name" ), layout->
name() );
687 composerTemplateElem.setAttribute( QStringLiteral(
"width" ), width.length() );
688 composerTemplateElem.setAttribute( QStringLiteral(
"height" ), height.
length() );
692 if ( atlas && atlas->
enabled() )
694 composerTemplateElem.setAttribute( QStringLiteral(
"atlasEnabled" ), QStringLiteral(
"1" ) );
701 layerName = cLayer->
id();
703 else if ( layerName.isEmpty() )
705 layerName = cLayer->
name();
707 composerTemplateElem.setAttribute( QStringLiteral(
"atlasCoverageLayer" ), layerName );
712 QList<QgsLayoutItemMap *> layoutMapList;
714 QList<QgsLayoutItemMap *>::const_iterator cmIt = layoutMapList.constBegin();
717 for ( ; cmIt != layoutMapList.constEnd(); ++cmIt )
721 QDomElement composerMapElem = doc.createElement( QStringLiteral(
"ComposerMap" ) );
722 composerMapElem.setAttribute( QStringLiteral(
"name" ), QStringLiteral(
"map%1" ).arg( mapId ) );
724 composerMapElem.setAttribute( QStringLiteral(
"width" ), composerMap->rect().width() );
725 composerMapElem.setAttribute( QStringLiteral(
"height" ), composerMap->rect().height() );
726 composerTemplateElem.appendChild( composerMapElem );
730 QList<QgsLayoutItemLabel *> composerLabelList;
732 QList<QgsLayoutItemLabel *>::const_iterator clIt = composerLabelList.constBegin();
733 for ( ; clIt != composerLabelList.constEnd(); ++clIt )
736 QString
id = composerLabel->
id();
740 QDomElement composerLabelElem = doc.createElement( QStringLiteral(
"ComposerLabel" ) );
741 composerLabelElem.setAttribute( QStringLiteral(
"name" ),
id );
742 composerTemplateElem.appendChild( composerLabelElem );
746 QList<QgsLayoutItemHtml *> composerHtmlList;
748 QList<QgsLayoutItemHtml *>::const_iterator chIt = composerHtmlList.constBegin();
749 for ( ; chIt != composerHtmlList.constEnd(); ++chIt )
755 QString
id = composerHtml->
frame( 0 )->
id();
759 QDomElement composerHtmlElem = doc.createElement( QStringLiteral(
"ComposerHtml" ) );
760 composerHtmlElem.setAttribute( QStringLiteral(
"name" ),
id );
761 composerTemplateElem.appendChild( composerHtmlElem );
764 composerTemplatesElem.appendChild( composerTemplateElem );
767 if ( composerTemplatesElem.childNodes().size() == 0 )
768 return QDomElement();
770 return composerTemplatesElem;
776 if ( wfsLayerIds.size() == 0 )
777 return QDomElement();
779 QDomElement wfsLayersElem = doc.createElement( QStringLiteral(
"WFSLayers" ) );
780 for (
int i = 0; i < wfsLayerIds.size(); ++i )
788 QDomElement wfsLayerElem = doc.createElement( QStringLiteral(
"WFSLayer" ) );
791 wfsLayerElem.setAttribute( QStringLiteral(
"name" ), layer->
id() );
795 wfsLayerElem.setAttribute( QStringLiteral(
"name" ), layer->
name() );
797 wfsLayersElem.appendChild( wfsLayerElem );
800 return wfsLayersElem;
804 const QgsProject *project,
const QString &version,
809 QDomElement layerParentElem = doc.createElement( QStringLiteral(
"Layer" ) );
811 if ( !project->
title().isEmpty() )
814 QDomElement layerParentTitleElem = doc.createElement( QStringLiteral(
"Title" ) );
815 QDomText layerParentTitleText = doc.createTextNode( project->
title() );
816 layerParentTitleElem.appendChild( layerParentTitleText );
817 layerParentElem.appendChild( layerParentTitleElem );
820 QDomElement layerParentAbstElem = doc.createElement( QStringLiteral(
"Abstract" ) );
821 QDomText layerParentAbstText = doc.createTextNode( project->
title() );
822 layerParentAbstElem.appendChild( layerParentAbstText );
823 layerParentElem.appendChild( layerParentAbstElem );
828 if ( rootLayerName.isEmpty() && !project->
title().isEmpty() )
830 rootLayerName = project->
title();
833 if ( !rootLayerName.isEmpty() )
835 QDomElement layerParentNameElem = doc.createElement( QStringLiteral(
"Name" ) );
836 QDomText layerParentNameText = doc.createTextNode( rootLayerName );
837 layerParentNameElem.appendChild( layerParentNameText );
838 layerParentElem.appendChild( layerParentNameElem );
842 addKeywordListElement( project, doc, layerParentElem );
845 if ( projectSettings )
847 QDomElement treeNameElem = doc.createElement( QStringLiteral(
"TreeName" ) );
848 QDomText treeNameText = doc.createTextNode( project->
title() );
849 treeNameElem.appendChild( treeNameText );
850 layerParentElem.appendChild( treeNameElem );
855 layerParentElem.setAttribute( QStringLiteral(
"queryable" ), QStringLiteral(
"1" ) );
859 layerParentElem.setAttribute( QStringLiteral(
"queryable" ), QStringLiteral(
"0" ) );
862 appendLayersFromTreeGroup( doc, layerParentElem, serverIface, project, version, request, projectLayerTreeRoot, projectSettings );
864 combineExtentAndCrsOfGroupChildren( doc, layerParentElem, project,
true );
866 return layerParentElem;
872 void appendLayersFromTreeGroup( QDomDocument &doc,
873 QDomElement &parentLayer,
876 const QString &version,
879 bool projectSettings )
885 QList< QgsLayerTreeNode * > layerTreeGroupChildren = layerTreeGroup->
children();
886 for (
int i = 0; i < layerTreeGroupChildren.size(); ++i )
889 QDomElement layerElem = doc.createElement( QStringLiteral(
"Layer" ) );
891 if ( projectSettings )
893 layerElem.setAttribute( QStringLiteral(
"visible" ), treeNode->
isVisible() );
900 QString name = treeGroupChild->
name();
901 if ( restrictedLayers.contains( name ) )
906 if ( projectSettings )
908 layerElem.setAttribute( QStringLiteral(
"mutuallyExclusive" ), treeGroupChild->
isMutuallyExclusive() );
911 QString shortName = treeGroupChild->
customProperty( QStringLiteral(
"wmsShortName" ) ).toString();
912 QString title = treeGroupChild->
customProperty( QStringLiteral(
"wmsTitle" ) ).toString();
914 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
916 if ( !shortName.isEmpty() )
917 nameText = doc.createTextNode( shortName );
919 nameText = doc.createTextNode( name );
920 nameElem.appendChild( nameText );
921 layerElem.appendChild( nameElem );
923 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
925 if ( !title.isEmpty() )
926 titleText = doc.createTextNode( title );
928 titleText = doc.createTextNode( name );
929 titleElem.appendChild( titleText );
930 layerElem.appendChild( titleElem );
932 QString
abstract = treeGroupChild->
customProperty( QStringLiteral(
"wmsAbstract" ) ).toString();
933 if ( !
abstract.isEmpty() )
935 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
936 QDomText abstractText = doc.createTextNode(
abstract );
937 abstractElem.appendChild( abstractText );
938 layerElem.appendChild( abstractElem );
942 if ( projectSettings )
944 QDomElement treeNameElem = doc.createElement( QStringLiteral(
"TreeName" ) );
945 QDomText treeNameText = doc.createTextNode( name );
946 treeNameElem.appendChild( treeNameText );
947 layerElem.appendChild( treeNameElem );
953 layerElem.setAttribute( QStringLiteral(
"queryable" ), QStringLiteral(
"1" ) );
957 layerElem.setAttribute( QStringLiteral(
"queryable" ), QStringLiteral(
"0" ) );
960 appendLayersFromTreeGroup( doc, layerElem, serverIface, project, version, request, treeGroupChild, projectSettings );
962 combineExtentAndCrsOfGroupChildren( doc, layerElem, project );
968 if ( restrictedLayers.contains( l->
name() ) )
973 #ifdef HAVE_SERVER_PYTHON_PLUGINS 980 QString wmsName = l->
name();
993 layerElem.setAttribute( QStringLiteral(
"queryable" ), QStringLiteral(
"0" ) );
997 layerElem.setAttribute( QStringLiteral(
"queryable" ), QStringLiteral(
"1" ) );
1000 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
1001 QDomText nameText = doc.createTextNode( wmsName );
1002 nameElem.appendChild( nameText );
1003 layerElem.appendChild( nameElem );
1005 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
1006 QString title = l->
title();
1007 if ( title.isEmpty() )
1011 QDomText titleText = doc.createTextNode( title );
1012 titleElem.appendChild( titleText );
1013 layerElem.appendChild( titleElem );
1016 if ( !
abstract.isEmpty() )
1018 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
1019 QDomText abstractText = doc.createTextNode(
abstract );
1020 abstractElem.appendChild( abstractText );
1021 layerElem.appendChild( abstractElem );
1027 QStringList keywordStringList = l->
keywordList().split(
',' );
1029 QDomElement keywordListElem = doc.createElement( QStringLiteral(
"KeywordList" ) );
1030 for (
int i = 0; i < keywordStringList.size(); ++i )
1032 QDomElement keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1033 QDomText keywordText = doc.createTextNode( keywordStringList.at( i ).trimmed() );
1034 keywordElem.appendChild( keywordText );
1037 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"SIA_Geo405" ) );
1039 keywordListElem.appendChild( keywordElem );
1041 layerElem.appendChild( keywordListElem );
1045 bool geometryLayer =
true;
1053 geometryLayer =
false;
1059 if ( geometryLayer )
1061 QStringList crsList;
1064 appendCrsElementsToLayer( doc, layerElem, crsList, outputCrsList );
1082 else if ( vl->
crs() != project->
crs() )
1087 extent = ct.transform( extent );
1091 QgsMessageLog::logMessage( QStringLiteral(
"Error transforming extent for layer %1: %2" ).arg( vl->
name() ).arg( cse.
what() ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Warning );
1098 appendLayerBoundingBoxes( doc, layerElem, extent, l->
crs(), crsList, outputCrsList, project );
1102 appendLayerStyles( doc, layerElem, l, project, version, request );
1107 if ( version == QLatin1String(
"1.1.1" ) )
1110 double SCALE_TO_SCALEHINT = OGC_PX_M * M_SQRT2;
1112 QDomElement scaleHintElem = doc.createElement( QStringLiteral(
"ScaleHint" ) );
1113 scaleHintElem.setAttribute( QStringLiteral(
"min" ), QString::number( l->
maximumScale() * SCALE_TO_SCALEHINT ) );
1114 scaleHintElem.setAttribute( QStringLiteral(
"max" ), QString::number( l->
minimumScale() * SCALE_TO_SCALEHINT ) );
1115 layerElem.appendChild( scaleHintElem );
1119 QString minScaleString = QString::number( l->
maximumScale() );
1120 QDomElement minScaleElem = doc.createElement( QStringLiteral(
"MinScaleDenominator" ) );
1121 QDomText minScaleText = doc.createTextNode( minScaleString );
1122 minScaleElem.appendChild( minScaleText );
1123 layerElem.appendChild( minScaleElem );
1125 QString maxScaleString = QString::number( l->
minimumScale() );
1126 QDomElement maxScaleElem = doc.createElement( QStringLiteral(
"MaxScaleDenominator" ) );
1127 QDomText maxScaleText = doc.createTextNode( maxScaleString );
1128 maxScaleElem.appendChild( maxScaleText );
1129 layerElem.appendChild( maxScaleElem );
1134 QString dataUrl = l->
dataUrl();
1135 if ( !dataUrl.isEmpty() )
1137 QDomElement dataUrlElem = doc.createElement( QStringLiteral(
"DataURL" ) );
1138 QDomElement dataUrlFormatElem = doc.createElement( QStringLiteral(
"Format" ) );
1140 QDomText dataUrlFormatText = doc.createTextNode( dataUrlFormat );
1141 dataUrlFormatElem.appendChild( dataUrlFormatText );
1142 dataUrlElem.appendChild( dataUrlFormatElem );
1143 QDomElement dataORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1144 dataORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1145 dataORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1146 dataORElem.setAttribute( QStringLiteral(
"xlink:href" ), dataUrl );
1147 dataUrlElem.appendChild( dataORElem );
1148 layerElem.appendChild( dataUrlElem );
1153 if ( !attribution.isEmpty() )
1155 QDomElement attribElem = doc.createElement( QStringLiteral(
"Attribution" ) );
1156 QDomElement attribTitleElem = doc.createElement( QStringLiteral(
"Title" ) );
1157 QDomText attribText = doc.createTextNode( attribution );
1158 attribTitleElem.appendChild( attribText );
1159 attribElem.appendChild( attribTitleElem );
1161 if ( !attributionUrl.isEmpty() )
1163 QDomElement attribORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1164 attribORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1165 attribORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1166 attribORElem.setAttribute( QStringLiteral(
"xlink:href" ), attributionUrl );
1167 attribElem.appendChild( attribORElem );
1169 layerElem.appendChild( attribElem );
1174 if ( !metadataUrl.isEmpty() )
1176 QDomElement metaUrlElem = doc.createElement( QStringLiteral(
"MetadataURL" ) );
1178 if ( version == QLatin1String(
"1.1.1" ) )
1180 metaUrlElem.setAttribute( QStringLiteral(
"type" ), metadataUrlType );
1182 else if ( metadataUrlType == QLatin1String(
"FGDC" ) )
1184 metaUrlElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"FGDC:1998" ) );
1186 else if ( metadataUrlType == QLatin1String(
"TC211" ) )
1188 metaUrlElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"ISO19115:2003" ) );
1192 metaUrlElem.setAttribute( QStringLiteral(
"type" ), metadataUrlType );
1195 if ( !metadataUrlFormat.isEmpty() )
1197 QDomElement metaUrlFormatElem = doc.createElement( QStringLiteral(
"Format" ) );
1198 QDomText metaUrlFormatText = doc.createTextNode( metadataUrlFormat );
1199 metaUrlFormatElem.appendChild( metaUrlFormatText );
1200 metaUrlElem.appendChild( metaUrlFormatElem );
1202 QDomElement metaUrlORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1203 metaUrlORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1204 metaUrlORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1205 metaUrlORElem.setAttribute( QStringLiteral(
"xlink:href" ), metadataUrl );
1206 metaUrlElem.appendChild( metaUrlORElem );
1207 layerElem.appendChild( metaUrlElem );
1219 if ( fieldIndex == -1 )
1224 QSet<QVariant> uniqueValues = vl->
uniqueValues( fieldIndex );
1227 if ( !dim.endFieldName.isEmpty() )
1229 int endFieldIndex = vl->
fields().
indexOf( dim.endFieldName );
1231 if ( endFieldIndex == -1 )
1235 uniqueValues.unite( vl->
uniqueValues( endFieldIndex ) );
1238 QList<QVariant> values = uniqueValues.toList();
1239 std::sort( values.begin(), values.end() );
1241 QDomElement dimElem = doc.createElement( QStringLiteral(
"Dimension" ) );
1242 dimElem.setAttribute( QStringLiteral(
"name" ), dim.name );
1243 if ( !dim.units.isEmpty() )
1245 dimElem.setAttribute( QStringLiteral(
"units" ), dim.units );
1247 if ( !dim.unitSymbol.isEmpty() )
1249 dimElem.setAttribute( QStringLiteral(
"unitSymbol" ), dim.unitSymbol );
1253 dimElem.setAttribute( QStringLiteral(
"default" ), values.first().toString() );
1257 dimElem.setAttribute( QStringLiteral(
"default" ), values.last().toString() );
1261 dimElem.setAttribute( QStringLiteral(
"default" ), dim.referenceValue.toString() );
1263 dimElem.setAttribute( QStringLiteral(
"multipleValue" ),
'1' );
1264 dimElem.setAttribute( QStringLiteral(
"nearestValue" ),
'0' );
1266 QStringList strValues;
1267 for (
const QVariant &v : values )
1269 strValues << v.toString();
1271 QDomText dimValuesText = doc.createTextNode( strValues.join( QStringLiteral(
", " ) ) );
1272 dimElem.appendChild( dimValuesText );
1273 layerElem.appendChild( dimElem );
1277 if ( projectSettings )
1279 appendLayerProjectSettings( doc, layerElem, l );
1283 parentLayer.appendChild( layerElem );
1287 void appendLayerStyles( QDomDocument &doc, QDomElement &layerElem,
QgsMapLayer *currentLayer,
1294 QString hrefString = href.toString();
1295 hrefString.append( href.hasQuery() ?
"&" :
"?" );
1298 QDomElement styleElem = doc.createElement( QStringLiteral(
"Style" ) );
1299 QDomElement styleNameElem = doc.createElement( QStringLiteral(
"Name" ) );
1300 QDomText styleNameText = doc.createTextNode( styleName );
1301 styleNameElem.appendChild( styleNameText );
1302 QDomElement styleTitleElem = doc.createElement( QStringLiteral(
"Title" ) );
1303 QDomText styleTitleText = doc.createTextNode( styleName );
1304 styleTitleElem.appendChild( styleTitleText );
1305 styleElem.appendChild( styleNameElem );
1306 styleElem.appendChild( styleTitleElem );
1309 QDomElement getLayerLegendGraphicElem = doc.createElement( QStringLiteral(
"LegendURL" ) );
1311 QString customHrefString = currentLayer->
legendUrl();
1313 QStringList getLayerLegendGraphicFormats;
1314 if ( !customHrefString.isEmpty() )
1320 getLayerLegendGraphicFormats << QStringLiteral(
"image/png" );
1323 for (
int i = 0; i < getLayerLegendGraphicFormats.size(); ++i )
1325 QDomElement getLayerLegendGraphicFormatElem = doc.createElement( QStringLiteral(
"Format" ) );
1326 QString getLayerLegendGraphicFormat = getLayerLegendGraphicFormats[i];
1327 QDomText getLayerLegendGraphicFormatText = doc.createTextNode( getLayerLegendGraphicFormat );
1328 getLayerLegendGraphicFormatElem.appendChild( getLayerLegendGraphicFormatText );
1329 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicFormatElem );
1333 if ( customHrefString.isEmpty() )
1335 QString layerName = currentLayer->
name();
1337 layerName = currentLayer->
id();
1338 else if ( !currentLayer->
shortName().isEmpty() )
1340 QUrlQuery mapUrl( hrefString );
1341 mapUrl.addQueryItem( QStringLiteral(
"SERVICE" ), QStringLiteral(
"WMS" ) );
1342 mapUrl.addQueryItem( QStringLiteral(
"VERSION" ), version );
1343 mapUrl.addQueryItem( QStringLiteral(
"REQUEST" ), QStringLiteral(
"GetLegendGraphic" ) );
1344 mapUrl.addQueryItem( QStringLiteral(
"LAYER" ), layerName );
1345 mapUrl.addQueryItem( QStringLiteral(
"FORMAT" ), QStringLiteral(
"image/png" ) );
1346 mapUrl.addQueryItem( QStringLiteral(
"STYLE" ), styleNameText.data() );
1347 if ( version == QLatin1String(
"1.3.0" ) )
1349 mapUrl.addQueryItem( QStringLiteral(
"SLD_VERSION" ), QStringLiteral(
"1.1.0" ) );
1351 customHrefString = mapUrl.toString();
1354 QDomElement getLayerLegendGraphicORElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
1355 getLayerLegendGraphicORElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1356 getLayerLegendGraphicORElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
1357 getLayerLegendGraphicORElem.setAttribute( QStringLiteral(
"xlink:href" ), customHrefString );
1358 getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicORElem );
1359 styleElem.appendChild( getLayerLegendGraphicElem );
1361 layerElem.appendChild( styleElem );
1365 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
1366 const QStringList &crsList,
const QStringList &constrainedCrsList )
1368 if ( layerElement.isNull() )
1374 QDomElement titleElement = layerElement.firstChildElement( QStringLiteral(
"Title" ) );
1375 QDomElement abstractElement = layerElement.firstChildElement( QStringLiteral(
"Abstract" ) );
1376 QDomElement CRSPrecedingElement = abstractElement.isNull() ? titleElement : abstractElement;
1378 if ( CRSPrecedingElement.isNull() )
1381 const QDomElement keyElement = layerElement.firstChildElement( QStringLiteral(
"KeywordList" ) );
1382 CRSPrecedingElement = keyElement;
1386 if ( !constrainedCrsList.isEmpty() )
1388 for (
int i = constrainedCrsList.size() - 1; i >= 0; --i )
1390 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, constrainedCrsList.at( i ) );
1395 for (
const QString &
crs : crsList )
1397 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement,
crs );
1402 appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, QString(
"CRS:84" ) );
1405 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
1406 const QString &crsText )
1408 if ( crsText.isEmpty() )
1410 QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1411 QDomElement crsElement = doc.createElement( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS" );
1412 QDomText crsTextNode = doc.createTextNode( crsText );
1413 crsElement.appendChild( crsTextNode );
1414 layerElement.insertAfter( crsElement, precedingElement );
1417 void appendLayerBoundingBoxes( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &lExtent,
1419 const QStringList &constrainedCrsList,
const QgsProject *project )
1421 if ( layerElem.isNull() )
1430 layerExtent.
grow( 0.000001 );
1434 int wgs84precision = 6;
1436 QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1439 QDomElement ExGeoBBoxElement;
1442 if ( !layerExtent.
isNull() )
1451 QgsMessageLog::logMessage( QStringLiteral(
"Error transforming extent: %1" ).arg( cse.
what() ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Warning );
1456 if ( version == QLatin1String(
"1.1.1" ) )
1458 ExGeoBBoxElement = doc.createElement( QStringLiteral(
"LatLonBoundingBox" ) );
1466 ExGeoBBoxElement = doc.createElement( QStringLiteral(
"EX_GeographicBoundingBox" ) );
1467 QDomElement wBoundLongitudeElement = doc.createElement( QStringLiteral(
"westBoundLongitude" ) );
1469 wBoundLongitudeElement.appendChild( wBoundLongitudeText );
1470 ExGeoBBoxElement.appendChild( wBoundLongitudeElement );
1471 QDomElement eBoundLongitudeElement = doc.createElement( QStringLiteral(
"eastBoundLongitude" ) );
1473 eBoundLongitudeElement.appendChild( eBoundLongitudeText );
1474 ExGeoBBoxElement.appendChild( eBoundLongitudeElement );
1475 QDomElement sBoundLatitudeElement = doc.createElement( QStringLiteral(
"southBoundLatitude" ) );
1477 sBoundLatitudeElement.appendChild( sBoundLatitudeText );
1478 ExGeoBBoxElement.appendChild( sBoundLatitudeElement );
1479 QDomElement nBoundLatitudeElement = doc.createElement( QStringLiteral(
"northBoundLatitude" ) );
1481 nBoundLatitudeElement.appendChild( nBoundLatitudeText );
1482 ExGeoBBoxElement.appendChild( nBoundLatitudeElement );
1485 if ( !wgs84BoundingRect.
isNull() )
1487 QDomElement lastCRSElem = layerElem.lastChildElement( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS" );
1488 if ( !lastCRSElem.isNull() )
1490 layerElem.insertAfter( ExGeoBBoxElement, lastCRSElem );
1494 layerElem.appendChild( ExGeoBBoxElement );
1499 if ( !constrainedCrsList.isEmpty() )
1501 for (
int i = constrainedCrsList.size() - 1; i >= 0; --i )
1503 appendLayerBoundingBox( doc, layerElem, layerExtent, layerCRS, constrainedCrsList.at( i ), project );
1508 for (
const QString &
crs : crsList )
1510 appendLayerBoundingBox( doc, layerElem, layerExtent, layerCRS,
crs, project );
1516 void appendLayerBoundingBox( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &layerExtent,
1520 if ( layerElem.isNull() )
1525 if ( crsText.isEmpty() )
1530 QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1536 if ( !layerExtent.
isNull() )
1545 QgsMessageLog::logMessage( QStringLiteral(
"Error transforming extent: %1" ).arg( cse.
what() ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Warning );
1550 if ( crsExtent.
isNull() )
1562 QDomElement bBoxElement = doc.createElement( QStringLiteral(
"BoundingBox" ) );
1565 bBoxElement.setAttribute( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS", crs.
authid() );
1578 QDomElement lastBBoxElem = layerElem.lastChildElement( QStringLiteral(
"BoundingBox" ) );
1579 if ( !lastBBoxElem.isNull() )
1581 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1585 lastBBoxElem = layerElem.lastChildElement( version == QLatin1String(
"1.1.1" ) ?
"LatLonBoundingBox" :
"EX_GeographicBoundingBox" );
1586 if ( !lastBBoxElem.isNull() )
1588 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1592 layerElem.appendChild( bBoxElement );
1597 QgsRectangle layerBoundingBoxInProjectCrs(
const QDomDocument &doc,
const QDomElement &layerElem,
1601 if ( layerElem.isNull() )
1607 QDomElement boundingBoxElem = layerElem.firstChildElement( QStringLiteral(
"BoundingBox" ) );
1608 if ( boundingBoxElem.isNull() )
1613 double minx, miny, maxx, maxy;
1615 minx = boundingBoxElem.attribute( QStringLiteral(
"minx" ) ).toDouble( &conversionOk );
1616 if ( !conversionOk )
1620 miny = boundingBoxElem.attribute( QStringLiteral(
"miny" ) ).toDouble( &conversionOk );
1621 if ( !conversionOk )
1625 maxx = boundingBoxElem.attribute( QStringLiteral(
"maxx" ) ).toDouble( &conversionOk );
1626 if ( !conversionOk )
1630 maxy = boundingBoxElem.attribute( QStringLiteral(
"maxy" ) ).toDouble( &conversionOk );
1631 if ( !conversionOk )
1637 QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1651 if ( version != QLatin1String(
"1.1.1" ) && layerCrs.
hasAxisInverted() )
1662 BBox = t.transformBoundingBox( BBox );
1666 QgsMessageLog::logMessage( QStringLiteral(
"Error transforming extent: %1" ).arg( cse.
what() ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Warning );
1673 bool crsSetFromLayerElement(
const QDomElement &layerElement, QSet<QString> &crsSet )
1675 if ( layerElement.isNull() )
1682 QDomNodeList crsNodeList;
1683 crsNodeList = layerElement.elementsByTagName( QStringLiteral(
"CRS" ) );
1684 for (
int i = 0; i < crsNodeList.size(); ++i )
1686 crsSet.insert( crsNodeList.at( i ).toElement().text() );
1689 crsNodeList = layerElement.elementsByTagName( QStringLiteral(
"SRS" ) );
1690 for (
int i = 0; i < crsNodeList.size(); ++i )
1692 crsSet.insert( crsNodeList.at( i ).toElement().text() );
1698 void combineExtentAndCrsOfGroupChildren( QDomDocument &doc, QDomElement &groupElem,
const QgsProject *project,
1699 bool considerMapExtent )
1702 QSet<QString> combinedCRSSet;
1703 bool firstBBox =
true;
1704 bool firstCRSSet =
true;
1706 QDomNodeList layerChildren = groupElem.childNodes();
1707 for (
int j = 0; j < layerChildren.size(); ++j )
1709 QDomElement childElem = layerChildren.at( j ).toElement();
1711 if ( childElem.tagName() != QLatin1String(
"Layer" ) )
1714 QgsRectangle bbox = layerBoundingBoxInProjectCrs( doc, childElem, project );
1724 combinedBBox = bbox;
1734 QSet<QString> crsSet;
1735 if ( crsSetFromLayerElement( childElem, crsSet ) )
1739 combinedCRSSet = crsSet;
1740 firstCRSSet =
false;
1744 combinedCRSSet.intersect( crsSet );
1750 appendCrsElementsToLayer( doc, groupElem, combinedCRSSet.toList(), outputCrsList );
1753 if ( considerMapExtent )
1758 combinedBBox = mapRect;
1761 appendLayerBoundingBoxes( doc, groupElem, combinedBBox, groupCRS, combinedCRSSet.toList(), outputCrsList, project );
1765 void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem,
QgsServerInterface *serverIface,
1768 #ifdef HAVE_SERVER_PYTHON_PLUGINS 1771 ( void )serverIface;
1776 QStringList layerList;
1779 QList< QgsMapLayer * > projectLayerOrder = projectLayerTreeRoot->
layerOrder();
1780 for (
int i = 0; i < projectLayerOrder.size(); ++i )
1784 if ( restrictedLayers.contains( l->
name() ) )
1788 #ifdef HAVE_SERVER_PYTHON_PLUGINS 1794 QString wmsName = l->
name();
1804 layerList << wmsName;
1807 if ( !layerList.isEmpty() )
1809 QStringList reversedList;
1810 reversedList.reserve( layerList.size() );
1811 for (
int i = layerList.size() - 1; i >= 0; --i )
1812 reversedList << layerList[ i ];
1814 QDomElement layerDrawingOrderElem = doc.createElement( QStringLiteral(
"LayerDrawingOrder" ) );
1815 QDomText drawingOrderText = doc.createTextNode( reversedList.join(
',' ) );
1816 layerDrawingOrderElem.appendChild( drawingOrderText );
1817 parentElem.appendChild( layerDrawingOrderElem );
1821 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem,
QgsMapLayer *currentLayer )
1823 if ( !currentLayer )
1829 QDomElement treeNameElem = doc.createElement( QStringLiteral(
"TreeName" ) );
1830 QDomText treeNameText = doc.createTextNode( currentLayer->
name() );
1831 treeNameElem.appendChild( treeNameText );
1832 layerElem.appendChild( treeNameElem );
1834 switch ( currentLayer->
type() )
1841 int displayFieldIdx = -1;
1842 QString displayField = QStringLiteral(
"maptip" );
1844 if ( exp.isField() )
1851 QDomElement attributesElem = doc.createElement( QStringLiteral(
"Attributes" ) );
1853 for (
int idx = 0; idx < layerFields.
count(); ++idx )
1856 if ( excludedAttributes.contains( field.
name() ) )
1861 if ( idx == displayFieldIdx )
1865 QDomElement attributeElem = doc.createElement( QStringLiteral(
"Attribute" ) );
1866 attributeElem.setAttribute( QStringLiteral(
"name" ), field.
name() );
1867 attributeElem.setAttribute( QStringLiteral(
"type" ), QVariant::typeToName( field.
type() ) );
1868 attributeElem.setAttribute( QStringLiteral(
"typeName" ), field.
typeName() );
1869 QString alias = field.
alias();
1870 if ( !alias.isEmpty() )
1872 attributeElem.setAttribute( QStringLiteral(
"alias" ), alias );
1876 attributeElem.setAttribute( QStringLiteral(
"editType" ), vLayer->
editorWidgetSetup( idx ).
type() );
1877 attributeElem.setAttribute( QStringLiteral(
"comment" ), field.
comment() );
1878 attributeElem.setAttribute( QStringLiteral(
"length" ), field.
length() );
1879 attributeElem.setAttribute( QStringLiteral(
"precision" ), field.
precision() );
1880 attributesElem.appendChild( attributeElem );
1884 layerElem.setAttribute( QStringLiteral(
"displayField" ), displayField );
1888 if ( pkAttributes.size() > 0 )
1890 QDomElement pkElem = doc.createElement( QStringLiteral(
"PrimaryKey" ) );
1891 QgsAttributeList::const_iterator pkIt = pkAttributes.constBegin();
1892 for ( ; pkIt != pkAttributes.constEnd(); ++pkIt )
1894 QDomElement pkAttributeElem = doc.createElement( QStringLiteral(
"PrimaryKeyAttribute" ) );
1895 QDomText pkAttName = doc.createTextNode( layerFields.
at( *pkIt ).
name() );
1896 pkAttributeElem.appendChild( pkAttName );
1897 pkElem.appendChild( pkAttributeElem );
1899 layerElem.appendChild( pkElem );
1906 layerElem.setAttribute( QStringLiteral(
"opacity" ), QString::number( vLayer->
opacity() ) );
1908 layerElem.appendChild( attributesElem );
1915 if ( provider && provider->
name() ==
"wms" )
1918 QVariant wmsBackgroundLayer = currentLayer->
customProperty( QStringLiteral(
"WMSBackgroundLayer" ),
false );
1919 QDomElement wmsBackgroundLayerElem = doc.createElement(
"WMSBackgroundLayer" );
1920 QDomText wmsBackgroundLayerText = doc.createTextNode( wmsBackgroundLayer.toBool() ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
1921 wmsBackgroundLayerElem.appendChild( wmsBackgroundLayerText );
1922 layerElem.appendChild( wmsBackgroundLayerElem );
1925 QVariant wmsPublishDataSourceUrl = currentLayer->
customProperty( QStringLiteral(
"WMSPublishDataSourceUrl" ),
false );
1926 if ( wmsPublishDataSourceUrl.toBool() )
1929 ? !qobject_cast< const QgsRasterDataProvider * >( provider )->
nativeResolutions().isEmpty()
1932 QDomElement dataSourceElem = doc.createElement( tiled ? QStringLiteral(
"WMTSDataSource" ) : QStringLiteral(
"WMSDataSource" ) );
1933 QDomText dataSourceUri = doc.createTextNode( provider->
dataSourceUri() );
1934 dataSourceElem.appendChild( dataSourceUri );
1935 layerElem.appendChild( dataSourceElem );
1939 QVariant wmsPrintLayer = currentLayer->
customProperty( QStringLiteral(
"WMSPrintLayer" ) );
1940 if ( wmsPrintLayer.isValid() )
1942 QDomElement wmsPrintLayerElem = doc.createElement(
"WMSPrintLayer" );
1943 QDomText wmsPrintLayerText = doc.createTextNode( wmsPrintLayer.toString() );
1944 wmsPrintLayerElem.appendChild( wmsPrintLayerText );
1945 layerElem.appendChild( wmsPrintLayerElem );
1951 if ( rasterRenderer )
1953 layerElem.setAttribute( QStringLiteral(
"opacity" ), QString::number( rasterRenderer->
opacity() ) );
1964 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent )
1968 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"KeywordList" ) );
1970 QDomElement keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1971 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"ISO" ) );
1972 QDomText keywordText = doc.createTextNode( QStringLiteral(
"infoMapAccessService" ) );
1973 keywordElem.appendChild( keywordText );
1974 keywordsElem.appendChild( keywordElem );
1975 parent.appendChild( keywordsElem );
1977 for (
const QString &keyword : qgis::as_const( keywords ) )
1979 if ( !keyword.isEmpty() )
1981 keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1982 keywordText = doc.createTextNode( keyword );
1983 keywordElem.appendChild( keywordText );
1986 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"SIA_Geo405" ) );
1988 keywordsElem.appendChild( keywordElem );
1991 parent.appendChild( keywordsElem );
1999 for (
int j = 0; j < childNode->
children().size(); ++j )
2009 const auto l { treeLayer->
layer() };
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
SERVER_EXPORT QString wmsInspireMetadataUrl(const QgsProject &project)
Returns the Inspire metadata URL.
Class for parsing and evaluation of expressions (formerly called "search strings").
Layer tree group node serves as a container for layers and further groups.
bool fillCacheKey(QStringList &cacheKey) const
Fill the capabilities caching key.
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...
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
SERVER_EXPORT QStringList wmsOutputCrsList(const QgsProject &project)
Returns the WMS output CRS list.
A rectangle specified with double values.
Base class for all map layer types.
QStringList styles() const
Returns list of all defined style names.
SERVER_EXPORT int wmsMaxWidth(const QgsProject &project)
Returns the maximum width for WMS images defined in a QGIS project.
void layoutObjects(QList< T *> &objectList) const
Returns a list of layout objects (items and multiframes) of a specific type.
QgsMapLayerType type() const
Returns the type of the layer.
Setting to define QGIS Server WMS Dimension.
virtual QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be nullptr.
void setXMaximum(double x)
Set the maximum x value.
SERVER_EXPORT QString owsServiceContactPosition(const QgsProject &project)
Returns the owsService contact position defined in project.
SERVER_EXPORT QString owsServiceContactPerson(const QgsProject &project)
Returns the owsService contact person defined in project.
SERVER_EXPORT QStringList owsServiceKeywords(const QgsProject &project)
Returns the owsService keywords defined in project.
QSet< QString > excludeAttributesWms() const
A set of attributes that are not advertised in WMS requests with QGIS server.
A layout item subclass for text labels.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
double opacity() const
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1...
Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
Represents a raster layer.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
SERVER_EXPORT QString owsServiceAbstract(const QgsProject &project)
Returns the owsService abstract defined in project.
QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request. ...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QgsLayoutSize sizeWithUnits() const
Returns the item's current size, including units.
bool hasQueryableChildren(const QgsLayerTreeNode *childNode, const QStringList &wmsRestrictedLayers)
Modify current selection to include only select features which match.
const QList< QgsVectorLayerServerProperties::WmsDimensionInfo > wmsDimensions() const
Returns the QGIS Server WMS Dimension list.
QDomElement getServiceElement(QDomDocument &doc, const QgsProject *project, const QString &version, const QgsServerRequest &request)
Create Service element for get capabilities document.
Container of fields for a vector layer.
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
SERVER_EXPORT bool wmsInfoFormatSia2045(const QgsProject &project)
Returns if the info format is SIA20145.
bool isVisible() const
Returns whether a node is really visible (ie checked and all its ancestors checked as well) ...
Abstract base class for spatial data provider implementations.
QList< QgsPrintLayout *> printLayouts() const
Returns a list of all print layouts contained in the manager.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
int frameCount() const
Returns the number of frames associated with this multiframe.
const QgsCoordinateReferenceSystem & crs
SERVER_EXPORT QString wmsInspireMetadataDate(const QgsProject &project)
Returns the Inspire metadata date.
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device...
int count() const
Returns number of items.
bool isMutuallyExclusive() const
Returns whether the group is mutually exclusive (only one child can be checked at a time) ...
virtual QString name() const =0
Returns a provider name.
virtual QgsRectangle extent() const
Returns the extent of the layer.
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) ...
virtual QString configFilePath()=0
Returns the configuration file path.
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
QDomElement getLayersAndStylesCapabilitiesElement(QDomDocument &doc, QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, bool projectSettings)
Create element for get capabilities document.
void layoutItems(QList< T *> &itemList) const
Returns a list of layout items of a specific type.
QString metadataUrlFormat() const
Returns the metadata format of the layer used by QGIS Server in GetCapabilities request.
void writeGetCapabilities(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response, bool projectSettings)
Output GetCapabilities response.
Layout graphical items for displaying a map.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
QgsLayoutItemPage * page(int pageNumber)
Returns a specific page (by pageNumber) from the collection.
virtual QgsCapabilitiesCache * capabilitiesCache()=0
Gets pointer to the capabiblities cache.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Namespace with helper functions for layer tree operations.
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
void grow(double delta)
Grows the rectangle in place by the specified amount.
bool isEmpty() const
Returns true if the rectangle is empty.
QString typeName() const
Gets the field type.
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout...
virtual QList< double > nativeResolutions() const
Returns a list of native resolutions if available, i.e.
long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
QDomElement getComposerTemplatesElement(QDomDocument &doc, const QgsProject *project)
Create ComposerTemplates element for get capabilities document.
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
SERVER_EXPORT QStringList wmsRestrictedComposers(const QgsProject &project)
Returns the restricted composer list.
QDomDocument getCapabilities(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, bool projectSettings)
Creates the WMS GetCapabilities XML document.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
SERVER_EXPORT double floorWithPrecision(double number, int places)
Returns a double less than number to the specified number of places.
void setYMinimum(double y)
Set the minimum y value.
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
QgsCoordinateReferenceSystem crs
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).
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
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...
QgsVectorLayerServerProperties * serverProperties() const
Returns QGIS Server Properties of the vector layer.
QgsAttributeList primaryKeyAttributes() const
Returns the list of attributes which make up the layer's primary keys.
SERVER_EXPORT bool wmsInspireActivate(const QgsProject &project)
Returns if Inspire is activated.
SERVER_EXPORT QString wmsInspireTemporalReference(const QgsProject &project)
Returns the Inspire temporal reference.
A helper class that centralizes caches accesses given by all the server cache filter plugins...
An expression node which takes it value from a feature's field.
QString legendUrl() const
Returns the URL for the layer's legend.
This class is a base class for nodes in a layer tree.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
QString id() const
Returns the item's ID name.
SERVER_EXPORT QString wmsInspireLanguage(const QgsProject &project)
Returns the Inspire language.
SERVER_EXPORT QString owsServiceFees(const QgsProject &project)
Returns the owsService fees defined in project.
Encapsulate a field in an attribute table or data source.
SERVER_EXPORT double ceilWithPrecision(double number, int places)
Returns a double greater than number to the specified number of places.
double minimumScale() const
Returns the minimum map scale (i.e.
double maximumScale() const
Returns the maximum map scale (i.e.
QgsLayoutAtlas * atlas()
Returns the print layout's atlas.
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.
QString displayExpression
QString legendUrlFormat() const
Returns the format for a URL based layer legend.
SERVER_EXPORT QString owsServiceAccessConstraints(const QgsProject &project)
Returns the owsService access constraints defined in project.
NodeType nodeType() const
Find out about type of the node. It is usually shorter to use convenience functions from QgsLayerTree...
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
SERVER_EXPORT QString owsServiceOnlineResource(const QgsProject &project)
Returns the owsService online resource defined in project.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
Remove from current selection.
Median cut implementation.
SERVER_EXPORT QString owsServiceContactOrganization(const QgsProject &project)
Returns the owsService contact organization defined in project.
int pageCount() const
Returns the number of pages in the collection.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
Add selection to current selection.
QgsLayoutFrame * frame(int index) const
Returns the child frame at a specified index from the multiframe.
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QgsCoordinateTransformContext transformContext
QgsMapLayer * layer() const
Returns the map layer associated with this node.
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle...
A cache for capabilities xml documents (by configuration file path)
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
Leaf node pointing to a layer.
bool layerReadPermission(const QgsMapLayer *layer) const
Returns the layer read right.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins...
QList< QgsMapLayer * > layerOrder() const
The order in which layers will be rendered on the canvas.
double length() const
Returns the length of the measurement.
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
QgsEditorWidgetSetup editorWidgetSetup(int index) const
The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field ...
int indexOf(const QString &fieldName) const
Gets the field index from the field name.
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const FINAL
Calculates a list of unique values contained within an attribute in the layer.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
void setYMaximum(double y)
Set the maximum y value.
QDomElement getInspireCapabilitiesElement(QDomDocument &doc, const QgsProject *project)
Create InspireCapabilities element for get capabilities document.
SERVER_EXPORT QgsRectangle wmsExtent(const QgsProject &project)
Returns the WMS Extent restriction.
QDomElement getCapabilityElement(QDomDocument &doc, const QgsProject *project, const QString &version, const QgsServerRequest &request, bool projectSettings)
Create Capability element for get capabilities document.
bool hasAxisInverted() const
Returns whether axis is inverted (e.g., for WMS 1.3) for the CRS.
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
SERVER_EXPORT QString wmsInspireMetadataUrlType(const QgsProject &project)
Returns the Inspire metadata URL type.
This class represents a coordinate reference system (CRS).
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
bool setCachedDocument(const QDomDocument *doc, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Updates or inserts the document in cache like capabilities.
QgsLayoutMeasurement convertFromLayoutUnits(double length, QgsUnitTypes::LayoutUnit unit) const
Converts a length measurement from the layout's native units to a specified target unit...
static QString displayString(Type type)
Returns a display string type for a WKB type, e.g., the geometry name used in WKT geometry representa...
virtual QgsServerCacheManager * cacheManager() const =0
Gets the registered server cache filters.
QUrl serviceUrl(const QgsServerRequest &request, const QgsProject *project)
Returns WMS service URL.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
bool enabled() const
Returns whether the atlas generation is enabled.
A helper class that centralizes restrictions given by all the access control filter plugins...
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
QgsVectorLayer * coverageLayer() const
Returns the coverage layer used for the atlas features.
QString metadataUrl() const
Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
const QDomDocument * searchCapabilitiesDocument(const QString &configFilePath, const QString &key)
Returns cached capabilities document (or 0 if document for configuration file not in cache) ...
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
QString name() const override
Returns the group's name.
Custom exception class for Coordinate Reference System related exceptions.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
QString title() const
Returns the project's title.
SERVER_EXPORT QString owsServiceContactMail(const QgsProject &project)
Returns the owsService contact mail defined in project.
QList< int > QgsAttributeList
Print layout, a QgsLayout subclass for static or atlas-based layouts.
QgsRectangle bounds() const
Returns the approximate bounds for the region the CRS is usable within.
SERVER_EXPORT QStringList wmsRestrictedLayers(const QgsProject &project)
Returns the restricted layer name list.
Container of other groups and layers.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
SERVER_EXPORT QString wmsRootName(const QgsProject &project)
Returns the WMS root layer name defined in a QGIS project.
Represents a vector layer which manages a vector based data sets.
CONSTLATIN1STRING geoEpsgCrsAuthId()
Geographic coord sys from EPSG authority.
A layout multiframe subclass for HTML content.
QString attributeDisplayName(int index) const
Convenience function that returns the attribute alias if defined or the field name else...
If the layer is identifiable using the identify map tool and as a WMS layer.
Raster renderer pipe that applies colors to a raster.
QString authid() const
Returns the authority identifier for the CRS.
SERVER_EXPORT QString owsServiceTitle(const QgsProject &project)
Returns the owsService title defined in project.
QDomElement getWFSLayersElement(QDomDocument &doc, const QgsProject *project)
Create WFSLayers element for get capabilities document.
void setXMinimum(double x)
Set the minimum x value.
QgsCoordinateReferenceSystem crs
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
QString metadataUrlType() const
Returns the metadata type of the layer used by QGIS Server in GetCapabilities request.
void invert()
Swap x/y coordinates in the rectangle.
QMap< QString, QString > Parameters
Layer tree node points to a map layer.
SERVER_EXPORT QString owsServiceContactPhone(const QgsProject &project)
Returns the owsService contact phone defined in project.
SERVER_EXPORT int wmsMaxHeight(const QgsProject &project)
Returns the maximum height for WMS images defined in a QGIS project.
Base class for raster data providers.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
SERVER_EXPORT bool wmsUseLayerIds(const QgsProject &project)
Returns if layer ids are used as name in WMS.