22 #include "qgis_core.h"
181 return ( !
operator==( other ) );
217 double upper = std::numeric_limits< double >::max(),
218 bool includeLower =
true,
bool includeUpper =
true )
229 bool includeLower =
true,
bool includeUpper =
true )
239 :
QgsRange( std::numeric_limits< double >::lowest(), std::numeric_limits< double >::max(), true, true )
249 return lower() == std::numeric_limits< double >::lowest() &&
upper() == std::numeric_limits< double >::max();
253 SIP_PYOBJECT __repr__();
255 QString
str = QStringLiteral(
"<QgsDoubleRange: %1%2, %3%4>" ).arg( sipCpp->includeLower() ? QStringLiteral(
"[" ) : QStringLiteral(
"(" ) )
256 .arg( sipCpp->lower() )
257 .arg( sipCpp->upper() )
258 .arg( sipCpp->includeUpper() ? QStringLiteral(
"]" ) : QStringLiteral(
")" ) );
259 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
273 return ( !
operator==( other ) );
302 int upper = std::numeric_limits< int >::max(),
303 bool includeLower =
true,
bool includeUpper =
true )
314 bool includeLower =
true,
bool includeUpper =
true )
324 :
QgsRange( std::numeric_limits< int >::lowest(), std::numeric_limits< int >::max(), true, true )
334 return lower() == std::numeric_limits< int >::lowest() &&
upper() == std::numeric_limits< int >::max();
338 SIP_PYOBJECT __repr__();
340 QString
str = QStringLiteral(
"<QgsIntRange: %1%2, %3%4>" ).arg( sipCpp->includeLower() ? QStringLiteral(
"[" ) : QStringLiteral(
"(" ) )
341 .arg( sipCpp->lower() )
342 .arg( sipCpp->upper() )
343 .arg( sipCpp->includeUpper() ? QStringLiteral(
"]" ) : QStringLiteral(
")" ) );
344 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
367 template <
typename T>
401 T
end()
const {
return mUpper; }
423 bool isInstant()
const {
return mLower.isValid() && mUpper.isValid() && mLower == mUpper && ( mIncludeLower || mIncludeUpper ); }
432 return !mLower.isValid() && !mUpper.isValid();
442 if ( !mLower.isValid() && !mUpper.isValid() )
445 if ( mLower.isValid() != mUpper.isValid() )
448 if ( mLower > mUpper )
451 if ( mLower == mUpper && !( mIncludeLower || mIncludeUpper ) )
462 if ( !other.mLower.isValid() && mLower.isValid() )
465 if ( mLower.isValid() )
467 const bool lowerOk = ( mIncludeLower && mLower <= other.mLower )
468 || ( !mIncludeLower && mLower < other.mLower )
469 || ( !mIncludeLower && !other.mIncludeLower && mLower <= other.mLower );
474 if ( !other.mUpper.isValid() && mUpper.isValid() )
477 if ( mUpper.isValid() )
479 const bool upperOk = ( mIncludeUpper && mUpper >= other.mUpper )
480 || ( !mIncludeUpper && mUpper > other.mUpper )
481 || ( !mIncludeUpper && !other.mIncludeUpper && mUpper >= other.mUpper );
494 if ( !element.isValid() )
497 if ( mLower.isValid() )
499 const bool lowerOk = ( mIncludeLower && mLower <= element )
500 || ( !mIncludeLower && mLower < element );
505 if ( mUpper.isValid() )
507 const bool upperOk = ( mIncludeUpper && mUpper >= element )
508 || ( !mIncludeUpper && mUpper > element );
521 if ( !mUpper.isValid() && ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) ) )
524 if ( ( ( mIncludeLower && mLower <= other.mLower ) || ( !mIncludeLower && mLower < other.mLower ) )
525 && ( ( mIncludeUpper && mUpper >= other.mUpper ) || ( !mIncludeUpper && mUpper > other.mUpper ) ) )
528 if ( ( ( mIncludeLower && mLower <= other.mLower ) || ( !mIncludeLower && mLower < other.mLower ) )
529 && ( ( mIncludeUpper && mUpper >= other.mLower ) || ( !mIncludeUpper && mUpper > other.mLower ) ) )
532 if ( ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) )
533 && ( ( mIncludeUpper && mUpper >= other.mUpper ) || ( !mIncludeUpper && mUpper > other.mUpper ) ) )
536 if ( ( ( mIncludeLower && mLower >= other.mLower ) || ( !mIncludeLower && mLower > other.mLower ) )
537 && ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) ) )
540 if ( mLower == other.mLower && mUpper == other.mUpper )
562 mLower = other.
begin();
563 mUpper = other.
end();
570 bool changed {
false };
573 if ( ! other.
begin().isValid()
574 || (
begin().isValid() && other.
begin() < mLower ) )
576 mLower = other.
begin();
582 mIncludeLower =
true;
587 if ( ! other.
end().isValid()
588 || (
end().isValid() && other.
end() > mUpper ) )
590 mUpper = other.
end();
594 else if ( other.
end() == mUpper && other.
includeEnd() && ! mIncludeUpper )
596 mIncludeUpper =
true;
619 if ( ranges.empty() )
622 QList< QgsTemporalRange<T > > sortedRanges = ranges;
624 QList< QgsTemporalRange<T>> res;
625 res.reserve( sortedRanges.size() );
628 auto it = sortedRanges.constBegin();
630 for ( ; it != sortedRanges.constEnd(); ++it )
649 return mLower == other.mLower &&
650 mUpper == other.mUpper &&
657 return ( !
operator==( other ) );
664 bool mIncludeLower =
true;
665 bool mIncludeUpper =
true;
QgsRange which stores a range of double values.
QgsDoubleRange(double lower=std::numeric_limits< double >::lowest(), double upper=std::numeric_limits< double >::max(), bool includeLower=true, bool includeUpper=true)
Constructor for QgsDoubleRange.
bool operator==(const QgsDoubleRange &other) const
bool isInfinite() const
Returns true if the range consists of all possible values.
bool operator!=(const QgsDoubleRange &other) const
QgsRange which stores a range of integer values.
bool isInfinite() const
Returns true if the range consists of all possible values.
QgsIntRange(int lower=std::numeric_limits< int >::lowest(), int upper=std::numeric_limits< int >::max(), bool includeLower=true, bool includeUpper=true)
Constructor for QgsIntRange.
A template based class for storing ranges (lower to upper values).
bool includeUpper() const
Returns true if the upper bound is inclusive, or false if the upper bound is exclusive.
bool overlaps(const QgsRange< T > &other) const
Returns true if this range overlaps another range.
QgsRange(T lower, T upper, bool includeLower=true, bool includeUpper=true)
Constructor for QgsRange.
bool contains(const QgsRange< T > &other) const
Returns true if this range contains another range.
T lower() const
Returns the lower bound of the range.
bool includeLower() const
Returns true if the lower bound is inclusive, or false if the lower bound is exclusive.
T upper() const
Returns the upper bound of the range.
bool isSingleton() const
Returns true if the range consists only of a single value or instant.
bool operator!=(const QgsRange< T > &other) const
bool contains(T element) const
Returns true if this range contains a specified element.
bool operator==(const QgsRange< T > &other) const
bool isEmpty() const
Returns true if the range is empty, ie the lower bound equals (or exceeds) the upper bound and either...
A template based class for storing temporal ranges (beginning to end values).
static QList< QgsTemporalRange< T > > mergeRanges(const QList< QgsTemporalRange< T > > &ranges)
Merges a list of temporal ranges.
bool contains(const T &element) const
Returns true if this range contains a specified element.
T begin() const
Returns the beginning of the range.
bool contains(const QgsTemporalRange< T > &other) const
Returns true if this range contains another range.
bool extend(const QgsTemporalRange< T > &other)
Extends the range in place by extending this range out to include an other range.
T end() const
Returns the upper bound of the range.
bool isInstant() const
Returns true if the range consists only of a single instant.
bool operator!=(const QgsTemporalRange< T > &other) const
QgsTemporalRange(const T &begin=T(), const T &end=T(), bool includeBeginning=true, bool includeEnd=true)
Constructor for QgsTemporalRange.
bool operator==(const QgsTemporalRange< T > &other) const
bool overlaps(const QgsTemporalRange< T > &other) const
Returns true if this range overlaps another range.
bool includeEnd() const
Returns true if the end is inclusive, or false if the end is exclusive.
bool includeBeginning() const
Returns true if the beginning is inclusive, or false if the beginning is exclusive.
bool isEmpty() const
Returns true if the range is empty, ie the beginning equals (or exceeds) the end and either of the bo...
bool isInfinite() const
Returns true if the range consists of all possible values.
int ANALYSIS_EXPORT lower(int n, int i)
Lower function.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
QgsTemporalRange< QDate > QgsDateRange SIP_DOC_TEMPLATE
QgsRange which stores a range of dates.