QGIS API Documentation  3.0.2-Girona (307d082)
qgsrasterrange.cpp
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 #include <limits>
19 #include "qgis.h"
20 #include "qgsrasterrange.h"
21 
23  : mMin( std::numeric_limits<double>::quiet_NaN() )
24  , mMax( std::numeric_limits<double>::quiet_NaN() )
25 {
26 }
27 
29  : mMin( min )
30  , mMax( max )
31 {
32 }
33 
34 bool QgsRasterRange::contains( double value, const QgsRasterRangeList &rangeList )
35 {
36  Q_FOREACH ( QgsRasterRange range, rangeList )
37  {
38  if ( ( value >= range.mMin && value <= range.mMax ) ||
39  qgsDoubleNear( value, range.mMin ) ||
40  qgsDoubleNear( value, range.mMax ) )
41  {
42  return true;
43  }
44  }
45  return false;
46 }
47 
static bool contains(double value, const QgsRasterRangeList &rangeList)
Test if value is within the list of ranges.
double max() const
Raster values range container.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
Definition: qgis.h:251
QList< QgsRasterRange > QgsRasterRangeList
QgsRasterRange()
Constructor.
double min() const