33using namespace Qt::StringLiterals;
38 : wfsParameters( wfsParams )
43#ifdef HAVE_SERVER_PYTHON_PLUGINS
47 const QDomDocument *describeDocument =
nullptr;
49#ifdef HAVE_SERVER_PYTHON_PLUGINS
51 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
53 describeDocument = &doc;
57 doc = createDescribeFeatureTypeDocument( serverIface, project, version, request );
63 describeDocument = &doc;
66 doc = createDescribeFeatureTypeDocument( serverIface, project, version, request );
67 describeDocument = &doc;
69 response.
setHeader(
"Content-Type",
"text/xml; charset=utf-8" );
70 response.
write( describeDocument->toByteArray() );
80#ifdef HAVE_SERVER_PYTHON_PLUGINS
89 QDomElement schemaElement = doc.createElement( u
"schema"_s );
90 schemaElement.setAttribute( u
"xmlns"_s, u
"http://www.w3.org/2001/XMLSchema"_s );
91 schemaElement.setAttribute( u
"xmlns:xsd"_s, u
"http://www.w3.org/2001/XMLSchema"_s );
95 schemaElement.setAttribute( u
"targetNamespace"_s,
QGS_NAMESPACE );
96 schemaElement.setAttribute( u
"elementFormDefault"_s, u
"qualified"_s );
97 schemaElement.setAttribute( u
"version"_s, u
"1.0"_s );
98 doc.appendChild( schemaElement );
101 QDomElement importElement = doc.createElement( u
"import"_s );
104 importElement.setAttribute( u
"schemaLocation"_s, u
"http://schemas.opengis.net/gml/2.1.2/feature.xsd"_s );
106 importElement.setAttribute( u
"schemaLocation"_s, u
"http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"_s );
107 schemaElement.appendChild( importElement );
112 for (
int i = 0; i < wfsLayerIds.size(); ++i )
122 if ( !typeNameList.isEmpty() && !typeNameList.contains( name ) )
126#ifdef HAVE_SERVER_PYTHON_PLUGINS
129 if ( !typeNameList.isEmpty() )
131 throw QgsSecurityAccessException( u
"Feature access permission denied"_s );
139 QgsVectorLayer *vLayer = qobject_cast<QgsVectorLayer *>( layer );
140 QgsVectorDataProvider *provider = vLayer->
dataProvider();
145 setSchemaLayer( schemaElement, doc,
const_cast<QgsVectorLayer *
>( vLayer ) );
150void QgsWfsDescribeFeatureTypeGml::setSchemaLayer( QDomElement &parentElement, QDomDocument &doc,
const QgsVectorLayer *layer )
const
152 const QgsVectorDataProvider *provider = layer->
dataProvider();
161 QDomElement elementElem = doc.createElement( u
"element"_s );
162 elementElem.setAttribute( u
"name"_s, typeName );
163 elementElem.setAttribute( u
"type"_s,
"qgs:" + typeName +
"Type" );
164 elementElem.setAttribute( u
"substitutionGroup"_s, u
"gml:_Feature"_s );
165 parentElement.appendChild( elementElem );
168 QDomElement complexTypeElem = doc.createElement( u
"complexType"_s );
169 complexTypeElem.setAttribute( u
"name"_s, typeName +
"Type" );
170 parentElement.appendChild( complexTypeElem );
173 QDomElement complexContentElem = doc.createElement( u
"complexContent"_s );
174 complexTypeElem.appendChild( complexContentElem );
177 QDomElement extensionElem = doc.createElement( u
"extension"_s );
178 extensionElem.setAttribute( u
"base"_s, u
"gml:AbstractFeatureType"_s );
179 complexContentElem.appendChild( extensionElem );
182 QDomElement sequenceElem = doc.createElement( u
"sequence"_s );
183 extensionElem.appendChild( sequenceElem );
188 QDomElement geomElem = doc.createElement( u
"element"_s );
189 geomElem.setAttribute( u
"name"_s, u
"geometry"_s );
190 geomElem.setAttribute( u
"type"_s, getGmlGeometryType( layer ) );
191 geomElem.setAttribute( u
"minOccurs"_s, u
"0"_s );
192 geomElem.setAttribute( u
"maxOccurs"_s, u
"1"_s );
193 sequenceElem.appendChild( geomElem );
197 const QgsFields fields = layer->
fields();
199 for (
int idx = 0; idx < fields.
count(); ++idx )
201 const QgsField field = fields.
at( idx );
208 QString attributeName, attributeType;
214 QDomElement attElem = doc.createElement( u
"element"_s );
216 attElem.setAttribute( u
"name"_s, attributeName );
217 attElem.setAttribute( u
"type"_s, attributeType );
221 attElem.setAttribute( u
"nillable"_s, u
"true"_s );
224 sequenceElem.appendChild( attElem );
226 const QString alias = field.
alias();
227 if ( !alias.isEmpty() )
229 attElem.setAttribute( u
"alias"_s, alias );
234QString QgsWfsDescribeFeatureTypeGml::getGmlGeometryType(
const QgsVectorLayer *layer )
const
237 switch ( wfsParameters.outputFormat() )
239 case QgsWfsParameters::Format::GML2:
245 return u
"gml:PointPropertyType"_s;
250 return u
"gml:LineStringPropertyType"_s;
255 return u
"gml:PolygonPropertyType"_s;
260 return u
"gml:MultiPointPropertyType"_s;
267 return u
"gml:MultiLineStringPropertyType"_s;
274 return u
"gml:MultiPolygonPropertyType"_s;
277 return u
"gml:GeometryPropertyType"_s;
279 case QgsWfsParameters::Format::GML3:
285 return u
"gml:PointPropertyType"_s;
290 return u
"gml:LineStringPropertyType"_s;
295 return u
"gml:PolygonPropertyType"_s;
299 return u
"gml:MultiPointPropertyType"_s;
306 return u
"gml:MultiCurvePropertyType"_s;
312 return u
"gml:MultiSurfacePropertyType"_s;
315 return u
"gml:GeometryPropertyType"_s;
318 return u
"gml:GeometryPropertyType"_s;
WkbType
The WKB type describes the number of dimensions a geometry has.
@ LineString25D
LineString25D.
@ MultiPointZ
MultiPointZ.
@ MultiPolygon25D
MultiPolygon25D.
@ MultiLineString25D
MultiLineString25D.
@ MultiPolygon
MultiPolygon.
@ MultiSurfaceZ
MultiSurfaceZ.
@ MultiLineString
MultiLineString.
@ MultiPoint25D
MultiPoint25D.
@ MultiLineStringZ
MultiLineStringZ.
@ MultiPolygonZ
MultiPolygonZ.
@ MultiCurveZ
MultiCurveZ.
@ LineStringZ
LineStringZ.
@ MultiSurface
MultiSurface.
@ HideFromWfs
Field is not available if layer is served as WFS from QGIS server.
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.
@ ConstraintNotNull
Field may not be null.
Qgis::FieldConfigurationFlags configurationFlags
QgsFieldConstraints constraints
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
QString wfsTypeName() const
Returns WFS typename for the layer.
Base class for all map layer types.
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 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.
Defines 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.
static QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
Defines requests passed to QgsService classes.
Defines the response interface passed to QgsService.
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...
Represents a vector layer which manages a vector based dataset.
bool isSpatial() const final
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
Q_INVOKABLE Qgis::WkbType wkbType() const final
Returns the WKBType or WKBUnknown in case of error.
QgsVectorDataProvider * dataProvider() final
Returns the layer's data provider, it may be nullptr.
void writeDescribeFeatureType(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response) const
Output GML response.
QgsWfsDescribeFeatureTypeGml(const QgsWfs::QgsWfsParameters wfsParams)
Constructor.
Provides an interface to retrieve and manipulate WFS parameters received from the client.
Format outputFormat() const
Returns format.
void getFieldAttributes(const QgsField &field, QString &fieldName, QString &fieldType)
Helper for returning the field type and type name.
const QString QGS_NAMESPACE
QStringList getRequestTypeNames(const QgsServerRequest &request, const QgsWfsParameters &wfsParams)
Helper for returning typename list from the request.