QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 <QUrl>
31#include <QUrlQuery>
32
34{
35 const QStringList parts { bbox.split( ',', Qt::SplitBehaviorFlags::SkipEmptyParts ) };
36 // Note: Z is ignored
37 bool ok { true };
38 if ( parts.count() == 4 || parts.count() == 6 )
39 {
40 const auto hasZ { parts.count() == 6 };
41 auto toDouble = [&]( const int i ) -> double {
42 if ( !ok )
43 return 0;
44 return parts[i].toDouble( &ok );
45 };
46 QgsRectangle rect;
47 if ( hasZ )
48 {
49 rect = QgsRectangle( toDouble( 0 ), toDouble( 1 ), toDouble( 3 ), toDouble( 4 ) );
50 }
51 else
52 {
53 rect = QgsRectangle( toDouble( 0 ), toDouble( 1 ), toDouble( 2 ), toDouble( 3 ) );
54 }
55 if ( ok )
56 {
57 return rect;
58 }
59 }
60 return QgsRectangle();
61}
62
63QList<QgsMapLayerServerProperties::WmsDimensionInfo> QgsServerApiUtils::temporalDimensions( const QgsVectorLayer *layer )
64{
65 if ( !layer )
66 return {};
67
68 const QgsMapLayerServerProperties *serverProperties = layer->serverProperties();
69 QList<QgsMapLayerServerProperties::WmsDimensionInfo> dimensions { serverProperties->wmsDimensions() };
70 // Filter only date and time
71 dimensions.erase( std::remove_if( dimensions.begin(), dimensions.end(), []( QgsMapLayerServerProperties::WmsDimensionInfo &dim ) {
72 return dim.name.toLower() != QStringLiteral( "time" )
73 && dim.name.toLower() != QLatin1String( "date" );
74 } ),
75 dimensions.end() );
76
77 // Automatically pick up the first date/datetime field if dimensions is empty
78 if ( dimensions.isEmpty() )
79 {
80 const auto constFields { layer->fields() };
81 for ( const auto &f : constFields )
82 {
83 if ( f.isDateOrTime() )
84 {
85 dimensions.append( QgsMapLayerServerProperties::WmsDimensionInfo( f.type() == QMetaType::Type::QDateTime ? QStringLiteral( "time" ) : QStringLiteral( "date" ), f.name() ) );
86 break;
87 }
88 }
89 }
90 return dimensions;
91}
92
94template<typename T, class T2> T QgsServerApiUtils::parseTemporalInterval( const QString &interval )
95{
96 auto parseDate = []( const QString &date ) -> T2 {
97 T2 result;
98 if ( date == QLatin1String( ".." ) || date.isEmpty() )
99 {
100 return result;
101 }
102 else
103 {
104 T2 result { T2::fromString( date, Qt::DateFormat::ISODate ) };
105 if ( !result.isValid() )
106 {
107 throw QgsServerApiBadRequestException( QStringLiteral( "%1 is not a valid date/datetime." ).arg( date ) );
108 }
109 return result;
110 }
111 };
112 const QStringList parts { interval.split( '/' ) };
113 if ( parts.size() != 2 )
114 {
115 throw QgsServerApiBadRequestException( QStringLiteral( "%1 is not a valid datetime interval." ).arg( interval ), QStringLiteral( "Server" ) );
116 }
117 // cppcheck-suppress containerOutOfBounds
118 T result { parseDate( parts[0] ), parseDate( parts[1] ) };
119 // Check validity
120 if ( result.isEmpty() )
121 {
122 throw QgsServerApiBadRequestException( QStringLiteral( "%1 is not a valid datetime interval (empty)." ).arg( interval ), QStringLiteral( "Server" ) );
123 }
124 return result;
125}
127
129{
130 return QgsServerApiUtils::parseTemporalInterval<QgsDateRange, QDate>( interval );
131}
132
134{
135 return QgsServerApiUtils::parseTemporalInterval<QgsDateTimeRange, QDateTime>( interval );
136}
137
139{
140 QgsExpression expression;
141 QStringList conditions;
142
143 const auto dimensions { QgsServerApiUtils::temporalDimensions( layer ) };
144 if ( dimensions.isEmpty() )
145 {
146 return expression;
147 }
148
149 // helper to get the field type from the field name
150 auto fieldTypeFromName = [&]( const QString &fieldName, const QgsVectorLayer *layer ) -> QMetaType::Type {
151 int fieldIdx { layer->fields().lookupField( fieldName ) };
152 if ( fieldIdx < 0 )
153 {
154 return QMetaType::Type::UnknownType;
155 }
156 const QgsField field { layer->fields().at( fieldIdx ) };
157 return field.type();
158 };
159
160 // helper to cast the field value
161 auto refFieldCast = [&]( const QString &fieldName, QMetaType::Type queryType, QMetaType::Type fieldType ) -> QString {
162 const auto fieldRealType { fieldTypeFromName( fieldName, layer ) };
163 if ( fieldRealType == QMetaType::Type::UnknownType )
164 {
165 return QString();
166 }
167
168 // Downcast only datetime -> date
169 // always cast strings
170 if ( fieldRealType == QMetaType::Type::QString )
171 {
172 // Cast to query type but only downcast
173 if ( fieldType != queryType || fieldType == QMetaType::Type::QDate )
174 {
175 return QStringLiteral( "to_date( %1 )" ).arg( QgsExpression::quotedColumnRef( fieldName ) );
176 }
177 else
178 {
179 return QStringLiteral( "%2( %1 )" ).arg( QgsExpression::quotedColumnRef( fieldName ) ).arg( queryType == QMetaType::Type::QDate ? QStringLiteral( "to_date" ) : QStringLiteral( "to_datetime" ) );
180 }
181 }
182 else if ( fieldType == queryType || fieldType == QMetaType::Type::QDate )
183 {
185 }
186 else
187 {
188 return QStringLiteral( "%2( %1 )" ).arg( QgsExpression::quotedColumnRef( fieldName ) ).arg( queryType == QMetaType::Type::QDate ? QStringLiteral( "to_date" ) : QStringLiteral( "to_datetime" ) );
189 }
190 };
191
192 // Quote and cast a query value
193 auto quoteValue = []( const QString &value ) -> QString {
194 if ( value.length() == 10 )
195 {
196 return QStringLiteral( "to_date( %1 )" ).arg( QgsExpression::quotedValue( value ) );
197 }
198 else
199 {
200 return QStringLiteral( "to_datetime( %1 )" ).arg( QgsExpression::quotedValue( value ) );
201 }
202 };
203
204 // helper to build the interval filter, fieldType is the underlying field type, queryType is the input query type
205 auto makeFilter = [&quoteValue]( const QString &fieldBegin, const QString &fieldEnd, const QString &fieldBeginCasted, const QString &fieldEndCasted, const QString &queryBegin, const QString &queryEnd ) -> QString {
206 QString result;
207
208 // It's a closed interval query, go for overlap
209 if ( !queryBegin.isEmpty() && !queryEnd.isEmpty() )
210 {
211 // Overlap of two intervals
212 if ( !fieldEndCasted.isEmpty() )
213 {
214 result = QStringLiteral( "( %1 IS NULL OR %2 <= %6 ) AND ( %4 IS NULL OR %5 >= %3 )" )
215 .arg( fieldBegin, fieldBeginCasted, quoteValue( queryBegin ), fieldEnd, fieldEndCasted, quoteValue( queryEnd ) );
216 }
217 else // Overlap of single value
218 {
219 result = QStringLiteral( "( %1 IS NULL OR ( %2 <= %3 AND %3 <= %4 ) )" )
220 .arg( fieldBegin, quoteValue( queryBegin ), fieldBeginCasted, quoteValue( queryEnd ) );
221 }
222 }
223 else if ( !queryBegin.isEmpty() ) // >=
224 {
225 if ( !fieldEndCasted.isEmpty() )
226 {
227 result = QStringLiteral( "( %1 IS NULL OR %2 >= %3 )" ).arg( fieldEnd, fieldEndCasted, quoteValue( queryBegin ) );
228 }
229 else
230 {
231 result = QStringLiteral( "( %1 IS NULL OR %2 >= %3 )" ).arg( fieldBegin, fieldBeginCasted, quoteValue( queryBegin ) );
232 }
233 }
234 else // <=
235 {
236 result = QStringLiteral( "( %1 IS NULL OR %2 <= %3 )" ).arg( fieldBegin, fieldBeginCasted, quoteValue( queryEnd ) );
237 }
238 return result;
239 };
240
241 // Determine if it is a date or a datetime interval (mixed are not supported)
242 QString testType { interval };
243 if ( interval.contains( '/' ) )
244 {
245 const QStringList parts { interval.split( '/' ) };
246 testType = parts[0];
247 if ( testType.isEmpty() || testType == QLatin1String( ".." ) )
248 {
249 // cppcheck-suppress containerOutOfBounds
250 testType = parts[1];
251 }
252 }
253 // Determine query input type: datetime is always longer than 10 chars
254 const bool inputQueryIsDateTime { testType.length() > 10 };
255 const QMetaType::Type queryType { inputQueryIsDateTime ? QMetaType::Type::QDateTime : QMetaType::Type::QDate };
256
257 // Is it an interval?
258 if ( interval.contains( '/' ) )
259 {
260 if ( !inputQueryIsDateTime )
261 {
263
264 for ( const auto &dimension : std::as_const( dimensions ) )
265 {
266 // Determine the field type from the dimension name "time"/"date"
267 const QMetaType::Type fieldType { dimension.name.toLower() == QLatin1String( "time" ) ? QMetaType::Type::QDateTime : QMetaType::Type::QDate };
268
269 const auto fieldBeginCasted { refFieldCast( dimension.fieldName, queryType, fieldType ) };
270 if ( fieldBeginCasted.isEmpty() )
271 {
272 continue;
273 }
274
275 const auto fieldBegin = QgsExpression::quotedColumnRef( dimension.fieldName );
276 const auto fieldEnd = QgsExpression::quotedColumnRef( dimension.endFieldName );
277
278 // This may be empty:
279 const auto fieldEndCasted { refFieldCast( dimension.endFieldName, queryType, fieldType ) };
280 if ( !dateInterval.begin().isValid() && !dateInterval.end().isValid() )
281 {
282 // Nothing to do here: log?
283 }
284 else
285 {
286 conditions.push_back( makeFilter( fieldBegin, fieldEnd, fieldBeginCasted, fieldEndCasted, dateInterval.begin().toString( Qt::DateFormat::ISODate ), dateInterval.end().toString( Qt::DateFormat::ISODate ) ) );
287 }
288 }
289 }
290 else // try datetime
291 {
293 for ( const auto &dimension : std::as_const( dimensions ) )
294 {
295 // Determine the field type from the dimension name "time"/"date"
296 const QMetaType::Type fieldType { dimension.name.toLower() == QLatin1String( "time" ) ? QMetaType::Type::QDateTime : QMetaType::Type::QDate };
297
298 const auto fieldfBeginCasted { refFieldCast( dimension.fieldName, queryType, fieldType ) };
299 if ( fieldfBeginCasted.isEmpty() )
300 {
301 continue;
302 }
303 const auto fieldBegin = QgsExpression::quotedColumnRef( dimension.fieldName );
304 const auto fieldEnd = QgsExpression::quotedColumnRef( dimension.endFieldName );
305
306 // This may be empty:
307 const auto fieldEndCasted { refFieldCast( dimension.endFieldName, queryType, fieldType ) };
308 if ( !dateTimeInterval.begin().isValid() && !dateTimeInterval.end().isValid() )
309 {
310 // Nothing to do here: log?
311 }
312 else
313 {
314 // Cast the query value according to the field type
315 QString beginQuery;
316 QString endQuery;
317 // Drop the time
318 if ( fieldType == QMetaType::Type::QDate )
319 {
320 beginQuery = dateTimeInterval.begin().date().toString( Qt::DateFormat::ISODate );
321 endQuery = dateTimeInterval.end().date().toString( Qt::DateFormat::ISODate );
322 }
323 else
324 {
325 beginQuery = dateTimeInterval.begin().toString( Qt::DateFormat::ISODate );
326 endQuery = dateTimeInterval.end().toString( Qt::DateFormat::ISODate );
327 }
328 conditions.push_back( makeFilter( fieldBegin, fieldEnd, fieldfBeginCasted, fieldEndCasted, beginQuery, endQuery ) );
329 }
330 }
331 }
332 }
333 else // single value
334 {
335 for ( const auto &dimension : std::as_const( dimensions ) )
336 {
337 // Determine the field type from the dimension name "time"/"date"
338 const bool fieldIsDateTime { dimension.name.toLower() == QLatin1String( "time" ) };
339 const QMetaType::Type fieldType { fieldIsDateTime ? QMetaType::Type::QDateTime : QMetaType::Type::QDate };
340
341 const auto fieldRefBegin { refFieldCast( dimension.fieldName, queryType, fieldType ) };
342 if ( fieldRefBegin.isEmpty() )
343 {
344 continue;
345 }
346 const auto fieldBegin = QgsExpression::quotedColumnRef( dimension.fieldName );
347
348 // This may be empty:
349 const auto fieldRefEnd { refFieldCast( dimension.endFieldName, queryType, fieldType ) };
350 const auto fieldEnd = QgsExpression::quotedColumnRef( dimension.endFieldName );
351
352 QString condition;
353 QString castedValue;
354
355 // field has possibly been downcasted
356 if ( !inputQueryIsDateTime || !fieldIsDateTime )
357 {
358 QString castedInterval { interval };
359 // Check if we need to downcast interval from datetime
360 if ( inputQueryIsDateTime )
361 {
362 castedInterval = QDate::fromString( castedInterval, Qt::DateFormat::ISODate ).toString( Qt::DateFormat::ISODate );
363 }
364 castedValue = QStringLiteral( "to_date( %1 )" ).arg( QgsExpression::quotedValue( castedInterval ) );
365 }
366 else
367 {
368 QString castedInterval { interval };
369 // Check if we need to upcast interval to datetime
370 if ( !inputQueryIsDateTime )
371 {
372 castedInterval = QDateTime::fromString( castedInterval, Qt::DateFormat::ISODate ).toString( Qt::DateFormat::ISODate );
373 }
374 castedValue = QStringLiteral( "to_datetime( %1 )" ).arg( QgsExpression::quotedValue( castedInterval ) );
375 }
376
377 if ( !fieldRefEnd.isEmpty() )
378 {
379 condition = QStringLiteral( "( %1 IS NULL OR %2 <= %3 ) AND ( %5 IS NULL OR %3 <= %4 )" ).arg( fieldBegin, fieldRefBegin, castedValue, fieldRefEnd, fieldEnd );
380 }
381 else
382 {
383 condition = QStringLiteral( "( %1 IS NULL OR %2 = %3 )" )
384 .arg( fieldBegin, fieldRefBegin, castedValue );
385 }
386 conditions.push_back( condition );
387 }
388 }
389 if ( !conditions.isEmpty() )
390 {
391 expression.setExpression( conditions.join( QLatin1String( " AND " ) ) );
392 }
393 return expression;
394}
395
397{
398 auto extent { layer->extent() };
399 if ( layer->crs().authid() != QLatin1String( "EPSG:4326" ) )
400 {
401 static const QgsCoordinateReferenceSystem targetCrs( QStringLiteral( "EPSG:4326" ) );
402 const QgsCoordinateTransform ct( layer->crs(), targetCrs, layer->transformContext() );
403 extent = ct.transform( extent );
404 }
405 return { { extent.xMinimum(), extent.yMinimum(), extent.xMaximum(), extent.yMaximum() } };
406}
407
409{
410 // Helper to get min/max from a dimension
411 auto range = [&]( const QgsMapLayerServerProperties::WmsDimensionInfo &dimInfo ) -> QgsDateTimeRange {
412 QgsDateTimeRange result;
413 // min
414 int fieldIdx { layer->fields().lookupField( dimInfo.fieldName ) };
415 if ( fieldIdx < 0 )
416 {
417 return result;
418 }
419
420 QVariant minVal;
421 QVariant maxVal;
422 layer->minimumAndMaximumValue( fieldIdx, minVal, maxVal );
423
424 QDateTime min { minVal.toDateTime() };
425 QDateTime max { maxVal.toDateTime() };
426 if ( !dimInfo.endFieldName.isEmpty() )
427 {
428 fieldIdx = layer->fields().lookupField( dimInfo.endFieldName );
429 if ( fieldIdx >= 0 )
430 {
431 QVariant minVal;
432 QVariant maxVal;
433 layer->minimumAndMaximumValue( fieldIdx, minVal, maxVal );
434
435 QDateTime minEnd { minVal.toDateTime() };
436 QDateTime maxEnd { maxVal.toDateTime() };
437 if ( minEnd.isValid() )
438 {
439 min = std::min<QDateTime>( min, minEnd );
440 }
441 if ( maxEnd.isValid() )
442 {
443 max = std::max<QDateTime>( max, maxEnd );
444 }
445 }
446 }
447 return { min, max };
448 };
449
450 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> dimensions { QgsServerApiUtils::temporalDimensions( layer ) };
451 if ( dimensions.isEmpty() )
452 {
453 return nullptr;
454 }
455 else
456 {
457 try
458 {
459 QgsDateTimeRange extent;
460 bool isFirst = true;
461 for ( const auto &dimension : dimensions )
462 {
463 // Get min/max for dimension
464 if ( isFirst )
465 {
466 extent = range( dimension );
467 isFirst = false;
468 }
469 else
470 {
471 extent.extend( range( dimension ) );
472 }
473 }
474 json ret = json::array();
475 const QString beginVal { extent.begin().toString( Qt::DateFormat::ISODate ) };
476 const QString endVal { extent.end().toString( Qt::DateFormat::ISODate ) };
477 // We cannot mix nullptr and std::string :(
478 if ( beginVal.isEmpty() && endVal.isEmpty() )
479 {
480 ret.push_back( { nullptr, nullptr } );
481 }
482 else if ( beginVal.isEmpty() )
483 {
484 ret.push_back( { nullptr, endVal.toStdString() } );
485 }
486 else if ( endVal.isEmpty() )
487 {
488 ret.push_back( { beginVal.toStdString(), nullptr } );
489 }
490 else
491 {
492 ret.push_back( { beginVal.toStdString(), endVal.toStdString() } );
493 }
494 return ret;
495 }
496 catch ( std::exception &ex )
497 {
498 const QString errorMessage { QStringLiteral( "Error creating temporal extent: %1" ).arg( ex.what() ) };
499 QgsMessageLog::logMessage( errorMessage, QStringLiteral( "Server" ), Qgis::MessageLevel::Critical );
500 throw QgsServerApiInternalServerError( errorMessage );
501 }
502 }
503}
504
506{
507 QVariantList list;
508 list.push_back( QgsJsonUtils::parseArray( QString::fromStdString( temporalExtent( layer )[0].dump() ) ) );
509 return list;
510}
511
513{
514 // We get this:
515 // http://www.opengis.net/def/crs/OGC/1.3/CRS84
516 // We want this:
517 // "urn:ogc:def:crs:<auth>:[<version>]:<code>"
518 const auto parts { QUrl( bboxCrs ).path().split( '/' ) };
519 if ( parts.count() == 6 )
520 {
521 return QgsCoordinateReferenceSystem::fromOgcWmsCrs( QStringLiteral( "urn:ogc:def:crs:%1:%2:%3" ).arg( parts[3], parts[4], parts[5] ) );
522 }
523 else
524 {
526 }
527}
528
529const QVector<QgsVectorLayer *> QgsServerApiUtils::publishedWfsLayers( const QgsServerApiContext &context )
530{
531 return publishedWfsLayers<QgsVectorLayer *>( context );
532}
533
534QString QgsServerApiUtils::fieldName( const QString &name, const QgsVectorLayer *layer )
535{
536 if ( layer->fields().names().contains( name ) )
537 {
538 return name;
539 }
540 const QgsFields fields { layer->fields() };
541 for ( const QgsField &field : std::as_const( fields ) )
542 {
543 if ( field.displayName() == name )
544 {
545 return field.name();
546 }
547 }
548 throw QgsServerApiBadRequestException { QStringLiteral( "Field '%1' is not a valid field name for layer: %2" ).arg( name, layer->name() ) };
549}
550
551QString QgsServerApiUtils::sanitizedFieldValue( const QString &value )
552{
553 QString result { QUrl( value ).toString() };
554 return result.replace( '\'', QLatin1String( "\'" ) );
555}
556
558{
559 // This must be always available in OGC APIs
560 QStringList result { { QStringLiteral( "http://www.opengis.net/def/crs/OGC/1.3/CRS84" ) } };
561 if ( project )
562 {
563 const QStringList outputCrsList = QgsServerProjectUtils::wmsOutputCrsList( *project );
564 for ( const QString &crsId : outputCrsList )
565 {
566 const auto crsUri { QgsCoordinateReferenceSystem::fromOgcWmsCrs( crsId ).toOgcUri() };
567 if ( !crsUri.isEmpty() )
568 {
569 result.push_back( crsUri );
570 }
571 }
572 }
573 return result;
574}
575
577{
578 return crs.toOgcUri();
579}
580
581QString QgsServerApiUtils::appendMapParameter( const QString &path, const QUrl &requestUrl )
582{
583 QList<QPair<QString, QString>> qi;
584 QString result { path };
585 const auto constItems { QUrlQuery( requestUrl ).queryItems() };
586 for ( const auto &i : constItems )
587 {
588 if ( i.first.compare( QStringLiteral( "MAP" ), Qt::CaseSensitivity::CaseInsensitive ) == 0 )
589 {
590 qi.push_back( i );
591 }
592 }
593 if ( !qi.empty() )
594 {
595 if ( !path.endsWith( '?' ) )
596 {
597 result += '?';
598 }
599 result.append( QStringLiteral( "MAP=%1" ).arg( qi.first().second ) );
600 }
601 return result;
602}
@ Critical
Critical/error message.
Definition qgis.h:159
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:54
QMetaType::Type type
Definition qgsfield.h:61
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:84
QgsCoordinateReferenceSystem crs
Definition qgsmaplayer.h:87
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:109
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:446
bool extend(const QgsTemporalRange< T > &other)
Extends the range in place by extending this range out to include an other range.
Definition qgsrange.h:622
T end() const
Returns the upper bound of the range.
Definition qgsrange.h:453
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:747
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:761
Setting to define QGIS Server WMS Dimension.