33 #include <QStringList> 46 #ifdef HAVE_SERVER_PYTHON_PLUGINS 50 const QDomDocument *capabilitiesDocument =
nullptr;
52 #ifdef HAVE_SERVER_PYTHON_PLUGINS 54 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
56 capabilitiesDocument = &doc;
66 capabilitiesDocument = &doc;
70 capabilitiesDocument = &doc;
72 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
73 response.
write( capabilitiesDocument->toByteArray() );
85 QDomElement wfsCapabilitiesElement = doc.createElement( QStringLiteral(
"WFS_Capabilities" ) );
86 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns" ),
WFS_NAMESPACE );
87 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
88 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xsi:schemaLocation" ),
WFS_NAMESPACE +
" http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd" );
89 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:ogc" ),
OGC_NAMESPACE );
90 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:gml" ),
GML_NAMESPACE );
91 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:ows" ), QStringLiteral(
"http://www.opengis.net/ows" ) );
92 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
93 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0.0" ) );
94 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"updateSequence" ), QStringLiteral(
"0" ) );
95 doc.appendChild( wfsCapabilitiesElement );
110 QDomElement filterCapabilitiesElement = doc.createElement( QStringLiteral(
"ogc:Filter_Capabilities" ) );
111 wfsCapabilitiesElement.appendChild( filterCapabilitiesElement );
112 QDomElement spatialCapabilitiesElement = doc.createElement( QStringLiteral(
"ogc:Spatial_Capabilities" ) );
113 filterCapabilitiesElement.appendChild( spatialCapabilitiesElement );
114 QDomElement spatialOperatorsElement = doc.createElement( QStringLiteral(
"ogc:Spatial_Operators" ) );
115 spatialCapabilitiesElement.appendChild( spatialOperatorsElement );
116 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:BBOX" ) ) );
117 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Disjoint" ) ) );
118 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Intersect" ) ) );
119 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Touches" ) ) );
120 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Crosses" ) ) );
121 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Contains" ) ) );
122 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Overlaps" ) ) );
123 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Within" ) ) );
124 QDomElement scalarCapabilitiesElement = doc.createElement( QStringLiteral(
"ogc:Scalar_Capabilities" ) );
125 filterCapabilitiesElement.appendChild( scalarCapabilitiesElement );
126 QDomElement comparisonOperatorsElement = doc.createElement( QStringLiteral(
"ogc:Comparison_Operators" ) );
127 scalarCapabilitiesElement.appendChild( comparisonOperatorsElement );
128 comparisonOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Simple_Comparisons" ) ) );
129 comparisonOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Between" ) ) );
130 comparisonOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Like" ) ) );
139 QDomElement serviceElem = doc.createElement( QStringLiteral(
"Service" ) );
142 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
143 QDomText nameText = doc.createTextNode(
"WFS" );
144 nameElem.appendChild( nameText );
145 serviceElem.appendChild( nameElem );
148 if ( !title.isEmpty() )
150 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
151 QDomText titleText = doc.createTextNode( title );
152 titleElem.appendChild( titleText );
153 serviceElem.appendChild( titleElem );
157 if ( !
abstract.isEmpty() )
159 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
160 QDomText abstractText = doc.createCDATASection(
abstract );
161 abstractElem.appendChild( abstractText );
162 serviceElem.appendChild( abstractElem );
166 if ( !keywords.isEmpty() && !keywords.join( QStringLiteral(
", " ) ).isEmpty() )
168 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"Keywords" ) );
169 QDomText keywordsText = doc.createTextNode( keywords.join( QStringLiteral(
", " ) ) );
170 keywordsElem.appendChild( keywordsText );
171 serviceElem.appendChild( keywordsElem );
174 QDomElement onlineResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
176 if ( !onlineResource.isEmpty() )
178 QDomText onlineResourceText = doc.createTextNode( onlineResource );
179 onlineResourceElem.appendChild( onlineResourceText );
181 serviceElem.appendChild( onlineResourceElem );
184 if ( !fees.isEmpty() )
186 QDomElement feesElem = doc.createElement( QStringLiteral(
"Fees" ) );
187 QDomText feesText = doc.createTextNode( fees );
188 feesElem.appendChild( feesText );
189 serviceElem.appendChild( feesElem );
193 if ( !accessConstraints.isEmpty() )
195 QDomElement accessConstraintsElem = doc.createElement( QStringLiteral(
"AccessConstraints" ) );
196 QDomText accessConstraintsText = doc.createTextNode( accessConstraints );
197 accessConstraintsElem.appendChild( accessConstraintsText );
198 serviceElem.appendChild( accessConstraintsElem );
208 QDomElement capabilityElement = doc.createElement( QStringLiteral(
"Capability" ) );
211 QDomElement requestElement = doc.createElement( QStringLiteral(
"Request" ) );
212 capabilityElement.appendChild( requestElement );
214 QDomElement getCapabilitiesElement = doc.createElement( QStringLiteral(
"GetCapabilities" ) );
215 requestElement.appendChild( getCapabilitiesElement );
217 QDomElement dcpTypeElement = doc.createElement( QStringLiteral(
"DCPType" ) );
218 getCapabilitiesElement.appendChild( dcpTypeElement );
219 QDomElement httpElement = doc.createElement( QStringLiteral(
"HTTP" ) );
220 dcpTypeElement.appendChild( httpElement );
223 QString hrefString =
serviceUrl( request, project );
226 QDomElement getElement = doc.createElement( QStringLiteral(
"Get" ) );
227 httpElement.appendChild( getElement );
228 getElement.setAttribute( QStringLiteral(
"onlineResource" ), hrefString );
229 QDomElement getCapabilitiesDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
230 getCapabilitiesDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
231 getCapabilitiesElement.appendChild( getCapabilitiesDhcTypePostElement );
234 QDomElement describeFeatureTypeElement = doc.createElement( QStringLiteral(
"DescribeFeatureType" ) );
235 requestElement.appendChild( describeFeatureTypeElement );
236 QDomElement schemaDescriptionLanguageElement = doc.createElement( QStringLiteral(
"SchemaDescriptionLanguage" ) );
237 describeFeatureTypeElement.appendChild( schemaDescriptionLanguageElement );
238 QDomElement xmlSchemaElement = doc.createElement( QStringLiteral(
"XMLSCHEMA" ) );
239 schemaDescriptionLanguageElement.appendChild( xmlSchemaElement );
240 QDomElement describeFeatureTypeDhcTypeElement = dcpTypeElement.cloneNode().toElement();
241 describeFeatureTypeElement.appendChild( describeFeatureTypeDhcTypeElement );
242 QDomElement describeFeatureTypeDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
243 describeFeatureTypeDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
244 describeFeatureTypeElement.appendChild( describeFeatureTypeDhcTypePostElement );
247 QDomElement getFeatureElement = doc.createElement( QStringLiteral(
"GetFeature" ) );
248 requestElement.appendChild( getFeatureElement );
249 QDomElement getFeatureFormatElement = doc.createElement( QStringLiteral(
"ResultFormat" ) );
250 getFeatureElement.appendChild( getFeatureFormatElement );
251 QDomElement gmlFormatElement = doc.createElement( QStringLiteral(
"GML2" ) );
252 getFeatureFormatElement.appendChild( gmlFormatElement );
253 QDomElement gml3FormatElement = doc.createElement( QStringLiteral(
"GML3" ) );
254 getFeatureFormatElement.appendChild( gml3FormatElement );
255 QDomElement geojsonFormatElement = doc.createElement( QStringLiteral(
"GeoJSON" ) );
256 getFeatureFormatElement.appendChild( geojsonFormatElement );
257 QDomElement getFeatureDhcTypeGetElement = dcpTypeElement.cloneNode().toElement();
258 getFeatureElement.appendChild( getFeatureDhcTypeGetElement );
259 QDomElement getFeatureDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
260 getFeatureDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
261 getFeatureElement.appendChild( getFeatureDhcTypePostElement );
264 QDomElement transactionElement = doc.createElement( QStringLiteral(
"Transaction" ) );
265 requestElement.appendChild( transactionElement );
266 QDomElement transactionDhcTypeElement = dcpTypeElement.cloneNode().toElement();
267 transactionDhcTypeElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
268 transactionElement.appendChild( transactionDhcTypeElement );
270 return capabilityElement;
275 #ifdef HAVE_SERVER_PYTHON_PLUGINS 282 QDomElement featureTypeListElement = doc.createElement( QStringLiteral(
"FeatureTypeList" ) );
284 QDomElement operationsElement = doc.createElement( QStringLiteral(
"Operations" ) );
285 featureTypeListElement.appendChild( operationsElement );
287 QDomElement queryElement = doc.createElement( QStringLiteral(
"Query" ) );
288 operationsElement.appendChild( queryElement );
294 for (
const QString &wfsLayerId : wfsLayerIds )
301 if ( layer->
type() != QgsMapLayer::LayerType::VectorLayer )
310 QDomElement layerElem = doc.createElement( QStringLiteral(
"FeatureType" ) );
313 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
317 typeName = typeName.replace( QLatin1String(
" " ), QLatin1String(
"_" ) );
318 QDomText nameText = doc.createTextNode( typeName );
319 nameElem.appendChild( nameText );
320 layerElem.appendChild( nameElem );
323 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
324 QString title = layer->
title();
325 if ( title.isEmpty() )
327 title = layer->
name();
329 QDomText titleText = doc.createTextNode( title );
330 titleElem.appendChild( titleText );
331 layerElem.appendChild( titleElem );
334 QString
abstract = layer->
abstract();
335 if ( !
abstract.isEmpty() )
337 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
338 QDomText abstractText = doc.createTextNode(
abstract );
339 abstractElem.appendChild( abstractText );
340 layerElem.appendChild( abstractElem );
345 if ( !keywords.isEmpty() )
347 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"Keywords" ) );
348 QDomText keywordsText = doc.createTextNode( keywords );
349 keywordsElem.appendChild( keywordsText );
350 layerElem.appendChild( keywordsElem );
354 QDomElement srsElem = doc.createElement( QStringLiteral(
"SRS" ) );
355 QDomText srsText = doc.createTextNode( layer->
crs().
authid() );
356 srsElem.appendChild( srsText );
357 layerElem.appendChild( srsElem );
368 QDomElement bBoxElement = doc.createElement( QStringLiteral(
"LatLongBoundingBox" ) );
373 layerElem.appendChild( bBoxElement );
377 if ( !metadataUrl.isEmpty() )
379 QDomElement metaUrlElem = doc.createElement( QStringLiteral(
"MetadataURL" ) );
381 metaUrlElem.setAttribute( QStringLiteral(
"type" ), metadataUrlType );
383 if ( metadataUrlFormat == QLatin1String(
"text/xml" ) )
385 metaUrlElem.setAttribute( QStringLiteral(
"format" ), QStringLiteral(
"XML" ) );
389 metaUrlElem.setAttribute( QStringLiteral(
"format" ), QStringLiteral(
"TXT" ) );
391 QDomText metaUrlText = doc.createTextNode( metadataUrl );
392 metaUrlElem.appendChild( metaUrlText );
393 layerElem.appendChild( metaUrlElem );
397 QDomElement operationsElement = doc.createElement( QStringLiteral(
"Operations" ) );
399 QDomElement queryElement = doc.createElement( QStringLiteral(
"Query" ) );
400 operationsElement.appendChild( queryElement );
401 if ( wfstUpdateLayersId.contains( layer->
id() ) ||
402 wfstInsertLayersId.contains( layer->
id() ) ||
403 wfstDeleteLayersId.contains( layer->
id() ) )
410 QDomElement insertElement = doc.createElement( QStringLiteral(
"Insert" ) );
411 operationsElement.appendChild( insertElement );
415 wfstUpdateLayersId.contains( layer->
id() ) )
418 QDomElement updateElement = doc.createElement( QStringLiteral(
"Update" ) );
419 operationsElement.appendChild( updateElement );
424 QDomElement deleteElement = doc.createElement( QStringLiteral(
"Delete" ) );
425 operationsElement.appendChild( deleteElement );
429 layerElem.appendChild( operationsElement );
431 featureTypeListElement.appendChild( layerElem );
434 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...
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.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
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 QStringList owsServiceKeywords(const QgsProject &project)
Returns the owsService keywords defined in project.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
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 title() const
Returns the title 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...
QString serviceUrl(const QgsServerRequest &request, const QgsProject *project)
Service URL string.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
virtual QgsRectangle extent() const
Returns the extent of the layer.
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 qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
SERVER_EXPORT double floorWithPrecision(double number, int places)
Returns a double less than number to the specified number of places.
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.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
Reads and writes project states.
QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request. ...
SERVER_EXPORT QString owsServiceFees(const QgsProject &project)
Returns the owsService fees defined in project.
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 QString owsServiceOnlineResource(const QgsProject &project)
Returns the owsService online resource defined in project.
const QString OGC_NAMESPACE
QString metadataUrl() const
Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins...
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
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.
QString metadataUrlType() const
Returns the metadata type of the layer used by QGIS Server in GetCapabilities request.
QString authid() const
Returns the authority identifier for the CRS.
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...
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...
Allows deletion of features.
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.
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
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.
bool isGeographic() const
Returns whether the CRS is a geographic CRS (using lat/lon coordinates)
double xMinimum() const
Returns the x minimum value (left side of rectangle).
Allows modification of attribute values.
QString metadataUrlFormat() const
Returns the metadata format of the layer used by QGIS Server in GetCapabilities request.
SERVER_EXPORT QString owsServiceTitle(const QgsProject &project)
Returns the owsService title defined in project.
QgsCoordinateReferenceSystem crs
bool layerReadPermission(const QgsMapLayer *layer) const
Returns the layer read right.