27 #include "../common/Translator.h"
28 #include "../raster/BandProperty.h"
29 #include "../datatype/Enums.h"
38 #include <boost/format.hpp>
41 : te::rst::
Band(0, idx),
52 int err = grib_get_size(
m_handle,
"values", &size);
70 throw Exception(
TR_GRIB(
"Not implemented yet!"));
78 grib_handle_delete(m_handle);
90 throw Exception(
TR_GRIB(
"Not implemented yet!"));
95 unsigned int pos = r * m_property->m_blkw + c;
102 unsigned int pos = r * m_property->m_blkw + c;
109 throw Exception(
TR_GRIB(
"Complex data not supported by GRIB format!"));
114 throw Exception(
TR_GRIB(
"Complex data not supported by GRIB format!"));
119 assert(x == 0 && y == 0);
121 memcpy(buffer, m_data, getBlockSize());
126 assert(x == 0 && y == 0);
133 assert(x == 0 && y == 0);
135 memcpy(m_data, buffer, getBlockSize());
147 int err = grib_get_long(m_handle, key, &val);
150 throw Exception((boost::format(
TR_GRIB(
"Can not get key: %1%, due to: %2%.")) % key % getErrMsg(err)).str());
159 int err = grib_get_double(m_handle, key, &val);
162 throw Exception((boost::format(
TR_GRIB(
"Can not get key: %1%, due to: %2%.")) % key % getErrMsg(err)).str());
171 std::size_t length = 0;
173 int err = grib_get_string(m_handle, key, val, &length);
176 throw Exception((boost::format(
TR_GRIB(
"Can not get key: %1%, due to: %2%.")) % key % getErrMsg(err)).str());
178 return std::string(val);
183 const char* errmsg = grib_get_error_message(errCode);
187 return std::string(errmsg);
te::rst::Raster * getRaster() const
Returns the associated raster.
void read(int x, int y, void *buffer) const
It reads a data block to the specified buffer.
A raster band description.
int m_nblocksx
The number of blocks in x.
An exception class for GRIB.
int m_nblocksy
The number of blocks in y.
grib_handle * m_handle
The grib handle.
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits::max().
A raster class for GRIB format.
void setIValue(unsigned int c, unsigned int r, const double value)
Sets the imaginary attribute value in a complex band of a cell.
void getValue(unsigned int c, unsigned int r, double &value) const
Returns the cell attribute value.
An abstract class for raster data strucutures.
int m_blkw
Block width (pixels).
std::string getString(const char *key) const
~Band()
Virtual destructor.
long getLong(const char *key) const
double * m_data
The matrix data.
Band(Raster *r, std::size_t idx, grib_handle *handle)
Band implemntatin for GRIB.
Band & operator=(const Band &rhs)
A raster class for GRIB format.
static std::string getErrMsg(int errCode)
void setValue(unsigned int c, unsigned int r, const double value)
Sets the cell attribute value.
grib_handle * getHandle() const
int m_blkh
Block height (pixels).
void write(int x, int y, void *buffer)
It writes a data block from the specified buffer.
Band implemntatin for GRIB.
#define TR_GRIB(message)
It marks a string in order to get translated. This is a special mark used in the DataAccess module of...
double getDouble(const char *key) const
BandProperty * m_property
The band information.
void getIValue(unsigned int c, unsigned int r, double &value) const
Returns the imaginary attribute value in a complex band of a cell.