43 #ifdef HAVE_SERVER_PYTHON_PLUGINS 47 const QDomDocument *capabilitiesDocument =
nullptr;
50 #ifdef HAVE_SERVER_PYTHON_PLUGINS 53 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
55 capabilitiesDocument = &doc;
65 capabilitiesDocument = &doc;
68 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
69 response.
write( capabilitiesDocument->toByteArray() );
81 QDomElement wfsCapabilitiesElement = doc.createElement( QStringLiteral(
"WFS_Capabilities" ) );
82 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns" ),
WFS_NAMESPACE );
83 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
84 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xsi:schemaLocation" ),
WFS_NAMESPACE +
" http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd" );
85 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:ogc" ),
OGC_NAMESPACE );
86 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:gml" ),
GML_NAMESPACE );
87 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:ows" ), QStringLiteral(
"http://www.opengis.net/ows" ) );
88 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
89 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0.0" ) );
90 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"updateSequence" ), QStringLiteral(
"0" ) );
91 doc.appendChild( wfsCapabilitiesElement );
106 QDomElement filterCapabilitiesElement = doc.createElement( QStringLiteral(
"ogc:Filter_Capabilities" ) );
107 wfsCapabilitiesElement.appendChild( filterCapabilitiesElement );
108 QDomElement spatialCapabilitiesElement = doc.createElement( QStringLiteral(
"ogc:Spatial_Capabilities" ) );
109 filterCapabilitiesElement.appendChild( spatialCapabilitiesElement );
110 QDomElement spatialOperatorsElement = doc.createElement( QStringLiteral(
"ogc:Spatial_Operators" ) );
111 spatialCapabilitiesElement.appendChild( spatialOperatorsElement );
112 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:BBOX" ) ) );
113 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Disjoint" ) ) );
114 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Intersect" ) ) );
115 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Touches" ) ) );
116 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Crosses" ) ) );
117 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Contains" ) ) );
118 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Overlaps" ) ) );
119 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Within" ) ) );
120 QDomElement scalarCapabilitiesElement = doc.createElement( QStringLiteral(
"ogc:Scalar_Capabilities" ) );
121 filterCapabilitiesElement.appendChild( scalarCapabilitiesElement );
122 QDomElement comparisonOperatorsElement = doc.createElement( QStringLiteral(
"ogc:Comparison_Operators" ) );
123 scalarCapabilitiesElement.appendChild( comparisonOperatorsElement );
124 comparisonOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Simple_Comparisons" ) ) );
125 comparisonOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Between" ) ) );
126 comparisonOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Like" ) ) );
135 QDomElement serviceElem = doc.createElement( QStringLiteral(
"Service" ) );
138 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
139 QDomText nameText = doc.createTextNode(
"WFS" );
140 nameElem.appendChild( nameText );
141 serviceElem.appendChild( nameElem );
144 if ( !title.isEmpty() )
146 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
147 QDomText titleText = doc.createTextNode( title );
148 titleElem.appendChild( titleText );
149 serviceElem.appendChild( titleElem );
153 if ( !
abstract.isEmpty() )
155 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
156 QDomText abstractText = doc.createCDATASection(
abstract );
157 abstractElem.appendChild( abstractText );
158 serviceElem.appendChild( abstractElem );
162 if ( !keywords.isEmpty() && !keywords.join( QStringLiteral(
", " ) ).isEmpty() )
164 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"Keywords" ) );
165 QDomText keywordsText = doc.createTextNode( keywords.join( QStringLiteral(
", " ) ) );
166 keywordsElem.appendChild( keywordsText );
167 serviceElem.appendChild( keywordsElem );
170 QDomElement onlineResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
172 if ( !onlineResource.isEmpty() )
174 QDomText onlineResourceText = doc.createTextNode( onlineResource );
175 onlineResourceElem.appendChild( onlineResourceText );
177 serviceElem.appendChild( onlineResourceElem );
180 if ( !fees.isEmpty() )
182 QDomElement feesElem = doc.createElement( QStringLiteral(
"Fees" ) );
183 QDomText feesText = doc.createTextNode( fees );
184 feesElem.appendChild( feesText );
185 serviceElem.appendChild( feesElem );
189 if ( !accessConstraints.isEmpty() )
191 QDomElement accessConstraintsElem = doc.createElement( QStringLiteral(
"AccessConstraints" ) );
192 QDomText accessConstraintsText = doc.createTextNode( accessConstraints );
193 accessConstraintsElem.appendChild( accessConstraintsText );
194 serviceElem.appendChild( accessConstraintsElem );
204 QDomElement capabilityElement = doc.createElement( QStringLiteral(
"Capability" ) );
207 QDomElement requestElement = doc.createElement( QStringLiteral(
"Request" ) );
208 capabilityElement.appendChild( requestElement );
210 QDomElement getCapabilitiesElement = doc.createElement( QStringLiteral(
"GetCapabilities" ) );
211 requestElement.appendChild( getCapabilitiesElement );
213 QDomElement dcpTypeElement = doc.createElement( QStringLiteral(
"DCPType" ) );
214 getCapabilitiesElement.appendChild( dcpTypeElement );
215 QDomElement httpElement = doc.createElement( QStringLiteral(
"HTTP" ) );
216 dcpTypeElement.appendChild( httpElement );
219 QString hrefString =
serviceUrl( request, project );
222 QDomElement getElement = doc.createElement( QStringLiteral(
"Get" ) );
223 httpElement.appendChild( getElement );
224 getElement.setAttribute( QStringLiteral(
"onlineResource" ), hrefString );
225 QDomElement getCapabilitiesDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
226 getCapabilitiesDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
227 getCapabilitiesElement.appendChild( getCapabilitiesDhcTypePostElement );
230 QDomElement describeFeatureTypeElement = doc.createElement( QStringLiteral(
"DescribeFeatureType" ) );
231 requestElement.appendChild( describeFeatureTypeElement );
232 QDomElement schemaDescriptionLanguageElement = doc.createElement( QStringLiteral(
"SchemaDescriptionLanguage" ) );
233 describeFeatureTypeElement.appendChild( schemaDescriptionLanguageElement );
234 QDomElement xmlSchemaElement = doc.createElement( QStringLiteral(
"XMLSCHEMA" ) );
235 schemaDescriptionLanguageElement.appendChild( xmlSchemaElement );
236 QDomElement describeFeatureTypeDhcTypeElement = dcpTypeElement.cloneNode().toElement();
237 describeFeatureTypeElement.appendChild( describeFeatureTypeDhcTypeElement );
238 QDomElement describeFeatureTypeDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
239 describeFeatureTypeDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
240 describeFeatureTypeElement.appendChild( describeFeatureTypeDhcTypePostElement );
243 QDomElement getFeatureElement = doc.createElement( QStringLiteral(
"GetFeature" ) );
244 requestElement.appendChild( getFeatureElement );
245 QDomElement getFeatureFormatElement = doc.createElement( QStringLiteral(
"ResultFormat" ) );
246 getFeatureElement.appendChild( getFeatureFormatElement );
247 QDomElement gmlFormatElement = doc.createElement( QStringLiteral(
"GML2" ) );
248 getFeatureFormatElement.appendChild( gmlFormatElement );
249 QDomElement gml3FormatElement = doc.createElement( QStringLiteral(
"GML3" ) );
250 getFeatureFormatElement.appendChild( gml3FormatElement );
251 QDomElement geojsonFormatElement = doc.createElement( QStringLiteral(
"GeoJSON" ) );
252 getFeatureFormatElement.appendChild( geojsonFormatElement );
253 QDomElement getFeatureDhcTypeGetElement = dcpTypeElement.cloneNode().toElement();
254 getFeatureElement.appendChild( getFeatureDhcTypeGetElement );
255 QDomElement getFeatureDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
256 getFeatureDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
257 getFeatureElement.appendChild( getFeatureDhcTypePostElement );
260 QDomElement transactionElement = doc.createElement( QStringLiteral(
"Transaction" ) );
261 requestElement.appendChild( transactionElement );
262 QDomElement transactionDhcTypeElement = dcpTypeElement.cloneNode().toElement();
263 transactionDhcTypeElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
264 transactionElement.appendChild( transactionDhcTypeElement );
266 return capabilityElement;
274 QDomElement featureTypeListElement = doc.createElement( QStringLiteral(
"FeatureTypeList" ) );
276 QDomElement operationsElement = doc.createElement( QStringLiteral(
"Operations" ) );
277 featureTypeListElement.appendChild( operationsElement );
279 QDomElement queryElement = doc.createElement( QStringLiteral(
"Query" ) );
280 operationsElement.appendChild( queryElement );
286 for (
const QString &wfsLayerId : wfsLayerIds )
293 if ( layer->
type() != QgsMapLayer::LayerType::VectorLayer )
302 QDomElement layerElem = doc.createElement( QStringLiteral(
"FeatureType" ) );
305 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
309 typeName = typeName.replace( QLatin1String(
" " ), QLatin1String(
"_" ) );
310 QDomText nameText = doc.createTextNode( typeName );
311 nameElem.appendChild( nameText );
312 layerElem.appendChild( nameElem );
315 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
316 QString title = layer->
title();
317 if ( title.isEmpty() )
319 title = layer->
name();
321 QDomText titleText = doc.createTextNode( title );
322 titleElem.appendChild( titleText );
323 layerElem.appendChild( titleElem );
326 QString
abstract = layer->
abstract();
327 if ( !
abstract.isEmpty() )
329 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
330 QDomText abstractText = doc.createTextNode(
abstract );
331 abstractElem.appendChild( abstractText );
332 layerElem.appendChild( abstractElem );
337 if ( !keywords.isEmpty() )
339 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"Keywords" ) );
340 QDomText keywordsText = doc.createTextNode( keywords );
341 keywordsElem.appendChild( keywordsText );
342 layerElem.appendChild( keywordsElem );
346 QDomElement srsElem = doc.createElement( QStringLiteral(
"SRS" ) );
347 QDomText srsText = doc.createTextNode( layer->
crs().
authid() );
348 srsElem.appendChild( srsText );
349 layerElem.appendChild( srsElem );
353 QDomElement bBoxElement = doc.createElement( QStringLiteral(
"LatLongBoundingBox" ) );
354 bBoxElement.setAttribute( QStringLiteral(
"minx" ), QString::number( layerExtent.
xMinimum() ) );
355 bBoxElement.setAttribute( QStringLiteral(
"miny" ), QString::number( layerExtent.
yMinimum() ) );
356 bBoxElement.setAttribute( QStringLiteral(
"maxx" ), QString::number( layerExtent.
xMaximum() ) );
357 bBoxElement.setAttribute( QStringLiteral(
"maxy" ), QString::number( layerExtent.
yMaximum() ) );
358 layerElem.appendChild( bBoxElement );
362 if ( !metadataUrl.isEmpty() )
364 QDomElement metaUrlElem = doc.createElement( QStringLiteral(
"MetadataURL" ) );
366 metaUrlElem.setAttribute( QStringLiteral(
"type" ), metadataUrlType );
368 if ( metadataUrlFormat == QLatin1String(
"text/xml" ) )
370 metaUrlElem.setAttribute( QStringLiteral(
"format" ), QStringLiteral(
"XML" ) );
374 metaUrlElem.setAttribute( QStringLiteral(
"format" ), QStringLiteral(
"TXT" ) );
376 QDomText metaUrlText = doc.createTextNode( metadataUrl );
377 metaUrlElem.appendChild( metaUrlText );
378 layerElem.appendChild( metaUrlElem );
382 QDomElement operationsElement = doc.createElement( QStringLiteral(
"Operations" ) );
384 QDomElement queryElement = doc.createElement( QStringLiteral(
"Query" ) );
385 operationsElement.appendChild( queryElement );
386 if ( wfstUpdateLayersId.contains( layer->
id() ) ||
387 wfstInsertLayersId.contains( layer->
id() ) ||
388 wfstDeleteLayersId.contains( layer->
id() ) )
395 QDomElement insertElement = doc.createElement( QStringLiteral(
"Insert" ) );
396 operationsElement.appendChild( insertElement );
400 wfstUpdateLayersId.contains( layer->
id() ) )
403 QDomElement updateElement = doc.createElement( QStringLiteral(
"Update" ) );
404 operationsElement.appendChild( updateElement );
409 QDomElement deleteElement = doc.createElement( QStringLiteral(
"Delete" ) );
410 operationsElement.appendChild( deleteElement );
414 layerElem.appendChild( operationsElement );
416 featureTypeListElement.appendChild( layerElem );
419 return featureTypeListElement;
QDomElement getCapabilityElement(QDomDocument &doc, const QgsProject *project, const QgsServerRequest &request)
Create Capability element for get capabilities document.
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...
A rectangle specified with double values.
Base class for all map layer types.
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 owsServiceKeywords(const QgsProject &project)
Returns the owsService keywords defined in project.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
QDomDocument createGetCapabilitiesDocument(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request)
Create get capabilities document.
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. ...
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device...
QgsMapLayer::LayerType type() const
Returns the type of the layer.
virtual QgsRectangle extent() const
Returns the extent of the layer.
QString metadataUrlFormat() const
Returns the metadata format of the layer used by QGIS Server in GetCapabilities request.
QString serviceUrl(const QgsServerRequest &request, const QgsProject *project)
Service URL string.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
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...
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
const QString GML_NAMESPACE
void writeGetCapabilities(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output WFS GetCapabilities response.
const QString WFS_NAMESPACE
A helper class that centralizes caches accesses given by all the server cache filter plugins...
Allows modifications of geometries.
Reads and writes project states.
SERVER_EXPORT QString owsServiceFees(const QgsProject &project)
Returns the owsService fees defined in project.
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.
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.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
const QString OGC_NAMESPACE
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
bool layerReadPermission(const QgsMapLayer *layer) const
Returns the layer read right.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins...
QDomElement getServiceElement(QDomDocument &doc, const QgsProject *project)
Create Service element for get capabilities document.
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
bool setCachedDocument(const QDomDocument *doc, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Updates or inserts the document in cache like capabilities.
virtual QgsServerCacheManager * cacheManager() const =0
Gets the registered server cache filters.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
A helper class that centralizes restrictions given by all the access control filter plugins...
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
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...
QString metadataUrl() const
Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request.
Allows deletion of features.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be null.
QDomElement getFeatureTypeListElement(QDomDocument &doc, QgsServerInterface *serverIface, const QgsProject *project)
Create FeatureTypeList element for get capabilities document.
This is the base class for vector data providers.
Represents a vector layer which manages a vector based data sets.
Allows modification of attribute values.
QString authid() const
Returns the authority identifier for the CRS.
SERVER_EXPORT QString owsServiceTitle(const QgsProject &project)
Returns the owsService title defined in project.
QgsCoordinateReferenceSystem crs
QString metadataUrlType() const
Returns the metadata type of the layer used by QGIS Server in GetCapabilities request.