22#include <QRegularExpression>
23#include <QRegularExpressionMatch>
25#include "moc_qgswfsparameters.cpp"
54 const QStringList corners =
mValue.toString().split(
',' );
55 if ( corners.size() == 5 )
57 value.resize( value.size() - corners[4].size() - 1 );
61 param.
mValue = QVariant( value );
68 const QString msg = QString(
"%1 ('%2') cannot be converted into rectangle" ).arg(
name(
mName ),
toString() );
79 const QString val =
mValue.toString();
87 const QRegularExpression rx( exp );
88 QRegularExpressionMatchIterator matchIt = rx.globalMatch( val );
89 if ( !matchIt.hasNext() )
95 while ( matchIt.hasNext() )
97 const QRegularExpressionMatch match = matchIt.next();
98 if ( match.hasMatch() )
100 QStringList matches = match.capturedTexts();
102 theList.append( matches );
119 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWfsParameter::Name>() );
120 return metaEnum.valueToKey(
name );
125 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWfsParameter::Name>() );
140 save( pOutputFormat );
146 save( pPropertyName );
149 save( pMaxFeatures );
176 save( pGeometryName );
185 bool QgsWfsParameters::loadParameter(
const QString &key,
const QString &value )
192 mWfsParameters[name].mValue =
value;
193 if ( !mWfsParameters[name].isValid() )
195 mWfsParameters[name].raiseError();
206 mWfsParameters[parameter.mName] = parameter;
211 log(
"WFS Request parameters:" );
212 const auto map = mWfsParameters.toStdMap();
213 for (
const auto ¶meter :
map )
215 const QString
value = parameter.second.toString();
217 if ( !
value.isEmpty() )
220 log( QStringLiteral(
" - %1 : %2" ).arg( name,
value ) );
225 log( QStringLiteral(
" - VERSION : %1" ).arg(
version() ) );
237 if ( fStr.isEmpty() )
246 if ( fStr.compare( QLatin1String(
"text/xml; subtype=gml/2.1.2" ), Qt::CaseInsensitive ) == 0 )
248 else if ( fStr.compare( QLatin1String(
"text/xml; subtype=gml/3.1.1" ), Qt::CaseInsensitive ) == 0 )
250 else if ( fStr.compare( QLatin1String(
"application/vnd.geo+json" ), Qt::CaseInsensitive ) == 0 ||
252 fStr.compare( QLatin1String(
"application/vnd.geo json" ), Qt::CaseInsensitive ) == 0 || fStr.compare( QLatin1String(
"application/geo+json" ), Qt::CaseInsensitive ) == 0 || fStr.compare( QLatin1String(
"application/geo json" ), Qt::CaseInsensitive ) == 0 || fStr.compare( QLatin1String(
"application/json" ), Qt::CaseInsensitive ) == 0 || fStr.compare( QLatin1String(
"geojson" ), Qt::CaseInsensitive ) == 0 )
254 else if ( fStr.compare( QLatin1String(
"gml2" ), Qt::CaseInsensitive ) == 0 )
256 else if ( fStr.compare( QLatin1String(
"gml3" ), Qt::CaseInsensitive ) == 0 )
259 if ( f ==
Format::NONE &&
request().compare( QLatin1String(
"describefeaturetype" ), Qt::CaseInsensitive ) == 0 && fStr.compare( QLatin1String(
"xmlschema" ), Qt::CaseInsensitive ) == 0 )
278 if ( rtStr.isEmpty() )
282 if ( rtStr.compare( QLatin1String(
"hits" ), Qt::CaseInsensitive ) == 0 )
359 const QString vStr =
version();
370 void QgsWfsParameters::log(
const QString &msg,
const char *file,
const char *function,
int line )
const
@ Info
Information message.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
Adds a message to the log instance (and creates it if necessary).
Describes the version of a project.
A rectangle specified with double values.
Q_INVOKABLE QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
QString toString(bool defaultValue=false) const
Converts the parameter into a string.
QgsServerParameterDefinition(const QMetaType::Type type=QMetaType::Type::QString, const QVariant defaultValue=QVariant(""))
Constructor for QgsServerParameterDefinition.
QString typeName() const
Returns the type of the parameter as a string.
static void raiseError(const QString &msg)
Raises an exception in case of an invalid parameters.
int toInt(bool &ok) const
Converts the parameter into an integer.
QgsRectangle toRectangle(bool &ok) const
Converts the parameter into a rectangle.
QString map() const
Returns MAP parameter as a string or an empty string if not defined.
QgsServerParameters()
Constructor.
virtual QString request() const
Returns REQUEST parameter as a string or an empty string if not defined.
QUrlQuery urlQuery() const
Returns a url query with underlying parameters.
void load(const QUrlQuery &query)
Loads new parameters.
virtual QString version() const
Returns VERSION parameter as a string or an empty string if not defined.
QString value(const QString &key) const
Returns the value of a parameter.
WFS parameter received from the client.
QgsWfsParameter::Name mName
Name
Available parameters for WFS requests.
int toInt() const
Converts the parameter into an integer.
QStringList toStringListWithExp(const QString &exp="\\(([^()]+)\\)") const
Converts the parameter into a list of string.
void raiseError() const
Raises an error in case of an invalid conversion.
QgsWfsParameter(const QgsWfsParameter::Name name=QgsWfsParameter::UNKNOWN, const QMetaType::Type type=QMetaType::Type::QString, const QVariant defaultValue=QVariant(""))
Constructor for QgsWfsParameter.
QgsRectangle toRectangle() const
Converts the parameter into a rectangle.
static QString name(const QgsWfsParameter::Name)
Converts a parameter's name into its string representation.
QgsWfsParameters()
Constructor for WFS parameters with default values only.
int startIndexAsInt() const
Returns STARTINDEX parameter as an int or its default value if not defined.
QString geometryNameAsString() const
Returns GEOMETRYNAME parameter as a string.
ResultType
Type of results.
QgsWfsParameters(const QgsServerParameters ¶meters)
Constructor for WFS parameters with specific values.
QStringList sortBy() const
Returns SORTBY parameter as list.
QStringList typeNames() const
Returns TYPENAME parameter as list.
QStringList expFilters() const
Returns EXP_FILTER parameter as list.
QString maxFeatures() const
Returns MAXFEATURES parameter as a string.
QStringList filters() const
Returns FILTER parameter as list.
QString srsName() const
Returns SRSNAME parameter as a string.
QString resultTypeAsString() const
Returns RESULTTYPE parameter as a string.
int maxFeaturesAsInt() const
Returns MAXFEATURES parameter as an int or its default value if not defined.
QString bbox() const
Returns BBOX if defined or an empty string.
void dump() const
Dumps parameters.
QString outputFormatAsString() const
Returns OUTPUTFORMAT parameter as a string.
ResultType resultType() const
Returns resultType.
QgsProjectVersion versionAsNumber() const
Returns VERSION parameter if defined or its default value.
QStringList featureIds() const
Returns FEATUREID parameter as list.
QString startIndex() const
Returns STARTINDEX parameter as a string.
Format
Output format for the response.
QgsRectangle bboxAsRectangle() const
Returns BBOX as a rectangle if defined and valid.
QStringList propertyNames() const
Returns PROPERTYNAME parameter as list.
Format outputFormat() const
Returns format.