28 const QVariant::Type type,
29 const QVariant defaultValue )
51 const QStringList corners =
mValue.toString().split(
',' );
52 if ( corners.size() == 5 )
54 value.resize( value.size() - corners[4].size() - 1 );
58 param.
mValue = QVariant( value );
65 const QString msg = QString(
"%1 ('%2') cannot be converted into rectangle" ).arg(
name(
mName ),
toString() );
76 QString val =
mValue.toString();
85 if ( rx.indexIn( val, 0 ) == -1 )
92 while ( ( pos = rx.indexIn( val, pos ) ) != -1 )
94 theList << rx.cap( 1 );
95 pos += rx.matchedLength();
111 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWfsParameter::Name>() );
112 return metaEnum.valueToKey( name );
117 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWfsParameter::Name>() );
132 save( pOutputFormat );
138 save( pPropertyName );
143 save( pMaxFeatures );
172 save( pGeometryName );
181 bool QgsWfsParameters::loadParameter(
const QString &key,
const QString &
value )
188 mWfsParameters[name].mValue =
value;
189 if ( ! mWfsParameters[name].isValid() )
191 mWfsParameters[name].raiseError();
202 mWfsParameters[ parameter.
mName ] = parameter;
207 log(
"WFS Request parameters:" );
208 for (
auto parameter : mWfsParameters.toStdMap() )
210 const QString value = parameter.second.
toString();
212 if ( ! value.isEmpty() )
215 log( QStringLiteral(
" - %1 : %2" ).arg( name, value ) );
220 log( QStringLiteral(
" - VERSION : %1" ).arg(
version() ) );
232 if ( fStr.isEmpty() )
241 if ( fStr.compare( QLatin1String(
"text/xml; subtype=gml/2.1.2" ), Qt::CaseInsensitive ) == 0 )
243 else if ( fStr.compare( QLatin1String(
"text/xml; subtype=gml/3.1.1" ), Qt::CaseInsensitive ) == 0 )
245 else if ( fStr.compare( QLatin1String(
"application/vnd.geo+json" ), Qt::CaseInsensitive ) == 0 )
247 else if ( fStr.compare( QLatin1String(
"gml2" ), Qt::CaseInsensitive ) == 0 )
249 else if ( fStr.compare( QLatin1String(
"gml3" ), Qt::CaseInsensitive ) == 0 )
251 else if ( fStr.compare( QLatin1String(
"geojson" ), Qt::CaseInsensitive ) == 0 )
254 if ( f == Format::NONE &&
255 request().compare( QLatin1String(
"describefeaturetype" ), Qt::CaseInsensitive ) == 0 &&
256 fStr.compare( QLatin1String(
"xmlschema" ), Qt::CaseInsensitive ) == 0 )
270 if ( rtStr.isEmpty() )
271 return ResultType::RESULTS;
274 if ( rtStr.compare( QLatin1String(
"hits" ), Qt::CaseInsensitive ) == 0 )
275 rt = ResultType::HITS;
354 if ( vStr.isEmpty() )
362 void QgsWfsParameters::log(
const QString &msg )
const
int toInt(bool &ok) const
Converts the parameter into an integer.
QString toString() const
Converts the parameter into a string.
QStringList sortBy() const
Returns SORTBY parameter as list.
A rectangle specified with double values.
QgsRectangle toRectangle() const
Converts the parameter into a rectangle.
void dump() const
Dumps parameters.
QString geometryNameAsString() const
Returns GEOMETRYNAME parameter as a string.
Format outputFormat() const
Returns format.
QStringList propertyNames() const
Returns PROPERTYNAME parameter as list.
QgsWfsParameters()
Constructor for WFS parameters with default values only.
QString value(const QString &key) const
Returns the value of a parameter.
ResultType resultType() const
Returns resultType.
static void raiseError(const QString &msg)
Raises an exception in case of an invalid parameters.
QStringList featureIds() const
Returns FEATUREID parameter as list.
void load(const QUrlQuery &query)
Loads new parameters.
WFS parameter received from the client.
QString resultTypeAsString() const
Returns RESULTTYPE parameter as a string.
QString typeName() const
Returns the type of the parameter as a string.
int toInt() const
Converts the parameter into an integer.
QStringList expFilters() const
Returns EXP_FILTER parameter as list.
QgsWfsParameter(const QgsWfsParameter::Name name=QgsWfsParameter::UNKNOWN, const QVariant::Type type=QVariant::String, const QVariant defaultValue=QVariant(""))
Constructor for QgsWfsParameter.
void raiseError() const
Raises an error in case of an invalid conversion.
QStringList typeNames() const
Returns TYPENAME parameter as list.
QString outputFormatAsString() const
Returns OUTPUTFORMAT parameter as a string.
QString version() const
Returns VERSION parameter as a string or an empty string if not defined.
A class to describe the version of a project.
QString request() const
Returns REQUEST parameter as a string or an empty string if not defined.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
QString bbox() const
Returns BBOX if defined or an empty string.
Format
Output format for the response.
QgsRectangle toRectangle(bool &ok) const
Converts the parameter into a rectangle.
QStringList filters() const
Returns FILTER parameter as list.
QStringList toStringListWithExp(const QString &exp="\\(([^()]+)\\)") const
Converts the parameter into a list of string.
QgsWfsParameter::Name mName
int startIndexAsInt() const
Returns STARTINDEX parameter as an int or its default value if not defined.
QgsServerParameters provides an interface to retrieve and manipulate global parameters received from ...
QUrlQuery urlQuery() const
Returns a url query with underlying parameters.
QString startIndex() const
Returns STARTINDEX parameter as a string.
QString srsName() const
Returns SRSNAME parameter as a string.
QString maxFeatures() const
Returns MAXFEATURES parameter as a string.
ResultType
Type of results.
Name
Available parameters for WFS requests.
QgsRectangle bboxAsRectangle() const
Returns BBOX as a rectangle if defined and valid.
Provides an interface to retrieve and manipulate WFS parameters received from the client...
static QString name(const QgsWfsParameter::Name)
Converts a parameter's name into its string representation.
int maxFeaturesAsInt() const
Returns MAXFEATURES parameter as an int or its default value if not defined.
QgsProjectVersion versionAsNumber() const
Returns VERSION parameter if defined or its default value.
Definition of a parameter with basic conversion methods.