isce3 0.25.0
Loading...
Searching...
No Matches
MemDataset.icc
1#ifndef ISCE_IO_GDAL_DETAIL_MEMDATASET_ICC
2#error "MemDataset.icc is an implementation detail of MemDataset.h"
3#endif
4
5#include <cpl_conv.h>
6
7#include <isce3/except/Error.h>
8
9#include "GDALDataTypeUtil.h"
10
11namespace isce3 { namespace io { namespace gdal { namespace detail {
12
13template<typename T>
14inline
15std::string toString(T * ptr)
16{
17 constexpr int maxlen = 64;
18 char buffer[maxlen];
19
20 // print pointer to buffer
21 // get length of resulting string
22 int len = CPLPrintPointer(buffer, ptr, maxlen);
23
24 // check if length may have exceeded buffer size
25 if (len >= maxlen) {
26 std::string errmsg = "string size exceeds buffer length";
27 throw isce3::except::RuntimeError(ISCE_SRCINFO(), errmsg);
28 }
29
30 // need to null-terminate the resulting string
31 buffer[len] = '\0';
32
33 return std::string(buffer);
34}
35
36template<typename T>
37inline
38std::string getMemDatasetName(T * data,
39 int width,
40 int length,
41 int bands,
42 std::size_t colstride,
43 std::size_t rowstride,
44 std::size_t bandstride)
45{
46 GDALDataType datatype = Type2GDALDataType<T>::datatype;
47 if (datatype == GDT_Unknown) {
48 throw isce3::except::RuntimeError(ISCE_SRCINFO(), "type is not mappable to GDALDataType");
49 }
50 std::string datatype_str = GDALGetDataTypeName(datatype);
51
52 std::string name = "MEM:::";
53 name += "DATAPOINTER=" + toString(data);
54 name += ",PIXELS=" + std::to_string(width);
55 name += ",LINES=" + std::to_string(length);
56 name += ",BANDS=" + std::to_string(bands);
57 name += ",DATATYPE=" + datatype_str;
58 if (colstride) { name += ",PIXELOFFSET=" + std::to_string(colstride); }
59 if (rowstride) { name += ",LINEOFFSET=" + std::to_string(rowstride); }
60 if (bandstride) { name += ",BANDOFFSET=" + std::to_string(bandstride); }
61
62 return name;
63}
64
65}}}}
The isce3::io namespace.
Definition Constants.h:14
base interpolator is an abstract base class
Definition BinarySearchFunc.cpp:5

Generated for ISCE3.0 by doxygen 1.13.2.