27 #include "../common/Translator.h" 
   28 #include "../raster/RasterProperty.h" 
   29 #include "../raster/Utils.h" 
   40 #include <gdal_priv.h> 
   43   : te::rst::
Band(0, idx),
 
   49     ( rst->
getGDALDataset()->GetRasterBand(1)->GetColorInterpretation() ==
 
   61   m_x = std::numeric_limits<int>::max();
 
   63   m_y = std::numeric_limits<int>::max();
 
   70     m_raster(rhs.m_raster),
 
   71     m_rasterBand(rhs.m_rasterBand),
 
   72     m_getBuff(rhs.m_getBuff),
 
   73     m_gdaltype(rhs.m_gdaltype)
 
   77   m_x = std::numeric_limits<int>::max();
 
   79   m_y = std::numeric_limits<int>::max();
 
   88     m_rasterBand->WriteBlock(m_x, m_y, m_buffer);
 
   90     m_rasterBand->FlushCache();
 
   93   unsigned char* buff = (
unsigned char*)m_buffer;
 
  113     unsigned char* buffer = 
new unsigned char[rhs.
getBlockSize()];
 
  115     for (
int x = 0; x < m_property->m_nblocksx; ++x)
 
  116       for (
int y = 0; y < m_property->m_nblocksy; ++y)
 
  118         rhs.
read(x, y, buffer);
 
  131   m_i = placeBuffer(c, r);
 
  133   m_getBuff(m_i, m_buffer, &value);
 
  138   m_i = placeBuffer(c, r);
 
  140   m_setBuff(m_i, m_buffer, &value);
 
  142   m_update_buffer = 
true;
 
  147   m_i = placeBuffer(c, r);
 
  149   m_getBuffI(m_i, m_buffer, &value);
 
  154   m_i = placeBuffer(c, r);
 
  156   m_setBuffI(m_i, m_buffer, &value);
 
  158   m_update_buffer = 
true;
 
  163   m_rasterBand->ReadBlock(x, y, buffer);
 
  168   if( m_rasterBand->GetColorInterpretation() == GCI_PaletteIndex )
 
  170     const int bufferSize = m_property->m_blkh * m_property->m_blkw;
 
  172     const GDALColorTable& cTable = *( m_rasterBand->GetColorTable() );
 
  174     GDALColorEntry 
const * cEntryPtr = 0;
 
  179         for( 
int bufferIdx = 0 ; bufferIdx < bufferSize ; ++bufferIdx )
 
  181           m_getBuff( bufferIdx, buffer, &value );
 
  183           cEntryPtr = cTable.GetColorEntry( (
int)value );
 
  186           value = (double)cEntryPtr->c1;
 
  188           m_setBuff( bufferIdx, buffer, &value );
 
  192         for( 
int bufferIdx = 0 ; bufferIdx < bufferSize ; ++bufferIdx )
 
  194           m_getBuff( bufferIdx, buffer, &value );
 
  196           cEntryPtr = cTable.GetColorEntry( (
int)value );
 
  199           value = (double)cEntryPtr->c2;
 
  201           m_setBuff( bufferIdx, buffer, &value );
 
  205         for( 
int bufferIdx = 0 ; bufferIdx < bufferSize ; ++bufferIdx )
 
  207           m_getBuff( bufferIdx, buffer, &value );
 
  209           cEntryPtr = cTable.GetColorEntry( (
int)value );
 
  212           value = (double)cEntryPtr->c3;
 
  214           m_setBuff( bufferIdx, buffer, &value );
 
  218         for( 
int bufferIdx = 0 ; bufferIdx < bufferSize ; ++bufferIdx )
 
  220           m_getBuff( bufferIdx, buffer, &value );
 
  222           cEntryPtr = cTable.GetColorEntry( (
int)value );
 
  225           value = (double)cEntryPtr->c4;
 
  227           m_setBuff( bufferIdx, buffer, &value );
 
  231         throw Exception(
TR_GDAL(
"Invalid band index"));
 
  239   if( ( x != m_x ) || ( y != m_y ) )
 
  243       m_rasterBand->WriteBlock(m_x, m_y, m_buffer);
 
  245       m_rasterBand->FlushCache();
 
  247       m_update_buffer = 
false;
 
  250     read( x, y, m_buffer );
 
  260   m_rasterBand->WriteBlock(x, y, buffer);
 
  265   assert(c >= 0 && c < m_raster->getNumberOfColumns());
 
  266   assert(r >= 0 && r < m_raster->getNumberOfRows());
 
  268   m_currX = c / m_property->m_blkw;
 
  270   m_currY = r / m_property->m_blkh;
 
  272   m_currC = c % m_property->m_blkw;
 
  274   m_currR = r % m_property->m_blkh;
 
  276   if (m_currX != m_x || m_currY != m_y)
 
  280       m_rasterBand->WriteBlock(m_x, m_y, m_buffer);
 
  282       m_rasterBand->FlushCache();
 
  284       m_update_buffer = 
false;
 
  287     read(m_currX, m_currY, m_buffer);
 
  295   return (m_currC + m_currR * m_property->m_blkw);
 
te::rst::GetBufferValueFPtr m_getBuff
A pointer to a function that helps to extract a double or complex value from a specific buffer data t...
 
void getIValue(unsigned int c, unsigned int r, double &value) const 
Returns the imaginary attribute value in a complex band of a cell. 
 
int getType() const 
It returns the data type of the elements in the band. 
 
te::rst::SetBufferValueFPtr m_setBuff
A pointer to a function that helps to insert a double or complex value into a specific buffer data ty...
 
Band(Raster *rst, std::size_t idx)
 
This class represents Raster data. 
 
void * m_buffer
An internal buffer. 
 
GDALDataType m_gdaltype
The GDAL Data type. 
 
GDALRasterBand * m_rasterBand
GDAL Raster band. 
 
It gives access to values in one band (dimension) of a raster. 
 
te::rst::Raster * getRaster() const 
Returns the associated raster. 
 
void getValue(unsigned int c, unsigned int r, double &value) const 
Returns the cell attribute value. 
 
te::rst::SetBufferValueFPtr m_setBuffI
A pointer to a function that helps to insert the imaginary part value into a specific buffer data typ...
 
bool m_update_buffer
Flag to update buffer. 
 
int m_x
Actual x buffer position. 
 
virtual Band & operator=(const Band &rhs)
Assignment operator. 
 
void read(int x, int y, void *buffer) const 
It reads a data block to the specified buffer. 
 
int placeBuffer(unsigned c, unsigned r) const 
Places the buffer in position adequate to obtain row/column values. 
 
void setValue(unsigned int c, unsigned int r, const double value)
Sets the cell attribute value. 
 
TERASTEREXPORT void SetBlockFunctions(GetBufferValueFPtr *gb, GetBufferValueFPtr *gbi, SetBufferValueFPtr *sb, SetBufferValueFPtr *sbi, int type)
Sets the pointers to functions that helps to extract a double or complex value from a specific buffer...
 
An exception class for the GDAL module. 
 
Band & operator=(const Band &rhs)
 
This class represents raster band description. 
 
std::size_t m_idx
The band index. 
 
te::rst::GetBufferValueFPtr m_getBuffI
A pointer to a function that helps to extract the imaginary part value from a specific buffer data ty...
 
void write(int x, int y, void *buffer)
It writes a data block from the specified buffer. 
 
virtual int getBlockSize() const 
It returns the number of bytes ocuppied by a data block. 
 
This is a class that represents a GDAL Raster. 
 
Utilitary functions to access GDAL and match some of its concepts to TerraLib concepts. 
 
~Band()
Virtual destructor. 
 
An abstract class for raster data strucutures. 
 
GDALDataset * getGDALDataset() const 
Returns the raster GDAL handler. 
 
int m_y
Actual y buffer position. 
 
te::rst::BandProperty * GetBandProperty(GDALRasterBand *gband, const unsigned int bandIndex)
Gets the properties of a single band from a GDAL dataset. 
 
BandProperty * m_property
The band information. 
 
#define TR_GDAL(message)
It marks a string in order to get translated. This is a special mark used in the Vector Geometry modu...
 
void setIValue(unsigned int c, unsigned int r, const double value)
Sets the imaginary attribute value in a complex band of a cell.