29#include <QJsonDocument> 
   34  : wfsParameters( wfsParams )
 
 
   39  const QJsonDocument doc( createDescribeFeatureTypeDocument( serverIface, project, version, request ) );
 
   41  response.
setHeader( 
"Content-Type", 
"application/vnd.geo+json; charset=utf-8" );
 
   42  response.
write( doc.toJson( QJsonDocument::Compact ) );
 
 
   51#ifdef HAVE_SERVER_PYTHON_PLUGINS 
   58  json[QStringLiteral( 
"elementFormDefault" )] = QStringLiteral( 
"qualified" );
 
   60  json[QStringLiteral( 
"targetPrefix" )] = QStringLiteral( 
"qgs" );
 
   62  QJsonArray featureTypes;
 
   67  for ( 
int i = 0; i < wfsLayerIds.size(); ++i )
 
   77    if ( !typeNameList.isEmpty() && !typeNameList.contains( name ) )
 
   81#ifdef HAVE_SERVER_PYTHON_PLUGINS 
   82    if ( accessControl && !accessControl->layerReadPermission( layer ) )
 
   84      if ( !typeNameList.isEmpty() )
 
  101    featureTypes.append( schemaLayerToJson( 
const_cast<QgsVectorLayer *
>( vLayer ) ) );
 
  104  json[QStringLiteral( 
"featureTypes" )] = featureTypes;
 
  108QJsonObject QgsWfsDescribeFeatureTypeJson::schemaLayerToJson( 
const QgsVectorLayer *layer )
 const 
  113  QJsonArray properties;
 
  115  json[QStringLiteral( 
"typeName" )] = 
typeName;
 
  119    QString geomType, geomLocalType;
 
  120    getGeometryType( layer, geomType, geomLocalType );
 
  122    QJsonObject property;
 
  123    property[QStringLiteral( 
"name" )] = QStringLiteral( 
"geometry" );
 
  124    property[QStringLiteral( 
"minOccurs" )] = QStringLiteral( 
"0" );
 
  125    property[QStringLiteral( 
"maxOccurs" )] = QStringLiteral( 
"1" );
 
  126    property[QStringLiteral( 
"type" )] = geomType;
 
  129    if ( !geomLocalType.isEmpty() )
 
  131      property[QStringLiteral( 
"localType" )] = geomLocalType;
 
  133    properties.append( property );
 
  139  for ( 
int idx = 0; idx < fields.
count(); ++idx )
 
  148    QString attributeName, attributeType;
 
  153    QJsonObject property;
 
  154    property[QStringLiteral( 
"name" )] = attributeName;
 
  155    property[QStringLiteral( 
"type" )] = attributeType;
 
  156    property[QStringLiteral( 
"localType" )] = attributeType;
 
  160      property[QStringLiteral( 
"nillable" )] = 
"true";
 
  163    const QString alias = field.
alias();
 
  164    if ( !alias.isEmpty() )
 
  166      property[QStringLiteral( 
"alias" )] = alias;
 
  169    properties.append( property );
 
  172  json[QStringLiteral( 
"properties" )] = properties;
 
  176void QgsWfsDescribeFeatureTypeJson::getGeometryType( 
const QgsVectorLayer *layer, QString &geomType, QString &geomLocalType )
 const 
  183      geomType = QStringLiteral( 
"gml:PointPropertyType" );
 
  184      geomLocalType = QStringLiteral( 
"Point" );
 
  189      geomType = QStringLiteral( 
"gml:LineStringPropertyType" );
 
  190      geomLocalType = QStringLiteral( 
"LineString" );
 
  195      geomType = QStringLiteral( 
"gml:PolygonPropertyType" );
 
  196      geomLocalType = QStringLiteral( 
"Polygon" );
 
  201      geomType = QStringLiteral( 
"gml:MultiPointPropertyType" );
 
  202      geomLocalType = QStringLiteral( 
"MultiPoint" );
 
  208      geomType = QStringLiteral( 
"gml:MultiCurvePropertyType" );
 
  209      geomLocalType = QStringLiteral( 
"MultiCurve" );
 
  215      geomType = QStringLiteral( 
"gml:MultiSurfacePropertyType" );
 
  216      geomLocalType = QStringLiteral( 
"MultiSurface" );
 
  220      geomType = QStringLiteral( 
"gml:GeometryPropertyType" );
 
WkbType
The WKB type describes the number of dimensions a geometry has.
 
@ LineString25D
LineString25D.
 
@ MultiPolygon25D
MultiPolygon25D.
 
@ MultiLineString25D
MultiLineString25D.
 
@ MultiPolygon
MultiPolygon.
 
@ MultiLineString
MultiLineString.
 
@ MultiPoint25D
MultiPoint25D.
 
@ 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.
 
@ ConstraintNotNull
Field may not be null.
 
Encapsulate a field in an attribute table or data source.
 
Qgis::FieldConfigurationFlags configurationFlags
 
QgsFieldConstraints constraints
 
Container of fields for a vector layer.
 
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
 
Base class for all map layer types.
 
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.
 
Defines interfaces exposed by QGIS Server and made available to plugins.
 
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...
 
Base class for vector data providers.
 
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.
 
QgsWfsDescribeFeatureTypeJson(const QgsWfs::QgsWfsParameters wfsParams)
Constructor.
 
void writeDescribeFeatureType(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response) const
Output GeoJson response.
 
Exception thrown when data access violates access controls.
 
Provides an interface to retrieve and manipulate WFS parameters received from the client.
 
QString layerTypeName(const QgsMapLayer *layer)
Returns typename from vector layer.
 
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.