isce3 0.25.0
Loading...
Searching...
No Matches
GDALDataTypeUtil.h
1#pragma once
2
3#include <cstdint>
4#include <complex>
5#include <gdal_priv.h>
6#include <type_traits>
7
8// forward declare thrust::complex
9namespace thrust {
10 template<typename> struct complex;
11}
12
13namespace isce3 { namespace io { namespace gdal { namespace detail {
14
15template<GDALDataType DataType>
16struct GDT {
17 static constexpr GDALDataType datatype = DataType;
18};
19
20template<typename T>
21struct Type2GDALDataType : public GDT<GDT_Unknown> {};
22
23// char is always a single byte
24template<> struct Type2GDALDataType<char> : public GDT<GDT_Byte> {};
25template<> struct Type2GDALDataType<unsigned char> : public GDT<GDT_Byte> {};
26
27#if GDAL_VERSION_NUM >= 3070000 // (GDAL>=3.7)
28template<> struct Type2GDALDataType<std::int8_t> : public GDT<GDT_Int8> {};
29#endif
30
31// fixed-size integer types
32template<> struct Type2GDALDataType<std::int16_t> : public GDT<GDT_Int16> {};
33template<> struct Type2GDALDataType<std::int32_t> : public GDT<GDT_Int32> {};
34
35// fixed-size unsigned integer types
36template<> struct Type2GDALDataType<std::uint16_t> : public GDT<GDT_UInt16> {};
37template<> struct Type2GDALDataType<std::uint32_t> : public GDT<GDT_UInt32> {};
38
39#if GDAL_VERSION_NUM >= 3050000 // (GDAL>=3.5)
40template<> struct Type2GDALDataType<std::uint64_t> : public GDT<GDT_UInt64> {};
41template<> struct Type2GDALDataType<std::int64_t> : public GDT<GDT_Int64> {};
42#endif
43
44// floating point types
45template<> struct Type2GDALDataType<float> : public GDT<GDT_Float32> {};
46template<> struct Type2GDALDataType<double> : public GDT<GDT_Float64> {};
47
48// complex floating point types
49template<> struct Type2GDALDataType<std::complex<float>> : public GDT<GDT_CFloat32> {};
50template<> struct Type2GDALDataType<std::complex<double>> : public GDT<GDT_CFloat64> {};
51
52// thrust::complex floating point types
53template<> struct Type2GDALDataType<thrust::complex<float>> : public GDT<GDT_CFloat32> {};
54template<> struct Type2GDALDataType<thrust::complex<double>> : public GDT<GDT_CFloat64> {};
55
56constexpr
57std::size_t getSize(GDALDataType datatype)
58{
59 switch (datatype) {
60 case GDT_Byte : return sizeof(unsigned char);
61#if GDAL_VERSION_NUM >= 3070000 // (GDAL>=3.7)
62 case GDT_Int8 : return sizeof(std::int8_t);
63#endif
64 case GDT_UInt16 : return sizeof(std::uint16_t);
65 case GDT_Int16 : return sizeof(std::int16_t);
66 case GDT_UInt32 : return sizeof(std::uint32_t);
67 case GDT_Int32 : return sizeof(std::int32_t);
68#if GDAL_VERSION_NUM >= 3050000 // (GDAL>=3.5)
69 case GDT_UInt64 : return sizeof(std::uint64_t);
70 case GDT_Int64 : return sizeof(std::int64_t);
71#endif
72 case GDT_Float32 : return sizeof(float);
73 case GDT_Float64 : return sizeof(double);
74 case GDT_CFloat32 : return sizeof(std::complex<float>);
75 case GDT_CFloat64 : return sizeof(std::complex<double>);
76 default : return 0;
77 }
78}
79
80}}}}
base interpolator is an abstract base class
Definition BinarySearchFunc.cpp:5
Definition GDALDataTypeUtil.h:16
Definition GDALDataTypeUtil.h:21
Definition GDALDataTypeUtil.h:10

Generated for ISCE3.0 by doxygen 1.13.2.