22#include <QDomDocument>
46 case QgsWfsParameters::Format::GML2:
47 case QgsWfsParameters::Format::GML3:
50 formatter.writeDescribeFeatureType( serverIface, project, version, request, response );
54 case QgsWfsParameters::Format::GeoJSON:
57 formatter.writeDescribeFeatureType( serverIface, project, version, request, response );
63 QStringLiteral(
"OUTPUTFORMAT %1 is not supported" ).arg( wfsParameters.
outputFormatAsString() ) );
70 QStringList typeNameList;
71 QDomDocument queryDoc;
73 if ( queryDoc.setContent( request.
data(),
true, &errorMsg ) )
76 const QDomElement queryDocElem = queryDoc.documentElement();
77 const QDomNodeList docChildNodes = queryDocElem.childNodes();
78 if ( docChildNodes.size() )
80 for (
int i = 0; i < docChildNodes.size(); i++ )
82 const QDomElement docChildElem = docChildNodes.at( i ).toElement();
83 if ( docChildElem.tagName() == QLatin1String(
"TypeName" ) )
85 const QString
typeName = docChildElem.text().trimmed();
87 typeNameList <<
typeName.section(
':', 1, 1 );
107 const thread_local QRegularExpression sCleanTagNameRegExp( QStringLiteral(
"[^\\w\\.-_]" ), QRegularExpression::PatternOption::UseUnicodePropertiesOption );
108 fieldName.replace(
' ',
'_' ).replace( sCleanTagNameRegExp, QString() );
110 const QVariant::Type attributeType =
field.
type();
112 if ( attributeType == QVariant::Int )
114 fieldType = QStringLiteral(
"int" );
116 else if ( attributeType == QVariant::UInt )
118 fieldType = QStringLiteral(
"unsignedInt" );
120 else if ( attributeType == QVariant::LongLong )
122 fieldType = QStringLiteral(
"long" );
124 else if ( attributeType == QVariant::ULongLong )
126 fieldType = QStringLiteral(
"unsignedLong" );
128 else if ( attributeType == QVariant::Double )
131 fieldType = QStringLiteral(
"integer" );
133 fieldType = QStringLiteral(
"decimal" );
135 else if ( attributeType == QVariant::Bool )
137 fieldType = QStringLiteral(
"boolean" );
139 else if ( attributeType == QVariant::Date )
141 fieldType = QStringLiteral(
"date" );
143 else if ( attributeType == QVariant::Time )
145 fieldType = QStringLiteral(
"time" );
147 else if ( attributeType == QVariant::DateTime )
149 fieldType = QStringLiteral(
"dateTime" );
153 fieldType = QStringLiteral(
"string" );
157 if ( setup.
type() == QStringLiteral(
"DateTime" ) )
160 const QVariantMap config = setup.
config();
162 const QString fieldFormat = config.value(
163 QStringLiteral(
"field_format" ),
168 fieldType = QStringLiteral(
"time" );
170 fieldType = QStringLiteral(
"date" );
172 fieldType = QStringLiteral(
"dateTime" );
174 fieldType = QStringLiteral(
"dateTime" );
176 else if ( setup.
type() == QStringLiteral(
"Range" ) )
178 const QVariantMap config = setup.
config();
179 if ( config.contains( QStringLiteral(
"Precision" ) ) )
184 const int configPrec( config[ QStringLiteral(
"Precision" ) ].toInt( &ok ) );
187 if ( configPrec == 0 )
188 fieldType = QStringLiteral(
"integer" );
190 fieldType = QStringLiteral(
"decimal" );
Encapsulate a field in an attribute table or data source.
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
virtual QByteArray data() const
Returns post/put data Check for QByteArray::isNull() to check if data is available.
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
GML output formatter for DescribeFeatureType.
Json output formatter for DescribeFeatureType.
Exception thrown in case of malformed request.
Provides an interface to retrieve and manipulate WFS parameters received from the client.
QStringList typeNames() const
Returns TYPENAME parameter as list.
QString outputFormatAsString() const
Returns OUTPUTFORMAT parameter as a string.
Format
Output format for the response.
Format outputFormat() const
Returns format.
void getFieldAttributes(const QgsField &field, QString &fieldName, QString &fieldType)
Helper for returning the field type and type name.
void writeDescribeFeatureType(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output WFS GetCapabilities response.
QStringList getRequestTypeNames(const QgsServerRequest &request, const QgsWfsParameters &wfsParams)
Helper for returning typename list from the request.