QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsraster.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsraster.cpp - Raster namespace
3  --------------------------------------
4  Date : Apr, 2013
5  Copyright : (C) 2013 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 
20 #include "qgsraster.h"
21 
23 {
24  switch ( theLimits )
25  {
27  return "MinMax";
29  return "StdDev";
31  return "CumulativeCut";
32  default:
33  break;
34  }
35  return "None";
36 }
37 
39 {
40  if ( theLimits == "MinMax" )
41  {
43  }
44  else if ( theLimits == "StdDev" )
45  {
47  }
48  else if ( theLimits == "CumulativeCut" )
49  {
51  }
53 }
54 
55 bool QgsRaster::isRepresentableValue( double value, QGis::DataType dataType )
56 {
57  switch ( dataType )
58  {
59  case QGis::Byte:
61  case QGis::UInt16:
63  case QGis::Int16:
65  case QGis::UInt32:
67  case QGis::Int32:
69  case QGis::Float32:
70  return qIsNaN( value ) || qIsInf( value ) ||
72  default:
73  return true;
74  break;
75  }
76 }
77 
78 double QgsRaster::representableValue( double value, QGis::DataType dataType )
79 {
80  switch ( dataType )
81  {
82  case QGis::Byte:
83  return static_cast<quint8>( value );
84  case QGis::UInt16:
85  return static_cast<quint16>( value );
86  case QGis::Int16:
87  return static_cast<qint16>( value );
88  case QGis::UInt32:
89  return static_cast<quint32>( value );
90  case QGis::Int32:
91  return static_cast<qint32>( value );
92  case QGis::Float32:
93  return static_cast<float>( value );
94  default:
95  break;
96  }
97  return value;
98 }
Eight bit unsigned integer (quint8)
Definition: qgis.h:136
static bool isRepresentableValue(double value, QGis::DataType dataType)
Check if the specified value is representable in the given data type.
Definition: qgsraster.cpp:55
Thirty two bit floating point (float)
Definition: qgis.h:141
static double representableValue(double value, QGis::DataType dataType)
Get value representable by given data type.
Definition: qgsraster.cpp:78
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
static ContrastEnhancementLimits contrastEnhancementLimitsFromString(const QString &theLimits)
Definition: qgsraster.cpp:38
Sixteen bit unsigned integer (quint16)
Definition: qgis.h:137
Thirty two bit signed integer (qint32)
Definition: qgis.h:140
ContrastEnhancementLimits
Contrast enhancement limits.
Definition: qgsraster.h:86
Thirty two bit unsigned integer (quint32)
Definition: qgis.h:139
static QString contrastEnhancementLimitsAsString(QgsRaster::ContrastEnhancementLimits theLimits)
Definition: qgsraster.cpp:22
Sixteen bit signed integer (qint16)
Definition: qgis.h:138
DataType
Raster data types.
Definition: qgis.h:133
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.