QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgsserverapiutils.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsserverapiutils.cpp
3
4 Class defining utilities for QGIS server APIs.
5 -------------------
6 begin : 2019-04-16
7 copyright : (C) 2019 by Alessandro Pasotti
8 email : elpaso at itopen dot it
9 ***************************************************************************/
10
11/***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
19
20#include "qgsserverapiutils.h"
21
22#include <nlohmann/json.hpp>
23
25#include "qgsmessagelog.h"
26#include "qgsrectangle.h"
28#include "qgsvectorlayer.h"
29
30#include <QString>
31#include <QUrl>
32#include <QUrlQuery>
33
34using namespace Qt::StringLiterals;
35
37{
38 const QStringList parts { bbox.split( ',', Qt::SplitBehaviorFlags::SkipEmptyParts ) };
39 // Note: Z is ignored
40 bool ok { true };
41 if ( parts.count() == 4 || parts.count() == 6 )
42 {
43 const auto hasZ { parts.count() == 6 };
44 auto toDouble = [&]( const int i ) -> double {
45 if ( !ok )
46 return 0;
47 return parts[i].toDouble( &ok );
48 };
49 QgsRectangle rect;
50 if ( hasZ )
51 {
52 rect = QgsRectangle( toDouble( 0 ), toDouble( 1 ), toDouble( 3 ), toDouble( 4 ) );
53 }
54 else
55 {
56 rect = QgsRectangle( toDouble( 0 ), toDouble( 1 ), toDouble( 2 ), toDouble( 3 ) );
57 }
58 if ( ok )
59 {
60 return rect;
61 }
62 }
63 return QgsRectangle();
64}
65
66QList<QgsMapLayerServerProperties::WmsDimensionInfo> QgsServerApiUtils::temporalDimensions( const QgsVectorLayer *layer )
67{
68 if ( !layer )
69 return {};
70
71 const QgsMapLayerServerProperties *serverProperties = layer->serverProperties();
72 QList<QgsMapLayerServerProperties::WmsDimensionInfo> dimensions { serverProperties->wmsDimensions() };
73 // Filter only date and time
74 dimensions.erase( std::remove_if( dimensions.begin(), dimensions.end(), []( QgsMapLayerServerProperties::WmsDimensionInfo &dim ) {
75 return dim.name.toLower() != u"time"_s
76 && dim.name.toLower() != "date"_L1;
77 } ),
78 dimensions.end() );
79
80 // Automatically pick up the first date/datetime field if dimensions is empty
81 if ( dimensions.isEmpty() )
82 {
83 const auto constFields { layer->fields() };
84 for ( const auto &f : constFields )
85 {
86 if ( f.isDateOrTime() )
87 {
88 dimensions.append( QgsMapLayerServerProperties::WmsDimensionInfo( f.type() == QMetaType::Type::QDateTime ? u"time"_s : u"date"_s, f.name() ) );
89 break;
90 }
91 }
92 }
93 return dimensions;
94}
95
97template<typename T, class T2> T QgsServerApiUtils::parseTemporalInterval( const QString &interval )
98{
99 auto parseDate = []( const QString &date ) -> T2 {
100 T2 result;
101 if ( date == ".."_L1 || date.isEmpty() )
102 {
103 return result;
104 }
105 else
106 {
107 T2 result { T2::fromString( date, Qt::DateFormat::ISODate ) };
108 if ( !result.isValid() )
109 {
110 throw QgsServerApiBadRequestException( u"%1 is not a valid date/datetime."_s.arg( date ) );
111 }
112 return result;
113 }
114 };
115 const QStringList parts { interval.split( '/' ) };
116 if ( parts.size() != 2 )
117 {
118 throw QgsServerApiBadRequestException( u"%1 is not a valid datetime interval."_s.arg( interval ), u"Server"_s );
119 }
120 // cppcheck-suppress containerOutOfBounds
121 T result { parseDate( parts[0] ), parseDate( parts[1] ) };
122 // Check validity
123 if ( result.isEmpty() )
124 {
125 throw QgsServerApiBadRequestException( u"%1 is not a valid datetime interval (empty)."_s.arg( interval ), u"Server"_s );
126 }
127 return result;
128}
130
132{
133 return QgsServerApiUtils::parseTemporalInterval<QgsDateRange, QDate>( interval );
134}
135
137{
138 return QgsServerApiUtils::parseTemporalInterval<QgsDateTimeRange, QDateTime>( interval );
139}
140
142{
143 QgsExpression expression;
144 QStringList conditions;
145
146 const auto dimensions { QgsServerApiUtils::temporalDimensions( layer ) };
147 if ( dimensions.isEmpty() )
148 {
149 return expression;
150 }
151
152 // helper to get the field type from the field name
153 auto fieldTypeFromName = [&]( const QString &fieldName, const QgsVectorLayer *layer ) -> QMetaType::Type {
154 int fieldIdx { layer->fields().lookupField( fieldName ) };
155 if ( fieldIdx < 0 )
156 {
157 return QMetaType::Type::UnknownType;
158 }
159 const QgsField field { layer->fields().at( fieldIdx ) };
160 return field.type();
161 };
162
163 // helper to cast the field value
164 auto refFieldCast = [&]( const QString &fieldName, QMetaType::Type queryType, QMetaType::Type fieldType ) -> QString {
165 const auto fieldRealType { fieldTypeFromName( fieldName, layer ) };
166 if ( fieldRealType == QMetaType::Type::UnknownType )
167 {
168 return QString();
169 }
170
171 // Downcast only datetime -> date
172 // always cast strings
173 if ( fieldRealType == QMetaType::Type::QString )
174 {
175 // Cast to query type but only downcast
176 if ( fieldType != queryType || fieldType == QMetaType::Type::QDate )
177 {
178 return u"to_date( %1 )"_s.arg( QgsExpression::quotedColumnRef( fieldName ) );
179 }
180 else
181 {
182 return u"%2( %1 )"_s.arg( QgsExpression::quotedColumnRef( fieldName ) ).arg( queryType == QMetaType::Type::QDate ? u"to_date"_s : u"to_datetime"_s );
183 }
184 }
185 else if ( fieldType == queryType || fieldType == QMetaType::Type::QDate )
186 {
188 }
189 else
190 {
191 return u"%2( %1 )"_s.arg( QgsExpression::quotedColumnRef( fieldName ) ).arg( queryType == QMetaType::Type::QDate ? u"to_date"_s : u"to_datetime"_s );
192 }
193 };
194
195 // Quote and cast a query value
196 auto quoteValue = []( const QString &value ) -> QString {
197 if ( value.length() == 10 )
198 {
199 return u"to_date( %1 )"_s.arg( QgsExpression::quotedValue( value ) );
200 }
201 else
202 {
203 return u"to_datetime( %1 )"_s.arg( QgsExpression::quotedValue( value ) );
204 }
205 };
206
207 // helper to build the interval filter, fieldType is the underlying field type, queryType is the input query type
208 auto makeFilter = [&quoteValue]( const QString &fieldBegin, const QString &fieldEnd, const QString &fieldBeginCasted, const QString &fieldEndCasted, const QString &queryBegin, const QString &queryEnd ) -> QString {
209 QString result;
210
211 // It's a closed interval query, go for overlap
212 if ( !queryBegin.isEmpty() && !queryEnd.isEmpty() )
213 {
214 // Overlap of two intervals
215 if ( !fieldEndCasted.isEmpty() )
216 {
217 result = u"( %1 IS NULL OR %2 <= %6 ) AND ( %4 IS NULL OR %5 >= %3 )"_s
218 .arg( fieldBegin, fieldBeginCasted, quoteValue( queryBegin ), fieldEnd, fieldEndCasted, quoteValue( queryEnd ) );
219 }
220 else // Overlap of single value
221 {
222 result = u"( %1 IS NULL OR ( %2 <= %3 AND %3 <= %4 ) )"_s
223 .arg( fieldBegin, quoteValue( queryBegin ), fieldBeginCasted, quoteValue( queryEnd ) );
224 }
225 }
226 else if ( !queryBegin.isEmpty() ) // >=
227 {
228 if ( !fieldEndCasted.isEmpty() )
229 {
230 result = u"( %1 IS NULL OR %2 >= %3 )"_s.arg( fieldEnd, fieldEndCasted, quoteValue( queryBegin ) );
231 }
232 else
233 {
234 result = u"( %1 IS NULL OR %2 >= %3 )"_s.arg( fieldBegin, fieldBeginCasted, quoteValue( queryBegin ) );
235 }
236 }
237 else // <=
238 {
239 result = u"( %1 IS NULL OR %2 <= %3 )"_s.arg( fieldBegin, fieldBeginCasted, quoteValue( queryEnd ) );
240 }
241 return result;
242 };
243
244 // Determine if it is a date or a datetime interval (mixed are not supported)
245 QString testType { interval };
246 if ( interval.contains( '/' ) )
247 {
248 const QStringList parts { interval.split( '/' ) };
249 testType = parts[0];
250 if ( testType.isEmpty() || testType == ".."_L1 )
251 {
252 // cppcheck-suppress containerOutOfBounds
253 testType = parts[1];
254 }
255 }
256 // Determine query input type: datetime is always longer than 10 chars
257 const bool inputQueryIsDateTime { testType.length() > 10 };
258 const QMetaType::Type queryType { inputQueryIsDateTime ? QMetaType::Type::QDateTime : QMetaType::Type::QDate };
259
260 // Is it an interval?
261 if ( interval.contains( '/' ) )
262 {
263 if ( !inputQueryIsDateTime )
264 {
266
267 for ( const auto &dimension : std::as_const( dimensions ) )
268 {
269 // Determine the field type from the dimension name "time"/"date"
270 const QMetaType::Type fieldType { dimension.name.toLower() == "time"_L1 ? QMetaType::Type::QDateTime : QMetaType::Type::QDate };
271
272 const auto fieldBeginCasted { refFieldCast( dimension.fieldName, queryType, fieldType ) };
273 if ( fieldBeginCasted.isEmpty() )
274 {
275 continue;
276 }
277
278 const auto fieldBegin = QgsExpression::quotedColumnRef( dimension.fieldName );
279 const auto fieldEnd = QgsExpression::quotedColumnRef( dimension.endFieldName );
280
281 // This may be empty:
282 const auto fieldEndCasted { refFieldCast( dimension.endFieldName, queryType, fieldType ) };
283 if ( !dateInterval.begin().isValid() && !dateInterval.end().isValid() )
284 {
285 // Nothing to do here: log?
286 }
287 else
288 {
289 conditions.push_back( makeFilter( fieldBegin, fieldEnd, fieldBeginCasted, fieldEndCasted, dateInterval.begin().toString( Qt::DateFormat::ISODate ), dateInterval.end().toString( Qt::DateFormat::ISODate ) ) );
290 }
291 }
292 }
293 else // try datetime
294 {
296 for ( const auto &dimension : std::as_const( dimensions ) )
297 {
298 // Determine the field type from the dimension name "time"/"date"
299 const QMetaType::Type fieldType { dimension.name.toLower() == "time"_L1 ? QMetaType::Type::QDateTime : QMetaType::Type::QDate };
300
301 const auto fieldfBeginCasted { refFieldCast( dimension.fieldName, queryType, fieldType ) };
302 if ( fieldfBeginCasted.isEmpty() )
303 {
304 continue;
305 }
306 const auto fieldBegin = QgsExpression::quotedColumnRef( dimension.fieldName );
307 const auto fieldEnd = QgsExpression::quotedColumnRef( dimension.endFieldName );
308
309 // This may be empty:
310 const auto fieldEndCasted { refFieldCast( dimension.endFieldName, queryType, fieldType ) };
311 if ( !dateTimeInterval.begin().isValid() && !dateTimeInterval.end().isValid() )
312 {
313 // Nothing to do here: log?
314 }
315 else
316 {
317 // Cast the query value according to the field type
318 QString beginQuery;
319 QString endQuery;
320 // Drop the time
321 if ( fieldType == QMetaType::Type::QDate )
322 {
323 beginQuery = dateTimeInterval.begin().date().toString( Qt::DateFormat::ISODate );
324 endQuery = dateTimeInterval.end().date().toString( Qt::DateFormat::ISODate );
325 }
326 else
327 {
328 beginQuery = dateTimeInterval.begin().toString( Qt::DateFormat::ISODate );
329 endQuery = dateTimeInterval.end().toString( Qt::DateFormat::ISODate );
330 }
331 conditions.push_back( makeFilter( fieldBegin, fieldEnd, fieldfBeginCasted, fieldEndCasted, beginQuery, endQuery ) );
332 }
333 }
334 }
335 }
336 else // single value
337 {
338 for ( const auto &dimension : std::as_const( dimensions ) )
339 {
340 // Determine the field type from the dimension name "time"/"date"
341 const bool fieldIsDateTime { dimension.name.toLower() == "time"_L1 };
342 const QMetaType::Type fieldType { fieldIsDateTime ? QMetaType::Type::QDateTime : QMetaType::Type::QDate };
343
344 const auto fieldRefBegin { refFieldCast( dimension.fieldName, queryType, fieldType ) };
345 if ( fieldRefBegin.isEmpty() )
346 {
347 continue;
348 }
349 const auto fieldBegin = QgsExpression::quotedColumnRef( dimension.fieldName );
350
351 // This may be empty:
352 const auto fieldRefEnd { refFieldCast( dimension.endFieldName, queryType, fieldType ) };
353 const auto fieldEnd = QgsExpression::quotedColumnRef( dimension.endFieldName );
354
355 QString condition;
356 QString castedValue;
357
358 // field has possibly been downcasted
359 if ( !inputQueryIsDateTime || !fieldIsDateTime )
360 {
361 QString castedInterval { interval };
362 // Check if we need to downcast interval from datetime
363 if ( inputQueryIsDateTime )
364 {
365 castedInterval = QDate::fromString( castedInterval, Qt::DateFormat::ISODate ).toString( Qt::DateFormat::ISODate );
366 }
367 castedValue = u"to_date( %1 )"_s.arg( QgsExpression::quotedValue( castedInterval ) );
368 }
369 else
370 {
371 QString castedInterval { interval };
372 // Check if we need to upcast interval to datetime
373 if ( !inputQueryIsDateTime )
374 {
375 castedInterval = QDateTime::fromString( castedInterval, Qt::DateFormat::ISODate ).toString( Qt::DateFormat::ISODate );
376 }
377 castedValue = u"to_datetime( %1 )"_s.arg( QgsExpression::quotedValue( castedInterval ) );
378 }
379
380 if ( !fieldRefEnd.isEmpty() )
381 {
382 condition = u"( %1 IS NULL OR %2 <= %3 ) AND ( %5 IS NULL OR %3 <= %4 )"_s.arg( fieldBegin, fieldRefBegin, castedValue, fieldRefEnd, fieldEnd );
383 }
384 else
385 {
386 condition = u"( %1 IS NULL OR %2 = %3 )"_s
387 .arg( fieldBegin, fieldRefBegin, castedValue );
388 }
389 conditions.push_back( condition );
390 }
391 }
392 if ( !conditions.isEmpty() )
393 {
394 expression.setExpression( conditions.join( " AND "_L1 ) );
395 }
396 return expression;
397}
398
400{
401 auto extent { layer->extent() };
402 if ( layer->crs().authid() != "EPSG:4326"_L1 )
403 {
404 static const QgsCoordinateReferenceSystem targetCrs( u"EPSG:4326"_s );
405 const QgsCoordinateTransform ct( layer->crs(), targetCrs, layer->transformContext() );
406 extent = ct.transform( extent );
407 }
408 return { { extent.xMinimum(), extent.yMinimum(), extent.xMaximum(), extent.yMaximum() } };
409}
410
412{
413 // Helper to get min/max from a dimension
414 auto range = [&]( const QgsMapLayerServerProperties::WmsDimensionInfo &dimInfo ) -> QgsDateTimeRange {
415 QgsDateTimeRange result;
416 // min
417 int fieldIdx { layer->fields().lookupField( dimInfo.fieldName ) };
418 if ( fieldIdx < 0 )
419 {
420 return result;
421 }
422
423 QVariant minVal;
424 QVariant maxVal;
425 layer->minimumAndMaximumValue( fieldIdx, minVal, maxVal );
426
427 QDateTime min { minVal.toDateTime() };
428 QDateTime max { maxVal.toDateTime() };
429 if ( !dimInfo.endFieldName.isEmpty() )
430 {
431 fieldIdx = layer->fields().lookupField( dimInfo.endFieldName );
432 if ( fieldIdx >= 0 )
433 {
434 QVariant minVal;
435 QVariant maxVal;
436 layer->minimumAndMaximumValue( fieldIdx, minVal, maxVal );
437
438 QDateTime minEnd { minVal.toDateTime() };
439 QDateTime maxEnd { maxVal.toDateTime() };
440 if ( minEnd.isValid() )
441 {
442 min = std::min<QDateTime>( min, minEnd );
443 }
444 if ( maxEnd.isValid() )
445 {
446 max = std::max<QDateTime>( max, maxEnd );
447 }
448 }
449 }
450 return { min, max };
451 };
452
453 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> dimensions { QgsServerApiUtils::temporalDimensions( layer ) };
454 if ( dimensions.isEmpty() )
455 {
456 return nullptr;
457 }
458 else
459 {
460 try
461 {
462 QgsDateTimeRange extent;
463 bool isFirst = true;
464 for ( const auto &dimension : dimensions )
465 {
466 // Get min/max for dimension
467 if ( isFirst )
468 {
469 extent = range( dimension );
470 isFirst = false;
471 }
472 else
473 {
474 extent.extend( range( dimension ) );
475 }
476 }
477 json ret = json::array();
478 const QString beginVal { extent.begin().toString( Qt::DateFormat::ISODate ) };
479 const QString endVal { extent.end().toString( Qt::DateFormat::ISODate ) };
480 // We cannot mix nullptr and std::string :(
481 if ( beginVal.isEmpty() && endVal.isEmpty() )
482 {
483 ret.push_back( { nullptr, nullptr } );
484 }
485 else if ( beginVal.isEmpty() )
486 {
487 ret.push_back( { nullptr, endVal.toStdString() } );
488 }
489 else if ( endVal.isEmpty() )
490 {
491 ret.push_back( { beginVal.toStdString(), nullptr } );
492 }
493 else
494 {
495 ret.push_back( { beginVal.toStdString(), endVal.toStdString() } );
496 }
497 return ret;
498 }
499 catch ( std::exception &ex )
500 {
501 const QString errorMessage { u"Error creating temporal extent: %1"_s.arg( ex.what() ) };
502 QgsMessageLog::logMessage( errorMessage, u"Server"_s, Qgis::MessageLevel::Critical );
503 throw QgsServerApiInternalServerError( errorMessage );
504 }
505 }
506}
507
509{
510 QVariantList list;
511 list.push_back( QgsJsonUtils::parseArray( QString::fromStdString( temporalExtent( layer )[0].dump() ) ) );
512 return list;
513}
514
516{
517 // We get this:
518 // http://www.opengis.net/def/crs/OGC/1.3/CRS84
519 // We want this:
520 // "urn:ogc:def:crs:<auth>:[<version>]:<code>"
521 const auto parts { QUrl( bboxCrs ).path().split( '/' ) };
522 if ( parts.count() == 6 )
523 {
524 return QgsCoordinateReferenceSystem::fromOgcWmsCrs( u"urn:ogc:def:crs:%1:%2:%3"_s.arg( parts[3], parts[4], parts[5] ) );
525 }
526 else
527 {
529 }
530}
531
532const QVector<QgsVectorLayer *> QgsServerApiUtils::publishedWfsLayers( const QgsServerApiContext &context )
533{
534 return publishedWfsLayers<QgsVectorLayer *>( context );
535}
536
537QString QgsServerApiUtils::fieldName( const QString &name, const QgsVectorLayer *layer )
538{
539 if ( layer->fields().names().contains( name ) )
540 {
541 return name;
542 }
543 const QgsFields fields { layer->fields() };
544 for ( const QgsField &field : std::as_const( fields ) )
545 {
546 if ( field.displayName() == name )
547 {
548 return field.name();
549 }
550 }
551 throw QgsServerApiBadRequestException { u"Field '%1' is not a valid field name for layer: %2"_s.arg( name, layer->name() ) };
552}
553
554QString QgsServerApiUtils::sanitizedFieldValue( const QString &value )
555{
556 QString result { QUrl( value ).toString() };
557 return result.replace( '\'', "\'"_L1 );
558}
559
561{
562 // This must be always available in OGC APIs
563 QStringList result { { u"http://www.opengis.net/def/crs/OGC/1.3/CRS84"_s } };
564 if ( project )
565 {
566 const QStringList outputCrsList = QgsServerProjectUtils::wmsOutputCrsList( *project );
567 for ( const QString &crsId : outputCrsList )
568 {
569 const auto crsUri { QgsCoordinateReferenceSystem::fromOgcWmsCrs( crsId ).toOgcUri() };
570 if ( !crsUri.isEmpty() )
571 {
572 result.push_back( crsUri );
573 }
574 }
575 }
576 return result;
577}
578
580{
581 return crs.toOgcUri();
582}
583
584QString QgsServerApiUtils::appendMapParameter( const QString &path, const QUrl &requestUrl )
585{
586 QList<QPair<QString, QString>> qi;
587 QString result { path };
588 const auto constItems { QUrlQuery( requestUrl ).queryItems() };
589 for ( const auto &i : constItems )
590 {
591 if ( i.first.compare( u"MAP"_s, Qt::CaseSensitivity::CaseInsensitive ) == 0 )
592 {
593 qi.push_back( i );
594 }
595 }
596 if ( !qi.empty() )
597 {
598 if ( !path.endsWith( '?' ) )
599 {
600 result += '?';
601 }
602 result.append( u"MAP=%1"_s.arg( qi.first().second ) );
603 }
604 return result;
605}
@ Critical
Critical/error message.
Definition qgis.h:162
Represents a coordinate reference system (CRS).
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
QString toOgcUri() const
Returns the crs as OGC URI (format: http://www.opengis.net/def/crs/OGC/1.3/CRS84) Returns an empty st...
Handles coordinate transforms between two coordinate systems.
QgsPointXY transform(const QgsPointXY &point, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward) const
Transform the point from the source CRS to the destination CRS.
Handles parsing and evaluation of expressions (formerly called "search strings").
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required.
void setExpression(const QString &expression)
Set the expression string, will reset the whole internal structure.
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes).
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:56
QMetaType::Type type
Definition qgsfield.h:63
Container of fields for a vector layer.
Definition qgsfields.h:46
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QStringList names
Definition qgsfields.h:51
static Q_INVOKABLE QVariantList parseArray(const QString &json, QMetaType::Type type=QMetaType::Type::UnknownType)
Parse a simple array (depth=1).
Manages QGIS Server properties for a map layer.
QString name
Definition qgsmaplayer.h:87
QgsCoordinateReferenceSystem crs
Definition qgsmaplayer.h:90
QgsMapLayerServerProperties * serverProperties()
Returns QGIS Server Properties for the map layer.
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
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).
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:112
A rectangle specified with double values.
Bad request error API exception.
Encapsulates the resources for a particular client request.
Internal server error API exception.
static QString sanitizedFieldValue(const QString &value)
Sanitizes the input value by removing URL encoding.
static QgsExpression temporalFilterExpression(const QgsVectorLayer *layer, const QString &interval)
Parses the interval and constructs a (possibly invalid) temporal filter expression for the given laye...
static QStringList publishedCrsList(const QgsProject *project)
Returns the list of CRSs (format: http://www.opengis.net/def/crs/OGC/1.3/CRS84) available for this pr...
static QVariantList temporalExtentList(const QgsVectorLayer *layer)
temporalExtent returns a json array with an array of [min, max] temporal extent for the given layer.
static QString fieldName(const QString &name, const QgsVectorLayer *layer)
Given a field name (or display name) and a layer returns the actual name of the field.
static QgsCoordinateReferenceSystem parseCrs(const QString &bboxCrs)
Parses the CRS URI bboxCrs (example: "http://www.opengis.net/def/crs/OGC/1.3/CRS84") into a QGIS CRS ...
static Q_DECL_DEPRECATED QString crsToOgcUri(const QgsCoordinateReferenceSystem &crs)
Returns a crs as OGC URI (format: http://www.opengis.net/def/crs/OGC/1.3/CRS84) Returns an empty stri...
static json temporalExtent(const QgsVectorLayer *layer)
temporalExtent returns a json array with an array of [min, max] temporal extent for the given layer.
static const QVector< QgsVectorLayer * > publishedWfsLayers(const QgsServerApiContext &context)
Returns the list of layers accessible to the service for a given context.
static json layerExtent(const QgsVectorLayer *layer)
layerExtent returns json array with [xMin,yMin,xMax,yMax] CRS84 extent for the given layer
static QgsDateTimeRange parseTemporalDateTimeInterval(const QString &interval)
Parses a datetime interval and returns a QgsDateTimeRange.
static QgsDateRange parseTemporalDateInterval(const QString &interval)
Parses a date interval and returns a QgsDateRange.
static QList< QgsServerWmsDimensionProperties::WmsDimensionInfo > temporalDimensions(const QgsVectorLayer *layer)
Returns a list of temporal dimensions information for the given layer (either configured in wmsDimens...
static QgsRectangle parseBbox(const QString &bbox)
Parses a comma separated bbox into a (possibly empty) QgsRectangle.
static QString appendMapParameter(const QString &path, const QUrl &requestUrl)
Appends MAP query string parameter from current requestUrl to the given path.
static QStringList wmsOutputCrsList(const QgsProject &project)
Returns the WMS output CRS list.
const QList< QgsServerWmsDimensionProperties::WmsDimensionInfo > wmsDimensions() const
Returns the QGIS Server WMS Dimension list.
T begin() const
Returns the beginning of the range.
Definition qgsrange.h:449
bool extend(const QgsTemporalRange< T > &other)
Extends the range in place by extending this range out to include an other range.
Definition qgsrange.h:625
T end() const
Returns the upper bound of the range.
Definition qgsrange.h:456
Represents a vector layer which manages a vector based dataset.
QgsRectangle extent() const final
Returns the extent of the layer.
void minimumAndMaximumValue(int index, QVariant &minimum, QVariant &maximum) const
Calculates both the minimum and maximum value for an attribute column.
#define SIP_PYNAME(name)
Definition qgis_sip.h:89
QgsTemporalRange< QDate > QgsDateRange
QgsRange which stores a range of dates.
Definition qgsrange.h:750
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:764
Setting to define QGIS Server WMS Dimension.