QGIS API Documentation
4.3.0-Master (1c7cf7431bd)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
raster
qgsrasterrange.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsrasterrange.h
3
--------------------------------------
4
Date : Oct 9, 2012
5
Copyright : (C) 2012 by Radim Blazek
6
email : radim dot blazek at gmail dot com
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#ifndef QGSRASTERRANGE_H
19
#define QGSRASTERRANGE_H
20
21
#include "
qgis.h
"
22
#include "qgis_core.h"
23
#include "
qgis_sip.h
"
24
25
#include <QList>
26
27
class
QgsRasterRange
;
28
29
typedef
QList<QgsRasterRange>
QgsRasterRangeList
;
30
36
class
CORE_EXPORT
QgsRasterRange
37
{
38
public
:
40
enum
BoundsType
41
{
42
IncludeMinAndMax
= 0,
43
IncludeMax
,
44
IncludeMin
,
45
Exclusive
,
46
};
47
51
QgsRasterRange
() =
default
;
52
59
QgsRasterRange
(
double
min
,
double
max
,
BoundsType
bounds
=
IncludeMinAndMax
);
60
65
double
min
()
const
{
return
mMin; }
66
71
double
max
()
const
{
return
mMax; }
72
80
BoundsType
bounds
()
const
{
return
mType; }
81
86
double
setMin
(
double
min
) {
return
mMin =
min
; }
87
92
double
setMax
(
double
max
) {
return
mMax =
max
; }
93
101
void
setBounds
(
BoundsType
type ) { mType = type; }
102
103
inline
bool
operator==
(
const
QgsRasterRange
&o )
const
104
{
105
return
( ( std::isnan( mMin ) && std::isnan( o.mMin ) ) ||
qgsDoubleNear
( mMin, o.mMin ) )
106
&& ( ( std::isnan( mMax ) && std::isnan( o.mMax ) ) ||
qgsDoubleNear
( mMax, o.mMax ) )
107
&& mType == o.mType;
108
}
109
114
bool
contains
(
double
value )
const
115
{
116
return
( value > mMin || ( !std::isnan( mMin ) &&
qgsDoubleNear
( value, mMin ) && ( mType ==
IncludeMinAndMax
|| mType ==
IncludeMin
) ) || std::isnan( mMin ) )
117
&& ( value < mMax || ( !std::isnan( mMax ) &&
qgsDoubleNear
( value, mMax ) && ( mType ==
IncludeMinAndMax
|| mType ==
IncludeMax
) ) || std::isnan( mMax ) );
118
}
119
126
static
bool
contains
(
double
value,
const
QgsRasterRangeList
&rangeList )
127
{
128
for
(
const
QgsRasterRange
&range : rangeList )
129
{
130
if
( range.contains( value ) )
131
{
132
return
true
;
133
}
134
}
135
return
false
;
136
}
137
142
bool
overlaps(
const
QgsRasterRange
&other )
const
;
143
148
QString asText()
const
;
149
150
private
:
151
double
mMin = std::numeric_limits<double>::quiet_NaN();
152
double
mMax = std::numeric_limits<double>::quiet_NaN();
153
BoundsType mType = IncludeMinAndMax;
154
};
155
156
#endif
QgsRasterRange
Represents a range of raster values between min and max, optionally including the min and max value.
Definition
qgsrasterrange.h:37
QgsRasterRange::setMin
double setMin(double min)
Sets the minimum value for the range.
Definition
qgsrasterrange.h:86
QgsRasterRange::BoundsType
BoundsType
Handling for min and max bounds.
Definition
qgsrasterrange.h:41
QgsRasterRange::IncludeMin
@ IncludeMin
Include the min value, but not the max value, e.g. min <= value < max.
Definition
qgsrasterrange.h:44
QgsRasterRange::IncludeMinAndMax
@ IncludeMinAndMax
Min and max values are inclusive.
Definition
qgsrasterrange.h:42
QgsRasterRange::Exclusive
@ Exclusive
Don't include either the min or max value, e.g. min < value < max.
Definition
qgsrasterrange.h:45
QgsRasterRange::IncludeMax
@ IncludeMax
Include the max value, but not the min value, e.g. min < value <= max.
Definition
qgsrasterrange.h:43
QgsRasterRange::operator==
bool operator==(const QgsRasterRange &o) const
Definition
qgsrasterrange.h:103
QgsRasterRange::min
double min() const
Returns the minimum value for the range.
Definition
qgsrasterrange.h:65
QgsRasterRange::setBounds
void setBounds(BoundsType type)
Sets the bounds type for the range, which specifies whether or not the min and max values themselves ...
Definition
qgsrasterrange.h:101
QgsRasterRange::contains
bool contains(double value) const
Returns true if this range contains the specified value.
Definition
qgsrasterrange.h:114
QgsRasterRange::setMax
double setMax(double max)
Sets the maximum value for the range.
Definition
qgsrasterrange.h:92
QgsRasterRange::max
double max() const
Returns the maximum value for the range.
Definition
qgsrasterrange.h:71
QgsRasterRange::QgsRasterRange
QgsRasterRange()=default
Default constructor, both min and max value for the range will be set to NaN.
QgsRasterRange::bounds
BoundsType bounds() const
Returns the bounds type for the range, which specifies whether or not the min and max values themselv...
Definition
qgsrasterrange.h:80
QgsRasterRange::contains
static bool contains(double value, const QgsRasterRangeList &rangeList)
Tests if a value is within the list of ranges.
Definition
qgsrasterrange.h:126
qgis.h
qgsDoubleNear
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Definition
qgis.h:7743
qgis_sip.h
QgsRasterRangeList
QList< QgsRasterRange > QgsRasterRangeList
Definition
qgsrasterrange.h:29
Generated on
for QGIS API Documentation by
1.17.0