33#include <QDomDocument>
37using namespace Qt::StringLiterals;
53 formatter.writeDescribeFeatureType( serverIface, project, version, request, response );
60 formatter.writeDescribeFeatureType( serverIface, project, version, request, response );
71 QStringList typeNameList;
72 QDomDocument queryDoc;
74 if ( queryDoc.setContent( request.
data(),
true, &errorMsg ) )
77 const QDomElement queryDocElem = queryDoc.documentElement();
78 const QDomNodeList docChildNodes = queryDocElem.childNodes();
79 if ( docChildNodes.size() )
81 for (
int i = 0; i < docChildNodes.size(); i++ )
83 const QDomElement docChildElem = docChildNodes.at( i ).toElement();
84 if ( docChildElem.tagName() ==
"TypeName"_L1 )
86 const QString typeName = docChildElem.text().trimmed();
87 if ( typeName.contains(
':' ) )
88 typeNameList << typeName.section(
':', 1, 1 );
90 typeNameList << typeName;
106 fieldName = field.
name();
108 const thread_local QRegularExpression sCleanTagNameRegExp( u
"[^\\w\\.-_]"_s, QRegularExpression::PatternOption::UseUnicodePropertiesOption );
109 fieldName.replace(
' ',
'_' ).replace( sCleanTagNameRegExp, QString() );
111 const QMetaType::Type attributeType = field.
type();
113 if ( attributeType == QMetaType::Type::Int )
115 fieldType = u
"int"_s;
117 else if ( attributeType == QMetaType::Type::UInt )
119 fieldType = u
"unsignedInt"_s;
121 else if ( attributeType == QMetaType::Type::LongLong )
123 fieldType = u
"long"_s;
125 else if ( attributeType == QMetaType::Type::ULongLong )
127 fieldType = u
"unsignedLong"_s;
129 else if ( attributeType == QMetaType::Type::Double )
132 fieldType = u
"integer"_s;
134 fieldType = u
"decimal"_s;
136 else if ( attributeType == QMetaType::Type::Bool )
138 fieldType = u
"boolean"_s;
140 else if ( attributeType == QMetaType::Type::QDate )
142 fieldType = u
"date"_s;
144 else if ( attributeType == QMetaType::Type::QTime )
146 fieldType = u
"time"_s;
148 else if ( attributeType == QMetaType::Type::QDateTime )
150 fieldType = u
"dateTime"_s;
154 fieldType = u
"string"_s;
158 if ( setup.
type() ==
"DateTime"_L1 )
161 const QVariantMap config = setup.
config();
163 const QString fieldFormat = config.value(
170 fieldType = u
"time"_s;
172 fieldType = u
"date"_s;
174 fieldType = u
"dateTime"_s;
176 fieldType = u
"dateTime"_s;
178 else if ( setup.
type() ==
"Range"_L1 )
180 const QVariantMap config = setup.
config();
181 if ( config.contains( u
"Precision"_s ) )
186 const int configPrec( config[u
"Precision"_s].toInt( &ok ) );
187 if ( ok && configPrec != field.
precision() )
189 if ( configPrec == 0 )
190 fieldType = u
"integer"_s;
192 fieldType = u
"decimal"_s;
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,...
Defines interfaces exposed by QGIS Server and made available to plugins.
Defines requests passed to QgsService classes.
QUrl url() const
Returns the request URL as seen by QGIS server.
virtual QByteArray data() const
Returns post/put data Check for QByteArray::isNull() to check if data is available.
Defines the response interface passed to QgsService.
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.