34 : wfsParameters( wfsParams )
39#ifdef HAVE_SERVER_PYTHON_PLUGINS
43 const QDomDocument *describeDocument =
nullptr;
45#ifdef HAVE_SERVER_PYTHON_PLUGINS
47 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
49 describeDocument = &doc;
53 doc = createDescribeFeatureTypeDocument( serverIface, project, version, request );
59 describeDocument = &doc;
62 doc = createDescribeFeatureTypeDocument( serverIface, project, version, request );
63 describeDocument = &doc;
65 response.
setHeader(
"Content-Type",
"text/xml; charset=utf-8" );
66 response.
write( describeDocument->toByteArray() );
76#ifdef HAVE_SERVER_PYTHON_PLUGINS
85 QDomElement schemaElement = doc.createElement( QStringLiteral(
"schema" ) );
86 schemaElement.setAttribute( QStringLiteral(
"xmlns" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema" ) );
87 schemaElement.setAttribute( QStringLiteral(
"xmlns:xsd" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema" ) );
88 schemaElement.setAttribute( QStringLiteral(
"xmlns:ogc" ),
OGC_NAMESPACE );
89 schemaElement.setAttribute( QStringLiteral(
"xmlns:gml" ),
GML_NAMESPACE );
90 schemaElement.setAttribute( QStringLiteral(
"xmlns:qgs" ),
QGS_NAMESPACE );
91 schemaElement.setAttribute( QStringLiteral(
"targetNamespace" ),
QGS_NAMESPACE );
92 schemaElement.setAttribute( QStringLiteral(
"elementFormDefault" ), QStringLiteral(
"qualified" ) );
93 schemaElement.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
94 doc.appendChild( schemaElement );
97 QDomElement importElement = doc.createElement( QStringLiteral(
"import" ) );
98 importElement.setAttribute( QStringLiteral(
"namespace" ),
GML_NAMESPACE );
100 importElement.setAttribute( QStringLiteral(
"schemaLocation" ), QStringLiteral(
"http://schemas.opengis.net/gml/2.1.2/feature.xsd" ) );
102 importElement.setAttribute( QStringLiteral(
"schemaLocation" ), QStringLiteral(
"http://schemas.opengis.net/gml/3.1.1/base/gml.xsd" ) );
103 schemaElement.appendChild( importElement );
108 for (
int i = 0; i < wfsLayerIds.size(); ++i )
118 if ( !typeNameList.isEmpty() && !typeNameList.contains( name ) )
122#ifdef HAVE_SERVER_PYTHON_PLUGINS
125 if ( !typeNameList.isEmpty() )
127 throw QgsSecurityAccessException( QStringLiteral(
"Feature access permission denied" ) );
135 QgsVectorLayer *vLayer = qobject_cast<QgsVectorLayer *>( layer );
136 QgsVectorDataProvider *provider = vLayer->
dataProvider();
141 setSchemaLayer( schemaElement, doc,
const_cast<QgsVectorLayer *
>( vLayer ) );
146void QgsWfsDescribeFeatureTypeGml::setSchemaLayer( QDomElement &parentElement, QDomDocument &doc,
const QgsVectorLayer *layer )
const
148 const QgsVectorDataProvider *provider = layer->
dataProvider();
157 QDomElement elementElem = doc.createElement( QStringLiteral(
"element" ) );
158 elementElem.setAttribute( QStringLiteral(
"name" ), typeName );
159 elementElem.setAttribute( QStringLiteral(
"type" ),
"qgs:" + typeName +
"Type" );
160 elementElem.setAttribute( QStringLiteral(
"substitutionGroup" ), QStringLiteral(
"gml:_Feature" ) );
161 parentElement.appendChild( elementElem );
164 QDomElement complexTypeElem = doc.createElement( QStringLiteral(
"complexType" ) );
165 complexTypeElem.setAttribute( QStringLiteral(
"name" ), typeName +
"Type" );
166 parentElement.appendChild( complexTypeElem );
169 QDomElement complexContentElem = doc.createElement( QStringLiteral(
"complexContent" ) );
170 complexTypeElem.appendChild( complexContentElem );
173 QDomElement extensionElem = doc.createElement( QStringLiteral(
"extension" ) );
174 extensionElem.setAttribute( QStringLiteral(
"base" ), QStringLiteral(
"gml:AbstractFeatureType" ) );
175 complexContentElem.appendChild( extensionElem );
178 QDomElement sequenceElem = doc.createElement( QStringLiteral(
"sequence" ) );
179 extensionElem.appendChild( sequenceElem );
184 QDomElement geomElem = doc.createElement( QStringLiteral(
"element" ) );
185 geomElem.setAttribute( QStringLiteral(
"name" ), QStringLiteral(
"geometry" ) );
186 geomElem.setAttribute( QStringLiteral(
"type" ), getGmlGeometryType( layer ) );
187 geomElem.setAttribute( QStringLiteral(
"minOccurs" ), QStringLiteral(
"0" ) );
188 geomElem.setAttribute( QStringLiteral(
"maxOccurs" ), QStringLiteral(
"1" ) );
189 sequenceElem.appendChild( geomElem );
193 const QgsFields fields = layer->
fields();
195 for (
int idx = 0; idx < fields.
count(); ++idx )
197 const QgsField field = fields.
at( idx );
204 QString attributeName, attributeType;
210 QDomElement attElem = doc.createElement( QStringLiteral(
"element" ) );
212 attElem.setAttribute( QStringLiteral(
"name" ), attributeName );
213 attElem.setAttribute( QStringLiteral(
"type" ), attributeType );
217 attElem.setAttribute( QStringLiteral(
"nillable" ), QStringLiteral(
"true" ) );
220 sequenceElem.appendChild( attElem );
222 const QString alias = field.
alias();
223 if ( !alias.isEmpty() )
225 attElem.setAttribute( QStringLiteral(
"alias" ), alias );
230QString QgsWfsDescribeFeatureTypeGml::getGmlGeometryType(
const QgsVectorLayer *layer )
const
233 switch ( wfsParameters.outputFormat() )
235 case QgsWfsParameters::Format::GML2:
241 return QStringLiteral(
"gml:PointPropertyType" );
246 return QStringLiteral(
"gml:LineStringPropertyType" );
251 return QStringLiteral(
"gml:PolygonPropertyType" );
256 return QStringLiteral(
"gml:MultiPointPropertyType" );
263 return QStringLiteral(
"gml:MultiLineStringPropertyType" );
270 return QStringLiteral(
"gml:MultiPolygonPropertyType" );
273 return QStringLiteral(
"gml:GeometryPropertyType" );
275 case QgsWfsParameters::Format::GML3:
281 return QStringLiteral(
"gml:PointPropertyType" );
286 return QStringLiteral(
"gml:LineStringPropertyType" );
291 return QStringLiteral(
"gml:PolygonPropertyType" );
295 return QStringLiteral(
"gml:MultiPointPropertyType" );
302 return QStringLiteral(
"gml:MultiCurvePropertyType" );
308 return QStringLiteral(
"gml:MultiSurfacePropertyType" );
311 return QStringLiteral(
"gml:GeometryPropertyType" );
314 return QStringLiteral(
"gml:GeometryPropertyType" );
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.