35#ifdef HAVE_SERVER_PYTHON_PLUGINS
39 const QDomDocument *capabilitiesDocument =
nullptr;
41#ifdef HAVE_SERVER_PYTHON_PLUGINS
43 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
45 capabilitiesDocument = &doc;
55 capabilitiesDocument = &doc;
59 capabilitiesDocument = &doc;
61 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
62 response.
write( capabilitiesDocument->toByteArray() );
74 QDomElement wcsCapabilitiesElement = doc.createElement( QStringLiteral(
"WCS_Capabilities" ) );
75 wcsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns" ),
WCS_NAMESPACE );
76 wcsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
77 wcsCapabilitiesElement.setAttribute( QStringLiteral(
"xsi:schemaLocation" ),
WCS_NAMESPACE +
" http://schemas.opengis.net/wcs/1.0.0/wcsCapabilities.xsd" );
78 wcsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:gml" ),
GML_NAMESPACE );
79 wcsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
81 wcsCapabilitiesElement.setAttribute( QStringLiteral(
"updateSequence" ), QStringLiteral(
"0" ) );
82 doc.appendChild( wcsCapabilitiesElement );
88 QDomElement capabilityElement = doc.createElement( QStringLiteral(
"Capability" ) );
89 wcsCapabilitiesElement.appendChild( capabilityElement );
92 QDomElement requestElement = doc.createElement( QStringLiteral(
"Request" ) );
93 capabilityElement.appendChild( requestElement );
96 QDomElement getCapabilitiesElement = doc.createElement( QStringLiteral(
"GetCapabilities" ) );
97 requestElement.appendChild( getCapabilitiesElement );
99 QDomElement dcpTypeElement = doc.createElement( QStringLiteral(
"DCPType" ) );
100 getCapabilitiesElement.appendChild( dcpTypeElement );
101 QDomElement httpElement = doc.createElement( QStringLiteral(
"HTTP" ) );
102 dcpTypeElement.appendChild( httpElement );
107 QDomElement getElement = doc.createElement( QStringLiteral(
"Get" ) );
108 httpElement.appendChild( getElement );
109 QDomElement onlineResourceElement = doc.createElement( QStringLiteral(
"OnlineResource" ) );
110 onlineResourceElement.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
111 onlineResourceElement.setAttribute( QStringLiteral(
"xlink:href" ), hrefString );
112 getElement.appendChild( onlineResourceElement );
114 const QDomElement getCapabilitiesDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
115 getCapabilitiesDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
116 getCapabilitiesElement.appendChild( getCapabilitiesDhcTypePostElement );
118 QDomElement describeCoverageElement = getCapabilitiesElement.cloneNode().toElement();
119 describeCoverageElement.setTagName( QStringLiteral(
"DescribeCoverage" ) );
120 requestElement.appendChild( describeCoverageElement );
122 QDomElement getCoverageElement = getCapabilitiesElement.cloneNode().toElement();
123 getCoverageElement.setTagName( QStringLiteral(
"GetCoverage" ) );
124 requestElement.appendChild( getCoverageElement );
136 QDomElement serviceElem = doc.createElement( QStringLiteral(
"Service" ) );
139 QDomElement nameElem = doc.createElement( QStringLiteral(
"name" ) );
140 const QDomText nameText = doc.createTextNode(
"WCS" );
141 nameElem.appendChild( nameText );
142 serviceElem.appendChild( nameElem );
145 QDomElement titleElem = doc.createElement( QStringLiteral(
"label" ) );
146 const QDomText titleText = doc.createTextNode( title );
147 titleElem.appendChild( titleText );
148 serviceElem.appendChild( titleElem );
151 if ( !abstract.isEmpty() )
153 QDomElement abstractElem = doc.createElement( QStringLiteral(
"description" ) );
154 const QDomText abstractText = doc.createCDATASection( abstract );
155 abstractElem.appendChild( abstractText );
156 serviceElem.appendChild( abstractElem );
160 if ( !keywords.isEmpty() )
162 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"keywords" ) );
163 for (
int i = 0; i < keywords.size(); ++i )
165 QDomElement keywordElem = doc.createElement( QStringLiteral(
"keyword" ) );
166 const QDomText keywordText = doc.createTextNode( keywords.at( i ) );
167 keywordElem.appendChild( keywordText );
168 keywordsElem.appendChild( keywordElem );
170 serviceElem.appendChild( keywordsElem );
180 if ( !contactPerson.isEmpty() ||
181 !contactOrganization.isEmpty() ||
182 !contactPosition.isEmpty() ||
183 !contactMail.isEmpty() ||
184 !contactPhone.isEmpty() ||
185 !onlineResource.isEmpty() )
187 QDomElement responsiblePartyElem = doc.createElement( QStringLiteral(
"responsibleParty" ) );
188 if ( !contactPerson.isEmpty() )
190 QDomElement contactPersonElem = doc.createElement( QStringLiteral(
"individualName" ) );
191 const QDomText contactPersonText = doc.createTextNode( contactPerson );
192 contactPersonElem.appendChild( contactPersonText );
193 responsiblePartyElem.appendChild( contactPersonElem );
195 if ( !contactOrganization.isEmpty() )
197 QDomElement contactOrganizationElem = doc.createElement( QStringLiteral(
"organisationName" ) );
198 const QDomText contactOrganizationText = doc.createTextNode( contactOrganization );
199 contactOrganizationElem.appendChild( contactOrganizationText );
200 responsiblePartyElem.appendChild( contactOrganizationElem );
202 if ( !contactPosition.isEmpty() )
204 QDomElement contactPositionElem = doc.createElement( QStringLiteral(
"positionName" ) );
205 const QDomText contactPositionText = doc.createTextNode( contactPosition );
206 contactPositionElem.appendChild( contactPositionText );
207 responsiblePartyElem.appendChild( contactPositionElem );
209 if ( !contactMail.isEmpty() ||
210 !contactPhone.isEmpty() ||
211 !onlineResource.isEmpty() )
213 QDomElement contactInfoElem = doc.createElement( QStringLiteral(
"contactInfo" ) );
214 if ( !contactMail.isEmpty() )
216 QDomElement contactAddressElem = doc.createElement( QStringLiteral(
"address" ) );
217 QDomElement contactAddressMailElem = doc.createElement( QStringLiteral(
"electronicMailAddress" ) );
218 const QDomText contactAddressMailText = doc.createTextNode( contactMail );
219 contactAddressMailElem.appendChild( contactAddressMailText );
220 contactAddressElem.appendChild( contactAddressMailElem );
221 contactInfoElem.appendChild( contactAddressElem );
223 if ( !contactPhone.isEmpty() )
225 QDomElement contactPhoneElem = doc.createElement( QStringLiteral(
"phone" ) );
226 QDomElement contactVoiceElem = doc.createElement( QStringLiteral(
"voice" ) );
227 const QDomText contactVoiceText = doc.createTextNode( contactPhone );
228 contactVoiceElem.appendChild( contactVoiceText );
229 contactPhoneElem.appendChild( contactVoiceElem );
230 contactInfoElem.appendChild( contactPhoneElem );
232 if ( !onlineResource.isEmpty() )
234 QDomElement onlineResourceElem = doc.createElement( QStringLiteral(
"onlineResource" ) );
235 onlineResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
236 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
237 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), onlineResource );
238 contactInfoElem.appendChild( onlineResourceElem );
240 responsiblePartyElem.appendChild( contactInfoElem );
242 serviceElem.appendChild( responsiblePartyElem );
245 QDomElement feesElem = doc.createElement( QStringLiteral(
"fees" ) );
246 QDomText feesText = doc.createTextNode( QStringLiteral(
"None" ) );
248 if ( !fees.isEmpty() )
250 feesText = doc.createTextNode( fees );
252 feesElem.appendChild( feesText );
253 serviceElem.appendChild( feesElem );
255 QDomElement accessConstraintsElem = doc.createElement( QStringLiteral(
"accessConstraints" ) );
256 QDomText accessConstraintsText = doc.createTextNode( QStringLiteral(
"None" ) );
258 if ( !accessConstraints.isEmpty() )
260 accessConstraintsText = doc.createTextNode( accessConstraints );
262 accessConstraintsElem.appendChild( accessConstraintsText );
263 serviceElem.appendChild( accessConstraintsElem );
271#ifdef HAVE_SERVER_PYTHON_PLUGINS
279 QDomElement contentMetadataElement = doc.createElement( QStringLiteral(
"ContentMetadata" ) );
282 for (
int i = 0; i < wcsLayersId.size(); ++i )
289 if ( layer->
type() != Qgis::LayerType::Raster )
293#ifdef HAVE_SERVER_PYTHON_PLUGINS
303 contentMetadataElement.appendChild( layerElem );
307 return contentMetadataElement;
A helper class that centralizes restrictions given by all the access control filter plugins.
bool layerReadPermission(const QgsMapLayer *layer) const
Returns the layer read right.
Base class for all map layer types.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
Represents a raster layer.
A helper class that centralizes caches accesses given by all the server cache filter plugins.
bool setCachedDocument(const QDomDocument *doc, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Updates or inserts the document in cache like capabilities.
bool getCachedDocument(QDomDocument *doc, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Returns cached document (or 0 if document not in cache) like capabilities.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
virtual QgsServerCacheManager * cacheManager() const =0
Gets the registered server cache filters.
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
virtual QgsServerSettings * serverSettings()=0
Returns the server settings.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device.
virtual void setHeader(const QString &key, const QString &value)=0
Set Header entry Add Header entry to the response Note that it is usually an error to set Header afte...
SERVER_EXPORT QString owsServiceAccessConstraints(const QgsProject &project)
Returns the owsService access constraints defined in project.
SERVER_EXPORT QString owsServiceOnlineResource(const QgsProject &project)
Returns the owsService online resource defined in project.
SERVER_EXPORT QString owsServiceFees(const QgsProject &project)
Returns the owsService fees defined in project.
SERVER_EXPORT QStringList owsServiceKeywords(const QgsProject &project)
Returns the owsService keywords defined in project.
SERVER_EXPORT QString owsServiceContactPosition(const QgsProject &project)
Returns the owsService contact position defined in project.
SERVER_EXPORT QString owsServiceContactOrganization(const QgsProject &project)
Returns the owsService contact organization defined in project.
SERVER_EXPORT QString owsServiceTitle(const QgsProject &project)
Returns the owsService title defined in project.
SERVER_EXPORT QString owsServiceContactMail(const QgsProject &project)
Returns the owsService contact mail defined in project.
SERVER_EXPORT QString owsServiceAbstract(const QgsProject &project)
Returns the owsService abstract defined in project.
SERVER_EXPORT QStringList wcsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WCS.
SERVER_EXPORT QString owsServiceContactPhone(const QgsProject &project)
Returns the owsService contact phone defined in project.
SERVER_EXPORT QString owsServiceContactPerson(const QgsProject &project)
Returns the owsService contact person defined in project.
QDomDocument createGetCapabilitiesDocument(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request)
Create get capabilities document.
QDomElement getCoverageOffering(QDomDocument &doc, const QgsRasterLayer *layer, const QgsProject *project, bool brief)
CoverageOffering or CoverageOfferingBrief element.
QString implementationVersion()
Returns the highest version supported by this implementation.
const QString WCS_NAMESPACE
const QString GML_NAMESPACE
QString serviceUrl(const QgsServerRequest &request, const QgsProject *project, const QgsServerSettings &settings)
Service URL string.
QDomElement getServiceElement(QDomDocument &doc, const QgsProject *project)
Create Service element for get capabilities document.
QDomElement getContentMetadataElement(QDomDocument &doc, QgsServerInterface *serverIface, const QgsProject *project)
Create ContentMetadata element for get capabilities document.
void writeGetCapabilities(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output WCS GetCapabilities response.