QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
raster
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 "
qgsraster.h
"
19
20
#include <limits>
21
22
bool
QgsRaster::isRepresentableValue
(
double
value,
Qgis::DataType
dataType )
23
{
24
switch
( dataType )
25
{
26
case
Qgis::DataType::Byte
:
27
return
value >= std::numeric_limits<quint8>::min() && value <= std::numeric_limits<quint8>::max();
28
case
Qgis::DataType::Int8
:
29
return
value >= std::numeric_limits<qint8>::min() && value <= std::numeric_limits<qint8>::max();
30
case
Qgis::DataType::UInt16
:
31
return
value >= std::numeric_limits<quint16>::min() && value <= std::numeric_limits<quint16>::max();
32
case
Qgis::DataType::Int16
:
33
return
value >= std::numeric_limits<qint16>::min() && value <= std::numeric_limits<qint16>::max();
34
case
Qgis::DataType::UInt32
:
35
return
value >= std::numeric_limits<quint32>::min() && value <= std::numeric_limits<quint32>::max();
36
case
Qgis::DataType::Int32
:
37
return
value >= std::numeric_limits<qint32>::min() && value <= std::numeric_limits<qint32>::max();
38
case
Qgis::DataType::Float32
:
39
return
std::isnan( value ) || std::isinf( value ) || ( value >= -std::numeric_limits<float>::max() && value <= std::numeric_limits<float>::max() );
40
case
Qgis::DataType::Float64
:
41
return
true
;
42
case
Qgis::DataType::CInt16
:
43
case
Qgis::DataType::CInt32
:
44
case
Qgis::DataType::CFloat32
:
45
case
Qgis::DataType::CFloat64
:
46
case
Qgis::DataType::ARGB32
:
47
case
Qgis::DataType::ARGB32_Premultiplied
:
48
case
Qgis::DataType::UnknownDataType
:
49
break
;
50
}
51
return
true
;
52
}
53
54
double
QgsRaster::representableValue
(
double
value,
Qgis::DataType
dataType )
55
{
56
switch
( dataType )
57
{
58
case
Qgis::DataType::Byte
:
59
return
static_cast<
quint8
>
( value );
60
case
Qgis::DataType::Int8
:
61
return
static_cast<
qint8
>
( value );
62
case
Qgis::DataType::UInt16
:
63
return
static_cast<
quint16
>
( value );
64
case
Qgis::DataType::Int16
:
65
return
static_cast<
qint16
>
( value );
66
case
Qgis::DataType::UInt32
:
67
return
static_cast<
quint32
>
( value );
68
case
Qgis::DataType::Int32
:
69
return
static_cast<
qint32
>
( value );
70
case
Qgis::DataType::Float32
:
71
return
static_cast<
float
>
( value );
72
case
Qgis::DataType::Float64
:
73
return
value;
74
case
Qgis::DataType::CInt16
:
75
case
Qgis::DataType::CInt32
:
76
case
Qgis::DataType::CFloat32
:
77
case
Qgis::DataType::CFloat64
:
78
case
Qgis::DataType::ARGB32
:
79
case
Qgis::DataType::ARGB32_Premultiplied
:
80
case
Qgis::DataType::UnknownDataType
:
81
break
;
82
}
83
return
value;
84
}
Qgis::DataType
DataType
Raster data types.
Definition
qgis.h:413
Qgis::DataType::CInt32
@ CInt32
Complex Int32.
Definition
qgis.h:424
Qgis::DataType::Float32
@ Float32
Thirty two bit floating point (float).
Definition
qgis.h:421
Qgis::DataType::CFloat64
@ CFloat64
Complex Float64.
Definition
qgis.h:426
Qgis::DataType::Int16
@ Int16
Sixteen bit signed integer (qint16).
Definition
qgis.h:418
Qgis::DataType::ARGB32_Premultiplied
@ ARGB32_Premultiplied
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
Definition
qgis.h:428
Qgis::DataType::Int8
@ Int8
Eight bit signed integer (qint8) (added in QGIS 3.30).
Definition
qgis.h:416
Qgis::DataType::UInt16
@ UInt16
Sixteen bit unsigned integer (quint16).
Definition
qgis.h:417
Qgis::DataType::Byte
@ Byte
Eight bit unsigned integer (quint8).
Definition
qgis.h:415
Qgis::DataType::UnknownDataType
@ UnknownDataType
Unknown or unspecified type.
Definition
qgis.h:414
Qgis::DataType::ARGB32
@ ARGB32
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.
Definition
qgis.h:427
Qgis::DataType::Int32
@ Int32
Thirty two bit signed integer (qint32).
Definition
qgis.h:420
Qgis::DataType::Float64
@ Float64
Sixty four bit floating point (double).
Definition
qgis.h:422
Qgis::DataType::CFloat32
@ CFloat32
Complex Float32.
Definition
qgis.h:425
Qgis::DataType::CInt16
@ CInt16
Complex Int16.
Definition
qgis.h:423
Qgis::DataType::UInt32
@ UInt32
Thirty two bit unsigned integer (quint32).
Definition
qgis.h:419
QgsRaster::isRepresentableValue
static bool isRepresentableValue(double value, Qgis::DataType dataType)
Check if the specified value is representable in the given data type.
Definition
qgsraster.cpp:22
QgsRaster::representableValue
static double representableValue(double value, Qgis::DataType dataType)
Gets value representable by given data type.
Definition
qgsraster.cpp:54
qgsraster.h
Generated on
for QGIS API Documentation by
1.17.0