29 #include <QStringList> 40 #ifdef HAVE_SERVER_PYTHON_PLUGINS 44 const QDomDocument *capabilitiesDocument =
nullptr;
46 #ifdef HAVE_SERVER_PYTHON_PLUGINS 48 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
50 capabilitiesDocument = &doc;
60 capabilitiesDocument = &doc;
64 capabilitiesDocument = &doc;
66 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
67 response.
write( capabilitiesDocument->toByteArray() );
79 QDomElement wcsCapabilitiesElement = doc.createElement( QStringLiteral(
"WCS_Capabilities" ) );
80 wcsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns" ),
WCS_NAMESPACE );
81 wcsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
82 wcsCapabilitiesElement.setAttribute( QStringLiteral(
"xsi:schemaLocation" ),
WCS_NAMESPACE +
" http://schemas.opengis.net/wcs/1.0.0/wcsCapabilities.xsd" );
83 wcsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:gml" ),
GML_NAMESPACE );
84 wcsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
86 wcsCapabilitiesElement.setAttribute( QStringLiteral(
"updateSequence" ), QStringLiteral(
"0" ) );
87 doc.appendChild( wcsCapabilitiesElement );
93 QDomElement capabilityElement = doc.createElement( QStringLiteral(
"Capability" ) );
94 wcsCapabilitiesElement.appendChild( capabilityElement );
97 QDomElement requestElement = doc.createElement( QStringLiteral(
"Request" ) );
98 capabilityElement.appendChild( requestElement );
101 QDomElement getCapabilitiesElement = doc.createElement( QStringLiteral(
"GetCapabilities" ) );
102 requestElement.appendChild( getCapabilitiesElement );
104 QDomElement dcpTypeElement = doc.createElement( QStringLiteral(
"DCPType" ) );
105 getCapabilitiesElement.appendChild( dcpTypeElement );
106 QDomElement httpElement = doc.createElement( QStringLiteral(
"HTTP" ) );
107 dcpTypeElement.appendChild( httpElement );
110 QString hrefString =
serviceUrl( request, project );
112 QDomElement getElement = doc.createElement( QStringLiteral(
"Get" ) );
113 httpElement.appendChild( getElement );
114 QDomElement onlineResourceElement = doc.createElement( QStringLiteral(
"OnlineResource" ) );
115 onlineResourceElement.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
116 onlineResourceElement.setAttribute( QStringLiteral(
"xlink:href" ), hrefString );
117 getElement.appendChild( onlineResourceElement );
119 QDomElement getCapabilitiesDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
120 getCapabilitiesDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
121 getCapabilitiesElement.appendChild( getCapabilitiesDhcTypePostElement );
123 QDomElement describeCoverageElement = getCapabilitiesElement.cloneNode().toElement();
124 describeCoverageElement.setTagName( QStringLiteral(
"DescribeCoverage" ) );
125 requestElement.appendChild( describeCoverageElement );
127 QDomElement getCoverageElement = getCapabilitiesElement.cloneNode().toElement();
128 getCoverageElement.setTagName( QStringLiteral(
"GetCoverage" ) );
129 requestElement.appendChild( getCoverageElement );
141 QDomElement serviceElem = doc.createElement( QStringLiteral(
"Service" ) );
144 QDomElement nameElem = doc.createElement( QStringLiteral(
"name" ) );
145 QDomText nameText = doc.createTextNode(
"WCS" );
146 nameElem.appendChild( nameText );
147 serviceElem.appendChild( nameElem );
150 if ( !title.isEmpty() )
152 QDomElement titleElem = doc.createElement( QStringLiteral(
"label" ) );
153 QDomText titleText = doc.createTextNode( title );
154 titleElem.appendChild( titleText );
155 serviceElem.appendChild( titleElem );
159 if ( !
abstract.isEmpty() )
161 QDomElement abstractElem = doc.createElement( QStringLiteral(
"description" ) );
162 QDomText abstractText = doc.createCDATASection(
abstract );
163 abstractElem.appendChild( abstractText );
164 serviceElem.appendChild( abstractElem );
168 if ( !keywords.isEmpty() )
170 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"keywords" ) );
171 for (
int i = 0; i < keywords.size(); ++i )
173 QDomElement keywordElem = doc.createElement( QStringLiteral(
"keyword" ) );
174 QDomText keywordText = doc.createTextNode( keywords.at( i ) );
175 keywordElem.appendChild( keywordText );
176 keywordsElem.appendChild( keywordElem );
178 serviceElem.appendChild( keywordsElem );
188 if ( !contactPerson.isEmpty() ||
189 !contactOrganization.isEmpty() ||
190 !contactPosition.isEmpty() ||
191 !contactMail.isEmpty() ||
192 !contactPhone.isEmpty() ||
193 !onlineResource.isEmpty() )
195 QDomElement responsiblePartyElem = doc.createElement( QStringLiteral(
"responsibleParty" ) );
196 if ( !contactPerson.isEmpty() )
198 QDomElement contactPersonElem = doc.createElement( QStringLiteral(
"individualName" ) );
199 QDomText contactPersonText = doc.createTextNode( contactPerson );
200 contactPersonElem.appendChild( contactPersonText );
201 responsiblePartyElem.appendChild( contactPersonElem );
203 if ( !contactOrganization.isEmpty() )
205 QDomElement contactOrganizationElem = doc.createElement( QStringLiteral(
"organisationName" ) );
206 QDomText contactOrganizationText = doc.createTextNode( contactOrganization );
207 contactOrganizationElem.appendChild( contactOrganizationText );
208 responsiblePartyElem.appendChild( contactOrganizationElem );
210 if ( !contactPosition.isEmpty() )
212 QDomElement contactPositionElem = doc.createElement( QStringLiteral(
"positionName" ) );
213 QDomText contactPositionText = doc.createTextNode( contactPosition );
214 contactPositionElem.appendChild( contactPositionText );
215 responsiblePartyElem.appendChild( contactPositionElem );
217 if ( !contactMail.isEmpty() ||
218 !contactPhone.isEmpty() ||
219 !onlineResource.isEmpty() )
221 QDomElement contactInfoElem = doc.createElement( QStringLiteral(
"contactInfo" ) );
222 if ( !contactMail.isEmpty() )
224 QDomElement contactAddressElem = doc.createElement( QStringLiteral(
"address" ) );
225 QDomElement contactAddressMailElem = doc.createElement( QStringLiteral(
"electronicMailAddress" ) );
226 QDomText contactAddressMailText = doc.createTextNode( contactMail );
227 contactAddressMailElem.appendChild( contactAddressMailText );
228 contactAddressElem.appendChild( contactAddressMailElem );
229 contactInfoElem.appendChild( contactAddressElem );
231 if ( !contactPhone.isEmpty() )
233 QDomElement contactPhoneElem = doc.createElement( QStringLiteral(
"phone" ) );
234 QDomElement contactVoiceElem = doc.createElement( QStringLiteral(
"voice" ) );
235 QDomText contactVoiceText = doc.createTextNode( contactPhone );
236 contactVoiceElem.appendChild( contactVoiceText );
237 contactPhoneElem.appendChild( contactVoiceElem );
238 contactInfoElem.appendChild( contactPhoneElem );
240 if ( !onlineResource.isEmpty() )
242 QDomElement onlineResourceElem = doc.createElement( QStringLiteral(
"onlineResource" ) );
243 onlineResourceElem.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
244 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
245 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), onlineResource );
246 contactInfoElem.appendChild( onlineResourceElem );
248 responsiblePartyElem.appendChild( contactInfoElem );
250 serviceElem.appendChild( responsiblePartyElem );
253 QDomElement feesElem = doc.createElement( QStringLiteral(
"fees" ) );
254 QDomText feesText = doc.createTextNode( QStringLiteral(
"None" ) );
256 if ( !fees.isEmpty() )
258 feesText = doc.createTextNode( fees );
260 feesElem.appendChild( feesText );
261 serviceElem.appendChild( feesElem );
263 QDomElement accessConstraintsElem = doc.createElement( QStringLiteral(
"accessConstraints" ) );
264 QDomText accessConstraintsText = doc.createTextNode( QStringLiteral(
"None" ) );
266 if ( !accessConstraints.isEmpty() )
268 accessConstraintsText = doc.createTextNode( accessConstraints );
270 accessConstraintsElem.appendChild( accessConstraintsText );
271 serviceElem.appendChild( accessConstraintsElem );
279 #ifdef HAVE_SERVER_PYTHON_PLUGINS 287 QDomElement contentMetadataElement = doc.createElement( QStringLiteral(
"ContentMetadata" ) );
290 for (
int i = 0; i < wcsLayersId.size(); ++i )
297 if ( layer->
type() != QgsMapLayer::LayerType::RasterLayer )
301 #ifdef HAVE_SERVER_PYTHON_PLUGINS 309 QDomElement layerElem =
getCoverageOffering( doc, const_cast<QgsRasterLayer *>( rLayer ), project,
true );
311 contentMetadataElement.appendChild( layerElem );
315 return contentMetadataElement;
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...
Base class for all map layer types.
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.
QgsMapLayer::LayerType type() const
Returns the type of the layer.
const QString WCS_NAMESPACE
bool setCachedDocument(const QDomDocument *doc, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Updates or inserts the document in cache like capabilities.
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.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
SERVER_EXPORT QString owsServiceAbstract(const QgsProject &project)
Returns the owsService abstract defined in project.
QString serviceUrl(const QgsServerRequest &request, const QgsProject *project)
Service URL string.
QDomDocument createGetCapabilitiesDocument(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request)
Create get capabilities document.
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device...
const QString GML_NAMESPACE
SERVER_EXPORT QStringList wcsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WCS.
A helper class that centralizes caches accesses given by all the server cache filter plugins...
Reads and writes project states.
SERVER_EXPORT QString owsServiceFees(const QgsProject &project)
Returns the owsService fees defined in project.
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 owsServiceContactOrganization(const QgsProject &project)
Returns the owsService contact organization defined in project.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
QDomElement getServiceElement(QDomDocument &doc, const QgsProject *project)
Create Service element for get capabilities document.
QString implementationVersion()
Returns the highest version supported by this implementation.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins...
QDomElement getCoverageOffering(QDomDocument &doc, const QgsRasterLayer *layer, const QgsProject *project, bool brief)
CoverageOffering or CoverageOfferingBrief element.
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
virtual QgsServerCacheManager * cacheManager() const =0
Gets the registered server cache filters.
A helper class that centralizes restrictions given by all the access control filter plugins...
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
SERVER_EXPORT QString owsServiceContactMail(const QgsProject &project)
Returns the owsService contact mail defined in project.
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.
SERVER_EXPORT QString owsServiceTitle(const QgsProject &project)
Returns the owsService title defined in project.
SERVER_EXPORT QString owsServiceContactPhone(const QgsProject &project)
Returns the owsService contact phone defined in project.
bool layerReadPermission(const QgsMapLayer *layer) const
Returns the layer read right.