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