19#include "moc_qgswfsparameters.cpp"
21#include <QRegularExpression>
22#include <QRegularExpressionMatch>
30 const QMetaType::Type type,
31 const QVariant defaultValue )
53 const QStringList corners =
mValue.toString().split(
',' );
54 if ( corners.size() == 5 )
56 value.resize( value.size() - corners[4].size() - 1 );
60 param.
mValue = QVariant( value );
67 const QString msg = QString(
"%1 ('%2') cannot be converted into rectangle" ).arg(
name(
mName ),
toString() );
86 const QRegularExpression rx( exp );
87 QRegularExpressionMatchIterator matchIt = rx.globalMatch( val );
88 if ( !matchIt.hasNext() )
94 while ( matchIt.hasNext() )
96 const QRegularExpressionMatch match = matchIt.next();
97 if ( match.hasMatch() )
99 QStringList matches = match.capturedTexts();
101 theList.append( matches );
118 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWfsParameter::Name>() );
119 return metaEnum.valueToKey(
name );
124 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWfsParameter::Name>() );
139 save( pOutputFormat );
145 save( pPropertyName );
148 QMetaType::Type::Int,
150 save( pMaxFeatures );
153 QMetaType::Type::Int,
179 save( pGeometryName );
188 bool QgsWfsParameters::loadParameter(
const QString &key,
const QString &value )
195 mWfsParameters[name].mValue =
value;
196 if ( ! mWfsParameters[name].isValid() )
198 mWfsParameters[name].raiseError();
207 void QgsWfsParameters::save(
const QgsWfsParameter ¶meter )
209 mWfsParameters[ parameter.mName ] = parameter;
214 log(
"WFS Request parameters:" );
215 const auto map = mWfsParameters.toStdMap();
216 for (
const auto ¶meter :
map )
218 const QString
value = parameter.second.toString();
220 if ( !
value.isEmpty() )
223 log( QStringLiteral(
" - %1 : %2" ).arg( name,
value ) );
228 log( QStringLiteral(
" - VERSION : %1" ).arg(
version() ) );
240 if ( fStr.isEmpty() )
249 if ( fStr.compare( QLatin1String(
"text/xml; subtype=gml/2.1.2" ), Qt::CaseInsensitive ) == 0 )
251 else if ( fStr.compare( QLatin1String(
"text/xml; subtype=gml/3.1.1" ), Qt::CaseInsensitive ) == 0 )
253 else if ( fStr.compare( QLatin1String(
"application/vnd.geo+json" ), Qt::CaseInsensitive ) == 0 ||
255 fStr.compare( QLatin1String(
"application/vnd.geo json" ), Qt::CaseInsensitive ) == 0 ||
256 fStr.compare( QLatin1String(
"application/geo+json" ), Qt::CaseInsensitive ) == 0 ||
257 fStr.compare( QLatin1String(
"application/geo json" ), Qt::CaseInsensitive ) == 0 ||
258 fStr.compare( QLatin1String(
"application/json" ), Qt::CaseInsensitive ) == 0 ||
259 fStr.compare( QLatin1String(
"geojson" ), Qt::CaseInsensitive ) == 0
262 else if ( fStr.compare( QLatin1String(
"gml2" ), Qt::CaseInsensitive ) == 0 )
264 else if ( fStr.compare( QLatin1String(
"gml3" ), Qt::CaseInsensitive ) == 0 )
268 request().compare( QLatin1String(
"describefeaturetype" ), Qt::CaseInsensitive ) == 0 &&
269 fStr.compare( QLatin1String(
"xmlschema" ), Qt::CaseInsensitive ) == 0 )
288 if ( rtStr.isEmpty() )
292 if ( rtStr.compare( QLatin1String(
"hits" ), Qt::CaseInsensitive ) == 0 )
369 const QString vStr =
version();
380 void QgsWfsParameters::log(
const QString &msg )
const
@ Info
Information message.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
A class to describe the version of a project.
A rectangle specified with double values.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
Definition of a parameter with basic conversion methods.
QString toString(bool defaultValue=false) const
Converts the parameter into a string.
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.
QgsServerParameters provides an interface to retrieve and manipulate global parameters received from ...
QString map() const
Returns MAP parameter as a string or an empty string if not defined.
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.
Provides an interface to retrieve and manipulate WFS parameters received from the client.
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.
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.