41#ifdef HAVE_SERVER_PYTHON_PLUGINS
45 const QDomDocument *capabilitiesDocument =
nullptr;
47#ifdef HAVE_SERVER_PYTHON_PLUGINS
49 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
51 capabilitiesDocument = &doc;
61 capabilitiesDocument = &doc;
65 capabilitiesDocument = &doc;
67 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
68 response.
write( capabilitiesDocument->toByteArray() );
79 QDomElement wfsCapabilitiesElement = doc.createElement( QStringLiteral(
"WFS_Capabilities" ) );
80 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns" ),
WFS_NAMESPACE );
81 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
82 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xsi:schemaLocation" ),
WFS_NAMESPACE +
" http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd" );
83 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:ogc" ),
OGC_NAMESPACE );
84 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:gml" ),
GML_NAMESPACE );
85 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:ows" ), QStringLiteral(
"http://www.opengis.net/ows" ) );
86 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
87 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0.0" ) );
88 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"updateSequence" ), QStringLiteral(
"0" ) );
89 doc.appendChild( wfsCapabilitiesElement );
104 QDomElement filterCapabilitiesElement = doc.createElement( QStringLiteral(
"ogc:Filter_Capabilities" ) );
105 wfsCapabilitiesElement.appendChild( filterCapabilitiesElement );
106 QDomElement spatialCapabilitiesElement = doc.createElement( QStringLiteral(
"ogc:Spatial_Capabilities" ) );
107 filterCapabilitiesElement.appendChild( spatialCapabilitiesElement );
108 QDomElement spatialOperatorsElement = doc.createElement( QStringLiteral(
"ogc:Spatial_Operators" ) );
109 spatialCapabilitiesElement.appendChild( spatialOperatorsElement );
110 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:BBOX" ) ) );
111 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Disjoint" ) ) );
112 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Intersect" ) ) );
113 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Touches" ) ) );
114 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Crosses" ) ) );
115 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Contains" ) ) );
116 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Overlaps" ) ) );
117 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Within" ) ) );
118 QDomElement scalarCapabilitiesElement = doc.createElement( QStringLiteral(
"ogc:Scalar_Capabilities" ) );
119 filterCapabilitiesElement.appendChild( scalarCapabilitiesElement );
120 QDomElement comparisonOperatorsElement = doc.createElement( QStringLiteral(
"ogc:Comparison_Operators" ) );
121 scalarCapabilitiesElement.appendChild( comparisonOperatorsElement );
122 comparisonOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Simple_Comparisons" ) ) );
123 comparisonOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Between" ) ) );
124 comparisonOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Like" ) ) );
132 QDomElement serviceElem = doc.createElement( QStringLiteral(
"Service" ) );
135 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
136 const QDomText nameText = doc.createTextNode(
"WFS" );
137 nameElem.appendChild( nameText );
138 serviceElem.appendChild( nameElem );
141 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
142 const QDomText titleText = doc.createTextNode( title );
143 titleElem.appendChild( titleText );
144 serviceElem.appendChild( titleElem );
147 if ( !abstract.isEmpty() )
149 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
150 const QDomText abstractText = doc.createCDATASection( abstract );
151 abstractElem.appendChild( abstractText );
152 serviceElem.appendChild( abstractElem );
156 if ( !keywords.isEmpty() && !keywords.join( QLatin1String(
", " ) ).isEmpty() )
158 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"Keywords" ) );
159 const QDomText keywordsText = doc.createTextNode( keywords.join( QLatin1String(
", " ) ) );
160 keywordsElem.appendChild( keywordsText );
161 serviceElem.appendChild( keywordsElem );
164 QDomElement onlineResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
166 if ( !onlineResource.isEmpty() )
168 const QDomText onlineResourceText = doc.createTextNode( onlineResource );
169 onlineResourceElem.appendChild( onlineResourceText );
171 serviceElem.appendChild( onlineResourceElem );
174 if ( !fees.isEmpty() )
176 QDomElement feesElem = doc.createElement( QStringLiteral(
"Fees" ) );
177 const QDomText feesText = doc.createTextNode( fees );
178 feesElem.appendChild( feesText );
179 serviceElem.appendChild( feesElem );
183 if ( !accessConstraints.isEmpty() )
185 QDomElement accessConstraintsElem = doc.createElement( QStringLiteral(
"AccessConstraints" ) );
186 const QDomText accessConstraintsText = doc.createTextNode( accessConstraints );
187 accessConstraintsElem.appendChild( accessConstraintsText );
188 serviceElem.appendChild( accessConstraintsElem );
197 QDomElement capabilityElement = doc.createElement( QStringLiteral(
"Capability" ) );
200 QDomElement requestElement = doc.createElement( QStringLiteral(
"Request" ) );
201 capabilityElement.appendChild( requestElement );
203 QDomElement getCapabilitiesElement = doc.createElement( QStringLiteral(
"GetCapabilities" ) );
204 requestElement.appendChild( getCapabilitiesElement );
206 QDomElement dcpTypeElement = doc.createElement( QStringLiteral(
"DCPType" ) );
207 getCapabilitiesElement.appendChild( dcpTypeElement );
208 QDomElement httpElement = doc.createElement( QStringLiteral(
"HTTP" ) );
209 dcpTypeElement.appendChild( httpElement );
212 const QString hrefString =
serviceUrl( request, project, *settings );
215 QDomElement getElement = doc.createElement( QStringLiteral(
"Get" ) );
216 httpElement.appendChild( getElement );
217 getElement.setAttribute( QStringLiteral(
"onlineResource" ), hrefString );
218 const QDomElement getCapabilitiesDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
219 getCapabilitiesDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
220 getCapabilitiesElement.appendChild( getCapabilitiesDhcTypePostElement );
223 QDomElement describeFeatureTypeElement = doc.createElement( QStringLiteral(
"DescribeFeatureType" ) );
224 requestElement.appendChild( describeFeatureTypeElement );
225 QDomElement schemaDescriptionLanguageElement = doc.createElement( QStringLiteral(
"SchemaDescriptionLanguage" ) );
226 describeFeatureTypeElement.appendChild( schemaDescriptionLanguageElement );
227 const QDomElement xmlSchemaElement = doc.createElement( QStringLiteral(
"XMLSCHEMA" ) );
228 schemaDescriptionLanguageElement.appendChild( xmlSchemaElement );
229 const QDomElement describeFeatureTypeDhcTypeElement = dcpTypeElement.cloneNode().toElement();
230 describeFeatureTypeElement.appendChild( describeFeatureTypeDhcTypeElement );
231 const QDomElement describeFeatureTypeDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
232 describeFeatureTypeDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
233 describeFeatureTypeElement.appendChild( describeFeatureTypeDhcTypePostElement );
236 QDomElement getFeatureElement = doc.createElement( QStringLiteral(
"GetFeature" ) );
237 requestElement.appendChild( getFeatureElement );
238 QDomElement getFeatureFormatElement = doc.createElement( QStringLiteral(
"ResultFormat" ) );
239 getFeatureElement.appendChild( getFeatureFormatElement );
240 const QDomElement gmlFormatElement = doc.createElement( QStringLiteral(
"GML2" ) );
241 getFeatureFormatElement.appendChild( gmlFormatElement );
242 const QDomElement gml3FormatElement = doc.createElement( QStringLiteral(
"GML3" ) );
243 getFeatureFormatElement.appendChild( gml3FormatElement );
244 const QDomElement geojsonFormatElement = doc.createElement( QStringLiteral(
"GeoJSON" ) );
245 getFeatureFormatElement.appendChild( geojsonFormatElement );
246 const QDomElement getFeatureDhcTypeGetElement = dcpTypeElement.cloneNode().toElement();
247 getFeatureElement.appendChild( getFeatureDhcTypeGetElement );
248 const QDomElement getFeatureDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
249 getFeatureDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
250 getFeatureElement.appendChild( getFeatureDhcTypePostElement );
253 QDomElement transactionElement = doc.createElement( QStringLiteral(
"Transaction" ) );
254 requestElement.appendChild( transactionElement );
255 const QDomElement transactionDhcTypeElement = dcpTypeElement.cloneNode().toElement();
256 transactionDhcTypeElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
257 transactionElement.appendChild( transactionDhcTypeElement );
259 return capabilityElement;
264#ifdef HAVE_SERVER_PYTHON_PLUGINS
267 ( void ) serverIface;
271 QDomElement featureTypeListElement = doc.createElement( QStringLiteral(
"FeatureTypeList" ) );
273 QDomElement operationsElement = doc.createElement( QStringLiteral(
"Operations" ) );
274 featureTypeListElement.appendChild( operationsElement );
276 const QDomElement queryElement = doc.createElement( QStringLiteral(
"Query" ) );
277 operationsElement.appendChild( queryElement );
283 for (
const QString &wfsLayerId : wfsLayerIds )
294#ifdef HAVE_SERVER_PYTHON_PLUGINS
300 QDomElement layerElem = doc.createElement( QStringLiteral(
"FeatureType" ) );
303 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
308 const QDomText nameText = doc.createTextNode(
typeName );
309 nameElem.appendChild( nameText );
310 layerElem.appendChild( nameElem );
313 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
315 if ( title.isEmpty() )
317 title = layer->
name();
319 const QDomText titleText = doc.createTextNode( title );
320 titleElem.appendChild( titleText );
321 layerElem.appendChild( titleElem );
325 if ( !abstract.isEmpty() )
327 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
328 const QDomText abstractText = doc.createTextNode( abstract );
329 abstractElem.appendChild( abstractText );
330 layerElem.appendChild( abstractElem );
335 if ( !keywords.isEmpty() )
337 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"Keywords" ) );
338 const QDomText keywordsText = doc.createTextNode( keywords );
339 keywordsElem.appendChild( keywordsText );
340 layerElem.appendChild( keywordsElem );
344 QDomElement srsElem = doc.createElement( QStringLiteral(
"SRS" ) );
345 const QDomText srsText = doc.createTextNode( layer->
crs().
authid() );
346 srsElem.appendChild( srsText );
347 layerElem.appendChild( srsElem );
358 QDomElement bBoxElement = doc.createElement( QStringLiteral(
"LatLongBoundingBox" ) );
363 layerElem.appendChild( bBoxElement );
369 QDomElement metaUrlElem = doc.createElement( QStringLiteral(
"MetadataURL" ) );
370 const QString metadataUrlType = url.type;
371 metaUrlElem.setAttribute( QStringLiteral(
"type" ), metadataUrlType );
372 const QString metadataUrlFormat = url.format;
373 if ( metadataUrlFormat == QLatin1String(
"text/xml" ) )
375 metaUrlElem.setAttribute( QStringLiteral(
"format" ), QStringLiteral(
"XML" ) );
379 metaUrlElem.setAttribute( QStringLiteral(
"format" ), QStringLiteral(
"TXT" ) );
381 const QDomText metaUrlText = doc.createTextNode( url.url );
382 metaUrlElem.appendChild( metaUrlText );
383 layerElem.appendChild( metaUrlElem );
387 QDomElement operationsElement = doc.createElement( QStringLiteral(
"Operations" ) );
389 const QDomElement queryElement = doc.createElement( QStringLiteral(
"Query" ) );
390 operationsElement.appendChild( queryElement );
391 if ( wfstUpdateLayersId.contains( layer->
id() ) || wfstInsertLayersId.contains( layer->
id() ) || wfstDeleteLayersId.contains( layer->
id() ) )
398 const QDomElement insertElement = doc.createElement( QStringLiteral(
"Insert" ) );
399 operationsElement.appendChild( insertElement );
404 const QDomElement updateElement = doc.createElement( QStringLiteral(
"Update" ) );
405 operationsElement.appendChild( updateElement );
410 const QDomElement deleteElement = doc.createElement( QStringLiteral(
"Delete" ) );
411 operationsElement.appendChild( deleteElement );
415 layerElem.appendChild( operationsElement );
417 featureTypeListElement.appendChild( layerElem );
420 return featureTypeListElement;
@ AddFeatures
Allows adding features.
@ ChangeGeometries
Allows modifications of geometries.
@ DeleteFeatures
Allows deletion of features.
@ ChangeAttributeValues
Allows modification of attribute values.
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.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
QString keywordList() const
Returns the keyword list of the layerused by QGIS Server in GetCapabilities request.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
QString abstract() const
Returns the abstract of the layerused by QGIS Server in GetCapabilities request.
Base class for all map layer types.
virtual QgsRectangle extent() const
Returns the extent of the layer.
QgsCoordinateReferenceSystem crs
QgsMapLayerServerProperties * serverProperties()
Returns QGIS Server Properties for the map layer.
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.
A rectangle specified with double values.
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...
Provides a way to retrieve settings by prioritizing according to environment variables,...
This is the base class for vector data providers.
virtual Q_INVOKABLE Qgis::VectorProviderCapabilities capabilities() const
Returns flags containing the supported capabilities.
Represents a vector layer which manages a vector based data sets.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
SERVER_EXPORT double ceilWithPrecision(double number, int places)
Returns a double greater than number to the specified number of places.
SERVER_EXPORT QString owsServiceAccessConstraints(const QgsProject &project)
Returns the owsService access constraints defined in project.
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
SERVER_EXPORT QString owsServiceOnlineResource(const QgsProject &project)
Returns the owsService online resource defined in project.
SERVER_EXPORT QString owsServiceFees(const QgsProject &project)
Returns the owsService fees defined in project.
SERVER_EXPORT QStringList owsServiceKeywords(const QgsProject &project)
Returns the owsService keywords defined in project.
SERVER_EXPORT QStringList wfstUpdateLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published as WFS-T with update capabilities.
SERVER_EXPORT QStringList wfstInsertLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published as WFS-T with insert capabilities.
SERVER_EXPORT QString owsServiceTitle(const QgsProject &project)
Returns the owsService title defined in project.
SERVER_EXPORT QString owsServiceAbstract(const QgsProject &project)
Returns the owsService abstract defined in project.
SERVER_EXPORT double floorWithPrecision(double number, int places)
Returns a double less than number to the specified number of places.
SERVER_EXPORT QStringList wfstDeleteLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published as WFS-T with delete capabilities.
void writeGetCapabilities(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output WFS GetCapabilities response.
QDomElement getFeatureTypeListElement(QDomDocument &doc, QgsServerInterface *serverIface, const QgsProject *project)
Create FeatureTypeList element for get capabilities document.
QDomDocument createGetCapabilitiesDocument(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request)
Create get capabilities document.
QDomElement getCapabilityElement(QDomDocument &doc, const QgsProject *project, const QgsServerRequest &request, const QgsServerSettings *settings)
Create Capability element for get capabilities document.
QDomElement getServiceElement(QDomDocument &doc, const QgsProject *project)
Create Service element for get capabilities document.
QString serviceUrl(const QgsServerRequest &request, const QgsProject *project, const QgsServerSettings &settings)
Service URL string.
const QString OGC_NAMESPACE
const QString GML_NAMESPACE
const QString WFS_NAMESPACE
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.