All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Band.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/gdal/Band.h
22 
23  \brief It gives access to values in one band (dimension) of a raster.
24  */
25 
26 #ifndef __TERRALIB_GDAL_INTERNAL_BAND_H
27 #define __TERRALIB_GDAL_INTERNAL_BAND_H
28 
29 // TerraLib
30 #include "../raster/Band.h"
31 #include "../raster/BandProperty.h"
32 #include "../raster/BlockUtils.h"
33 #include "../raster/Raster.h"
34 #include "Config.h"
35 
36 // STL
37 #include <complex>
38 #include <string>
39 #include <vector>
40 
41 // GDAL
42 #include <gdal.h>
43 
44 // Forward declaration
45 class GDALRasterBand;
46 
47 namespace te
48 {
49  namespace gdal
50  {
51  // Forward declaration.
52  class Raster;
53 
54  /*!
55  \class Band
56 
57  \brief This class represents raster band description.
58 
59  This class is a concrete implementation of a Raster Band using the GDAL library to access
60  the data.
61 
62  \sa te::rst::Band, te::rst::BandProperty
63  */
65  {
66  public:
67 
68  Band(Raster* rst, std::size_t idx);
69 
70  Band(const Band& rhs);
71 
72  ~Band();
73 
74  te::rst::Raster* getRaster() const;
75 
76  Band& operator=(const Band& rhs);
77 
78  void getValue(unsigned int c, unsigned int r, double& value) const;
79 
80  void setValue(unsigned int c, unsigned int r, const double value);
81 
82  void getIValue(unsigned int c, unsigned int r, double& value) const;
83 
84  void setIValue(unsigned int c, unsigned int r, const double value);
85 
86  void getValue(unsigned int c, unsigned int r, std::complex<double>& value) const { te::rst::Band::getValue(c, r, value); }
87 
88  void setValue(unsigned int c, unsigned int r, const std::complex<double>& value) { te::rst::Band::setValue(c, r, value); }
89 
90  void read(int x, int y, void* buffer) const;
91 
92  void* read(int /*x*/, int /*y*/);
93 
94  void write(int x, int y, void* buffer);
95 
96  void getValueFromBlock(void* block, unsigned int pos, std::complex<double>& value) const;
97 
98  void getValueFromBlock(void* block, unsigned int pos, double& value) const;
99 
100  private:
101 
102  /*!
103  \brief Places the buffer in position adequate to obtain row/column values.
104 
105  \param c The column in band to manipulate value.
106  \param r The row in band to manipulate value.
107 
108  \warning The caller is responsible for providing correct values for the range [c x r].
109  */
110  int placeBuffer(unsigned c, unsigned r) const;
111 
112  /*! \brief The type of function used to insert/extract data from buffers. */
113  //typedef void (*ManipulateBufferValueFPtr)(int index, void* buffer, double* value);
114 
115  private:
116 
117  te::rst::Raster* m_raster; //!< The Raster associated to this band.
118  GDALRasterBand* m_rasterBand; //!< GDAL Raster band.
119  te::rst::GetBufferValueFPtr m_getBuff; //!< A pointer to a function that helps to extract a double or complex value from a specific buffer data type (char, int16, int32, float, ...).
120  te::rst::GetBufferValueFPtr m_getBuffI; //!< A pointer to a function that helps to extract the imaginary part value from a specific buffer data type (cint16, cint32, cfloat, cdouble).
121  te::rst::SetBufferValueFPtr m_setBuff; //!< A pointer to a function that helps to insert a double or complex value into a specific buffer data type (char, int16, int32, float, ...).
122  te::rst::SetBufferValueFPtr m_setBuffI; //!< A pointer to a function that helps to insert the imaginary part value into a specific buffer data type (cint16, cint32, cfloat, cdouble).
123  GDALDataType m_gdaltype; //!< The GDAL Data type.
124  void* m_buffer; //!< An internal buffer.
125  mutable int m_x; //!< Actual x buffer position.
126  mutable int m_y; //!< Actual y buffer position.
127  mutable bool m_update_buffer; //!< Flag to update buffer.
128 
129  // te::gdal::Band::getValue/setValue internal variables
130  mutable int m_currX; //!< Block x position.
131  mutable int m_currY; //!< Block y position.
132  mutable int m_currC; //!< Block column position.
133  mutable int m_currR; //!< Block row position.
134  mutable int m_i; //!< Block index.
135  };
136  } // end namespace gdal
137 } // end namespace te
138 
139 #endif // __TERRALIB_GDAL_INTERNAL_BAND_H
140 
void getValue(unsigned int c, unsigned int r, std::complex< double > &value) const
Returns the imaginary attribute value in a complex band of a cell.
Definition: Band.h:86
int m_x
Actual x buffer position.
Definition: Band.h:125
int m_currC
Block column position.
Definition: Band.h:132
te::rst::GetBufferValueFPtr m_getBuffI
A pointer to a function that helps to extract the imaginary part value from a specific buffer data ty...
Definition: Band.h:120
virtual void getValue(unsigned int c, unsigned int r, double &value) const =0
Returns the cell attribute value.
void * m_buffer
An internal buffer.
Definition: Band.h:124
This class represents Raster data.
Definition: Raster.h:59
#define TEGDALEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:69
void setValue(unsigned int c, unsigned int r, const std::complex< double > &value)
Sets the imaginary attribute value in a complex band of a cell.
Definition: Band.h:88
int m_currR
Block row position.
Definition: Band.h:133
int m_currY
Block y position.
Definition: Band.h:131
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...
Definition: Band.h:119
This class represents raster band description.
Definition: Band.h:64
te::rst::SetBufferValueFPtr m_setBuffI
A pointer to a function that helps to insert the imaginary part value into a specific buffer data typ...
Definition: Band.h:122
An abstract class for raster data strucutures.
Definition: Raster.h:71
This file contains include headers for the TerraLib GDAL driver.
void(* SetBufferValueFPtr)(int index, void *buffer, const double *value)
The type of function used to extract data from a buffer.
Definition: BlockUtils.h:40
GDALRasterBand * m_rasterBand
GDAL Raster band.
Definition: Band.h:118
A raster band description.
Definition: Band.h:63
int m_y
Actual y buffer position.
Definition: Band.h:126
te::rst::Raster * m_raster
The type of function used to insert/extract data from buffers.
Definition: Band.h:117
virtual void setValue(unsigned int c, unsigned int r, const double value)=0
Sets the cell attribute value.
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...
Definition: Band.h:121
int m_i
Block index.
Definition: Band.h:134
GDALDataType m_gdaltype
The GDAL Data type.
Definition: Band.h:123
int m_currX
Block x position.
Definition: Band.h:130
bool m_update_buffer
Flag to update buffer.
Definition: Band.h:127
void(* GetBufferValueFPtr)(int index, void *buffer, double *value)
The type of function used to extract data from a buffer.
Definition: BlockUtils.h:37
Configuration flags for the GDAL Driver of TerraLib.