50 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem,
QgsMapLayer *currentLayer );
52 void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem,
QgsServerInterface *serverIface,
55 void combineExtentAndCrsOfGroupChildren( QDomDocument &doc, QDomElement &groupElem,
const QgsProject *project,
56 bool considerMapExtent =
false );
58 bool crsSetFromLayerElement(
const QDomElement &layerElement, QSet<QString> &crsSet );
60 QgsRectangle layerBoundingBoxInProjectCrs(
const QDomDocument &doc,
const QDomElement &layerElem,
63 void appendLayerBoundingBox( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &layerExtent,
67 void appendLayerBoundingBoxes( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &lExtent,
69 const QStringList &constrainedCrsList,
const QgsProject *project );
71 void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement,
const QDomElement &precedingElement,
72 const QString &crsText );
74 void appendCrsElementsToLayer( QDomDocument &doc, QDomElement &layerElement,
75 const QStringList &crsList,
const QStringList &constrainedCrsList );
77 void appendLayerStyles( QDomDocument &doc, QDomElement &layerElem,
QgsMapLayer *currentLayer,
80 void appendLayersFromTreeGroup( QDomDocument &doc,
81 QDomElement &parentLayer,
84 const QString &version,
87 bool projectSettings );
89 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent );
96 #ifdef HAVE_SERVER_PYTHON_PLUGINS 101 const QDomDocument *capabilitiesDocument =
nullptr;
106 QStringList cacheKeyList;
107 cacheKeyList << ( projectSettings ? QStringLiteral(
"projectSettings" ) : version );
108 cacheKeyList << request.
url().host();
111 #ifdef HAVE_SERVER_PYTHON_PLUGINS 115 QString cacheKey = cacheKeyList.join(
'-' );
117 #ifdef HAVE_SERVER_PYTHON_PLUGINS 119 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
121 capabilitiesDocument = &doc;
124 if ( !capabilitiesDocument && cache )
129 if ( !capabilitiesDocument )
131 QgsMessageLog::logMessage( QStringLiteral(
"WMS capabilities document not found in cache" ), QStringLiteral(
"Server" ) );
133 doc =
getCapabilities( serverIface, project, version, request, projectSettings );
135 #ifdef HAVE_SERVER_PYTHON_PLUGINS 139 capabilitiesDocument = &doc;
143 if ( !capabilitiesDocument )
148 if ( !capabilitiesDocument )
150 capabilitiesDocument = &doc;
162 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
163 response.
write( capabilitiesDocument->toByteArray() );
168 bool projectSettings )
171 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 );
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 if ( !title.isEmpty() )
272 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
273 QDomText titleText = doc.createTextNode( title );
274 titleElem.appendChild( titleText );
275 serviceElem.appendChild( titleElem );
279 if ( !
abstract.isEmpty() )
281 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
282 QDomText abstractText = doc.createCDATASection(
abstract );
283 abstractElem.appendChild( abstractText );
284 serviceElem.appendChild( abstractElem );
287 addKeywordListElement( project, doc, serviceElem );
290 if ( onlineResource.isEmpty() )
292 onlineResource =
serviceUrl( request, project ).toString();
294 QDomElement onlineResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
295 onlineResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
296 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
297 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), onlineResource );
298 serviceElem.appendChild( onlineResourceElem );
305 if ( !contactPerson.isEmpty() ||
306 !contactOrganization.isEmpty() ||
307 !contactPosition.isEmpty() ||
308 !contactMail.isEmpty() ||
309 !contactPhone.isEmpty() )
312 QDomElement contactInfoElem = doc.createElement( QStringLiteral(
"ContactInformation" ) );
315 if ( !contactPerson.isEmpty() ||
316 !contactOrganization.isEmpty() ||
317 !contactPosition.isEmpty() )
319 QDomElement contactPersonPrimaryElem = doc.createElement( QStringLiteral(
"ContactPersonPrimary" ) );
321 if ( !contactPerson.isEmpty() )
323 QDomElement contactPersonElem = doc.createElement( QStringLiteral(
"ContactPerson" ) );
324 QDomText contactPersonText = doc.createTextNode( contactPerson );
325 contactPersonElem.appendChild( contactPersonText );
326 contactPersonPrimaryElem.appendChild( contactPersonElem );
329 if ( !contactOrganization.isEmpty() )
331 QDomElement contactOrganizationElem = doc.createElement( QStringLiteral(
"ContactOrganization" ) );
332 QDomText contactOrganizationText = doc.createTextNode( contactOrganization );
333 contactOrganizationElem.appendChild( contactOrganizationText );
334 contactPersonPrimaryElem.appendChild( contactOrganizationElem );
337 if ( !contactPosition.isEmpty() )
339 QDomElement contactPositionElem = doc.createElement( QStringLiteral(
"ContactPosition" ) );
340 QDomText contactPositionText = doc.createTextNode( contactPosition );
341 contactPositionElem.appendChild( contactPositionText );
342 contactPersonPrimaryElem.appendChild( contactPositionElem );
345 contactInfoElem.appendChild( contactPersonPrimaryElem );
348 if ( !contactPhone.isEmpty() )
350 QDomElement phoneElem = doc.createElement( QStringLiteral(
"ContactVoiceTelephone" ) );
351 QDomText phoneText = doc.createTextNode( contactPhone );
352 phoneElem.appendChild( phoneText );
353 contactInfoElem.appendChild( phoneElem );
356 if ( !contactMail.isEmpty() )
358 QDomElement mailElem = doc.createElement( QStringLiteral(
"ContactElectronicMailAddress" ) );
359 QDomText mailText = doc.createTextNode( contactMail );
360 mailElem.appendChild( mailText );
361 contactInfoElem.appendChild( mailElem );
364 serviceElem.appendChild( contactInfoElem );
367 QDomElement feesElem = doc.createElement( QStringLiteral(
"Fees" ) );
368 QDomText feesText = doc.createTextNode( QStringLiteral(
"None" ) );
370 if ( !fees.isEmpty() )
372 feesText = doc.createTextNode( fees );
374 feesElem.appendChild( feesText );
375 serviceElem.appendChild( feesElem );
377 QDomElement accessConstraintsElem = doc.createElement( QStringLiteral(
"AccessConstraints" ) );
378 QDomText accessConstraintsText = doc.createTextNode( QStringLiteral(
"None" ) );
380 if ( !accessConstraints.isEmpty() )
382 accessConstraintsText = doc.createTextNode( accessConstraints );
384 accessConstraintsElem.appendChild( accessConstraintsText );
385 serviceElem.appendChild( accessConstraintsElem );
387 if ( version == QLatin1String(
"1.3.0" ) )
392 QDomElement maxWidthElem = doc.createElement( QStringLiteral(
"MaxWidth" ) );
393 QDomText maxWidthText = doc.createTextNode( QString::number( maxWidth ) );
394 maxWidthElem.appendChild( maxWidthText );
395 serviceElem.appendChild( maxWidthElem );
401 QDomElement maxHeightElem = doc.createElement( QStringLiteral(
"MaxHeight" ) );
402 QDomText maxHeightText = doc.createTextNode( QString::number( maxHeight ) );
403 maxHeightElem.appendChild( maxHeightText );
404 serviceElem.appendChild( maxHeightElem );
413 bool projectSettings )
421 QString hrefString = href.toString();
422 hrefString.append( href.hasQuery() ?
"&" :
"?" );
424 QDomElement capabilityElem = doc.createElement( QStringLiteral(
"Capability" ) );
427 QDomElement requestElem = doc.createElement( QStringLiteral(
"Request" ) );
428 capabilityElem.appendChild( requestElem );
430 QDomElement dcpTypeElem = doc.createElement( QStringLiteral(
"DCPType" ) );
431 QDomElement httpElem = doc.createElement( QStringLiteral(
"HTTP" ) );
432 dcpTypeElem.appendChild( httpElem );
435 std::function < void ( QDomElement &, const QString & ) > appendFormat = [&doc]( QDomElement & elem,
const QString & format )
437 QDomElement formatElem = doc.createElement( QStringLiteral(
"Format" ) );
438 formatElem.appendChild( doc.createTextNode( format ) );
439 elem.appendChild( formatElem );
445 elem = doc.createElement( QStringLiteral(
"GetCapabilities" ) );
446 appendFormat( elem, ( version == QLatin1String(
"1.1.1" ) ?
"application/vnd.ogc.wms_xml" :
"text/xml" ) );
447 elem.appendChild( dcpTypeElem );
448 requestElem.appendChild( elem );
453 if ( parameters.value( QStringLiteral(
"SERVICE" ) ).compare( QLatin1String(
"WMS" ), Qt::CaseInsensitive ) != 0 )
455 QDomElement soapElem = doc.createElement( QStringLiteral(
"SOAP" ) );
456 httpElem.appendChild( soapElem );
457 QDomElement soapResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
458 soapResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
459 soapResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
460 soapResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), hrefString );
461 soapElem.appendChild( soapResourceElem );
465 QDomElement getElem = doc.createElement( QStringLiteral(
"Get" ) );
466 httpElem.appendChild( getElem );
467 QDomElement olResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
468 olResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
469 olResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
470 olResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), hrefString );
471 getElem.appendChild( olResourceElem );
474 elem = doc.createElement( QStringLiteral(
"GetMap" ) );
475 appendFormat( elem, QStringLiteral(
"image/jpeg" ) );
476 appendFormat( elem, QStringLiteral(
"image/png" ) );
477 appendFormat( elem, QStringLiteral(
"image/png; mode=16bit" ) );
478 appendFormat( elem, QStringLiteral(
"image/png; mode=8bit" ) );
479 appendFormat( elem, QStringLiteral(
"image/png; mode=1bit" ) );
480 appendFormat( elem, QStringLiteral(
"application/dxf" ) );
481 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
482 requestElem.appendChild( elem );
485 elem = doc.createElement( QStringLiteral(
"GetFeatureInfo" ) );
486 appendFormat( elem, QStringLiteral(
"text/plain" ) );
487 appendFormat( elem, QStringLiteral(
"text/html" ) );
488 appendFormat( elem, QStringLiteral(
"text/xml" ) );
489 appendFormat( elem, QStringLiteral(
"application/vnd.ogc.gml" ) );
490 appendFormat( elem, QStringLiteral(
"application/vnd.ogc.gml/3.1.1" ) );
491 appendFormat( elem, QStringLiteral(
"application/json" ) );
492 appendFormat( elem, QStringLiteral(
"application/geo+json" ) );
493 elem.appendChild( dcpTypeElem.cloneNode().toElement() );
494 requestElem.appendChild( elem );
497 elem = doc.createElement( ( version == QLatin1String(
"1.1.1" ) ?
"GetLegendGraphic" :
"sld:GetLegendGraphic" ) );
498 appendFormat( elem, QStringLiteral(
"image/jpeg" ) );
499 appendFormat( elem, QStringLiteral(
"image/png" ) );
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 );
1435 QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1438 QDomElement ExGeoBBoxElement;
1441 if ( !layerExtent.
isNull() )
1450 QgsMessageLog::logMessage( QStringLiteral(
"Error transforming extent: %1" ).arg( cse.
what() ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Warning );
1455 if ( version == QLatin1String(
"1.1.1" ) )
1457 ExGeoBBoxElement = doc.createElement( QStringLiteral(
"LatLonBoundingBox" ) );
1458 ExGeoBBoxElement.setAttribute( QStringLiteral(
"minx" ), QString::number( wgs84BoundingRect.
xMinimum() ) );
1459 ExGeoBBoxElement.setAttribute( QStringLiteral(
"maxx" ), QString::number( wgs84BoundingRect.
xMaximum() ) );
1460 ExGeoBBoxElement.setAttribute( QStringLiteral(
"miny" ), QString::number( wgs84BoundingRect.
yMinimum() ) );
1461 ExGeoBBoxElement.setAttribute( QStringLiteral(
"maxy" ), QString::number( wgs84BoundingRect.
yMaximum() ) );
1465 ExGeoBBoxElement = doc.createElement( QStringLiteral(
"EX_GeographicBoundingBox" ) );
1466 QDomElement wBoundLongitudeElement = doc.createElement( QStringLiteral(
"westBoundLongitude" ) );
1467 QDomText wBoundLongitudeText = doc.createTextNode( QString::number( wgs84BoundingRect.
xMinimum() ) );
1468 wBoundLongitudeElement.appendChild( wBoundLongitudeText );
1469 ExGeoBBoxElement.appendChild( wBoundLongitudeElement );
1470 QDomElement eBoundLongitudeElement = doc.createElement( QStringLiteral(
"eastBoundLongitude" ) );
1471 QDomText eBoundLongitudeText = doc.createTextNode( QString::number( wgs84BoundingRect.
xMaximum() ) );
1472 eBoundLongitudeElement.appendChild( eBoundLongitudeText );
1473 ExGeoBBoxElement.appendChild( eBoundLongitudeElement );
1474 QDomElement sBoundLatitudeElement = doc.createElement( QStringLiteral(
"southBoundLatitude" ) );
1475 QDomText sBoundLatitudeText = doc.createTextNode( QString::number( wgs84BoundingRect.
yMinimum() ) );
1476 sBoundLatitudeElement.appendChild( sBoundLatitudeText );
1477 ExGeoBBoxElement.appendChild( sBoundLatitudeElement );
1478 QDomElement nBoundLatitudeElement = doc.createElement( QStringLiteral(
"northBoundLatitude" ) );
1479 QDomText nBoundLatitudeText = doc.createTextNode( QString::number( wgs84BoundingRect.
yMaximum() ) );
1480 nBoundLatitudeElement.appendChild( nBoundLatitudeText );
1481 ExGeoBBoxElement.appendChild( nBoundLatitudeElement );
1484 if ( !wgs84BoundingRect.
isNull() )
1486 QDomElement lastCRSElem = layerElem.lastChildElement( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS" );
1487 if ( !lastCRSElem.isNull() )
1489 layerElem.insertAfter( ExGeoBBoxElement, lastCRSElem );
1493 layerElem.appendChild( ExGeoBBoxElement );
1498 if ( !constrainedCrsList.isEmpty() )
1500 for (
int i = constrainedCrsList.size() - 1; i >= 0; --i )
1502 appendLayerBoundingBox( doc, layerElem, layerExtent, layerCRS, constrainedCrsList.at( i ), project );
1507 for (
const QString &
crs : crsList )
1509 appendLayerBoundingBox( doc, layerElem, layerExtent, layerCRS,
crs, project );
1515 void appendLayerBoundingBox( QDomDocument &doc, QDomElement &layerElem,
const QgsRectangle &layerExtent,
1519 if ( layerElem.isNull() )
1524 if ( crsText.isEmpty() )
1529 QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1535 if ( !layerExtent.
isNull() )
1544 QgsMessageLog::logMessage( QStringLiteral(
"Error transforming extent: %1" ).arg( cse.
what() ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Warning );
1549 if ( crsExtent.
isNull() )
1555 QDomElement bBoxElement = doc.createElement( QStringLiteral(
"BoundingBox" ) );
1558 bBoxElement.setAttribute( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS", crs.
authid() );
1566 bBoxElement.setAttribute( QStringLiteral(
"minx" ), QString::number( crsExtent.
xMinimum() ) );
1567 bBoxElement.setAttribute( QStringLiteral(
"miny" ), QString::number( crsExtent.
yMinimum() ) );
1568 bBoxElement.setAttribute( QStringLiteral(
"maxx" ), QString::number( crsExtent.
xMaximum() ) );
1569 bBoxElement.setAttribute( QStringLiteral(
"maxy" ), QString::number( crsExtent.
yMaximum() ) );
1571 QDomElement lastBBoxElem = layerElem.lastChildElement( QStringLiteral(
"BoundingBox" ) );
1572 if ( !lastBBoxElem.isNull() )
1574 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1578 lastBBoxElem = layerElem.lastChildElement( version == QLatin1String(
"1.1.1" ) ?
"LatLonBoundingBox" :
"EX_GeographicBoundingBox" );
1579 if ( !lastBBoxElem.isNull() )
1581 layerElem.insertAfter( bBoxElement, lastBBoxElem );
1585 layerElem.appendChild( bBoxElement );
1590 QgsRectangle layerBoundingBoxInProjectCrs(
const QDomDocument &doc,
const QDomElement &layerElem,
1594 if ( layerElem.isNull() )
1600 QDomElement boundingBoxElem = layerElem.firstChildElement( QStringLiteral(
"BoundingBox" ) );
1601 if ( boundingBoxElem.isNull() )
1606 double minx, miny, maxx, maxy;
1608 minx = boundingBoxElem.attribute( QStringLiteral(
"minx" ) ).toDouble( &conversionOk );
1609 if ( !conversionOk )
1613 miny = boundingBoxElem.attribute( QStringLiteral(
"miny" ) ).toDouble( &conversionOk );
1614 if ( !conversionOk )
1618 maxx = boundingBoxElem.attribute( QStringLiteral(
"maxx" ) ).toDouble( &conversionOk );
1619 if ( !conversionOk )
1623 maxy = boundingBoxElem.attribute( QStringLiteral(
"maxy" ) ).toDouble( &conversionOk );
1624 if ( !conversionOk )
1630 QString version = doc.documentElement().attribute( QStringLiteral(
"version" ) );
1644 if ( version != QLatin1String(
"1.1.1" ) && layerCrs.
hasAxisInverted() )
1655 BBox = t.transformBoundingBox( BBox );
1659 QgsMessageLog::logMessage( QStringLiteral(
"Error transforming extent: %1" ).arg( cse.
what() ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Warning );
1666 bool crsSetFromLayerElement(
const QDomElement &layerElement, QSet<QString> &crsSet )
1668 if ( layerElement.isNull() )
1675 QDomNodeList crsNodeList;
1676 crsNodeList = layerElement.elementsByTagName( QStringLiteral(
"CRS" ) );
1677 for (
int i = 0; i < crsNodeList.size(); ++i )
1679 crsSet.insert( crsNodeList.at( i ).toElement().text() );
1682 crsNodeList = layerElement.elementsByTagName( QStringLiteral(
"SRS" ) );
1683 for (
int i = 0; i < crsNodeList.size(); ++i )
1685 crsSet.insert( crsNodeList.at( i ).toElement().text() );
1691 void combineExtentAndCrsOfGroupChildren( QDomDocument &doc, QDomElement &groupElem,
const QgsProject *project,
1692 bool considerMapExtent )
1695 QSet<QString> combinedCRSSet;
1696 bool firstBBox =
true;
1697 bool firstCRSSet =
true;
1699 QDomNodeList layerChildren = groupElem.childNodes();
1700 for (
int j = 0; j < layerChildren.size(); ++j )
1702 QDomElement childElem = layerChildren.at( j ).toElement();
1704 if ( childElem.tagName() != QLatin1String(
"Layer" ) )
1707 QgsRectangle bbox = layerBoundingBoxInProjectCrs( doc, childElem, project );
1717 combinedBBox = bbox;
1727 QSet<QString> crsSet;
1728 if ( crsSetFromLayerElement( childElem, crsSet ) )
1732 combinedCRSSet = crsSet;
1733 firstCRSSet =
false;
1737 combinedCRSSet.intersect( crsSet );
1743 appendCrsElementsToLayer( doc, groupElem, combinedCRSSet.toList(), outputCrsList );
1746 if ( considerMapExtent )
1751 combinedBBox = mapRect;
1754 appendLayerBoundingBoxes( doc, groupElem, combinedBBox, groupCRS, combinedCRSSet.toList(), outputCrsList, project );
1758 void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem,
QgsServerInterface *serverIface,
1761 #ifdef HAVE_SERVER_PYTHON_PLUGINS 1764 ( void )serverIface;
1769 QStringList layerList;
1772 QList< QgsMapLayer * > projectLayerOrder = projectLayerTreeRoot->
layerOrder();
1773 for (
int i = 0; i < projectLayerOrder.size(); ++i )
1777 if ( restrictedLayers.contains( l->
name() ) )
1781 #ifdef HAVE_SERVER_PYTHON_PLUGINS 1787 QString wmsName = l->
name();
1797 layerList << wmsName;
1800 if ( !layerList.isEmpty() )
1802 QStringList reversedList;
1803 reversedList.reserve( layerList.size() );
1804 for (
int i = layerList.size() - 1; i >= 0; --i )
1805 reversedList << layerList[ i ];
1807 QDomElement layerDrawingOrderElem = doc.createElement( QStringLiteral(
"LayerDrawingOrder" ) );
1808 QDomText drawingOrderText = doc.createTextNode( reversedList.join(
',' ) );
1809 layerDrawingOrderElem.appendChild( drawingOrderText );
1810 parentElem.appendChild( layerDrawingOrderElem );
1814 void appendLayerProjectSettings( QDomDocument &doc, QDomElement &layerElem,
QgsMapLayer *currentLayer )
1816 if ( !currentLayer )
1822 QDomElement treeNameElem = doc.createElement( QStringLiteral(
"TreeName" ) );
1823 QDomText treeNameText = doc.createTextNode( currentLayer->
name() );
1824 treeNameElem.appendChild( treeNameText );
1825 layerElem.appendChild( treeNameElem );
1827 switch ( currentLayer->
type() )
1834 int displayFieldIdx = -1;
1835 QString displayField = QStringLiteral(
"maptip" );
1837 if ( exp.isField() )
1844 QDomElement attributesElem = doc.createElement( QStringLiteral(
"Attributes" ) );
1846 for (
int idx = 0; idx < layerFields.
count(); ++idx )
1849 if ( excludedAttributes.contains( field.
name() ) )
1854 if ( idx == displayFieldIdx )
1858 QDomElement attributeElem = doc.createElement( QStringLiteral(
"Attribute" ) );
1859 attributeElem.setAttribute( QStringLiteral(
"name" ), field.
name() );
1860 attributeElem.setAttribute( QStringLiteral(
"type" ), QVariant::typeToName( field.
type() ) );
1861 attributeElem.setAttribute( QStringLiteral(
"typeName" ), field.
typeName() );
1862 QString alias = field.
alias();
1863 if ( !alias.isEmpty() )
1865 attributeElem.setAttribute( QStringLiteral(
"alias" ), alias );
1869 attributeElem.setAttribute( QStringLiteral(
"editType" ), vLayer->
editorWidgetSetup( idx ).
type() );
1870 attributeElem.setAttribute( QStringLiteral(
"comment" ), field.
comment() );
1871 attributeElem.setAttribute( QStringLiteral(
"length" ), field.
length() );
1872 attributeElem.setAttribute( QStringLiteral(
"precision" ), field.
precision() );
1873 attributesElem.appendChild( attributeElem );
1877 layerElem.setAttribute( QStringLiteral(
"displayField" ), displayField );
1881 if ( pkAttributes.size() > 0 )
1883 QDomElement pkElem = doc.createElement( QStringLiteral(
"PrimaryKey" ) );
1884 QgsAttributeList::const_iterator pkIt = pkAttributes.constBegin();
1885 for ( ; pkIt != pkAttributes.constEnd(); ++pkIt )
1887 QDomElement pkAttributeElem = doc.createElement( QStringLiteral(
"PrimaryKeyAttribute" ) );
1888 QDomText pkAttName = doc.createTextNode( layerFields.
at( *pkIt ).
name() );
1889 pkAttributeElem.appendChild( pkAttName );
1890 pkElem.appendChild( pkAttributeElem );
1892 layerElem.appendChild( pkElem );
1898 layerElem.appendChild( attributesElem );
1905 if ( provider && provider->
name() ==
"wms" )
1908 QVariant wmsBackgroundLayer = currentLayer->
customProperty( QStringLiteral(
"WMSBackgroundLayer" ),
false );
1909 QDomElement wmsBackgroundLayerElem = doc.createElement(
"WMSBackgroundLayer" );
1910 QDomText wmsBackgroundLayerText = doc.createTextNode( wmsBackgroundLayer.toBool() ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
1911 wmsBackgroundLayerElem.appendChild( wmsBackgroundLayerText );
1912 layerElem.appendChild( wmsBackgroundLayerElem );
1915 QVariant wmsPublishDataSourceUrl = currentLayer->
customProperty( QStringLiteral(
"WMSPublishDataSourceUrl" ),
false );
1916 if ( wmsPublishDataSourceUrl.toBool() )
1919 ? !qobject_cast< const QgsRasterDataProvider * >( provider )->
nativeResolutions().isEmpty()
1922 QDomElement dataSourceElem = doc.createElement( tiled ? QStringLiteral(
"WMTSDataSource" ) : QStringLiteral(
"WMSDataSource" ) );
1923 QDomText dataSourceUri = doc.createTextNode( provider->
dataSourceUri() );
1924 dataSourceElem.appendChild( dataSourceUri );
1925 layerElem.appendChild( dataSourceElem );
1929 QVariant wmsPrintLayer = currentLayer->
customProperty( QStringLiteral(
"WMSPrintLayer" ) );
1930 if ( wmsPrintLayer.isValid() )
1932 QDomElement wmsPrintLayerElem = doc.createElement(
"WMSPrintLayer" );
1933 QDomText wmsPrintLayerText = doc.createTextNode( wmsPrintLayer.toString() );
1934 wmsPrintLayerElem.appendChild( wmsPrintLayerText );
1935 layerElem.appendChild( wmsPrintLayerElem );
1946 void addKeywordListElement(
const QgsProject *project, QDomDocument &doc, QDomElement &parent )
1950 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"KeywordList" ) );
1952 QDomElement keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1953 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"ISO" ) );
1954 QDomText keywordText = doc.createTextNode( QStringLiteral(
"infoMapAccessService" ) );
1955 keywordElem.appendChild( keywordText );
1956 keywordsElem.appendChild( keywordElem );
1957 parent.appendChild( keywordsElem );
1959 for (
const QString &keyword : qgis::as_const( keywords ) )
1961 if ( !keyword.isEmpty() )
1963 keywordElem = doc.createElement( QStringLiteral(
"Keyword" ) );
1964 keywordText = doc.createTextNode( keyword );
1965 keywordElem.appendChild( keywordText );
1968 keywordElem.setAttribute( QStringLiteral(
"vocabulary" ), QStringLiteral(
"SIA_Geo405" ) );
1970 keywordsElem.appendChild( keywordElem );
1973 parent.appendChild( keywordsElem );
1981 for (
int j = 0; j < childNode->
children().size(); ++j )
1991 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.
QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
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.
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.
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...
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.
const QString GEO_EPSG_CRS_AUTHID
Geographic coord sys from EPSG authority.
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.
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 compositions within the project.
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).
QgsVectorLayerServerProperties * serverProperties()
Returns QGIS Server Properties of the vector layer.
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.
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.
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.
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.