Skip to content

Commit

Permalink
More appropriate equality operator for QgsDoubleRange
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 25, 2020
1 parent 867dc85 commit 928c969
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions python/core/auto_generated/qgsrange.sip.in
Expand Up @@ -121,6 +121,9 @@ Returns ``True`` if this range overlaps another range.

bool operator!=( const QgsRange<T> &other ) const;

protected:


};


Expand Down Expand Up @@ -179,6 +182,10 @@ Returns ``True`` if the range consists of all possible values.
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

bool operator==( const QgsDoubleRange &other ) const;

bool operator!=( const QgsDoubleRange &other ) const;

};


Expand Down
16 changes: 15 additions & 1 deletion src/core/qgsrange.h
Expand Up @@ -20,6 +20,7 @@

#include "qgis_sip.h"
#include "qgis_core.h"
#include "qgis.h"

#include <QDate>
#include <QDateTime>
Expand Down Expand Up @@ -180,7 +181,7 @@ class QgsRange
return ( ! operator==( other ) );
}

private:
protected:

T mLower;
T mUpper;
Expand Down Expand Up @@ -259,6 +260,19 @@ class CORE_EXPORT QgsDoubleRange : public QgsRange< double >
% End
#endif

bool operator==( const QgsDoubleRange &other ) const
{
return qgsDoubleNear( mIncludeLower, other.mIncludeLower ) &&
qgsDoubleNear( mIncludeUpper, other.mIncludeUpper ) &&
mIncludeLower == other.includeLower() &&
mIncludeUpper == other.includeUpper();
}

bool operator!=( const QgsDoubleRange &other ) const
{
return ( ! operator==( other ) );
}

};


Expand Down

0 comments on commit 928c969

Please sign in to comment.