Loading...
Searching...
No Matches
Band.h
Go to the documentation of this file.
1/* Copyright (C) 2008 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
45class GDALRasterBand;
46
47namespace 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 /*!
69 \brief Constructor
70
71 \param rstPtr A pointer to the parent raster.
72 \param idx This band index.
73 \param gdalRasterBandPtr The GDAL band related to this terralib band.
74
75 \warning The caller is responsible for providing correct values for the range [c x r].
76 */
77 Band( Raster* rstPtr, std::size_t idx, GDALRasterBand* gdalRasterBandPtr );
78
79 Band(const Band& rhs);
80
82
84
85 Band& operator=(const Band& rhs);
86
87 void getValue(unsigned int c, unsigned int r, double& value) const;
88
89 void setValue(unsigned int c, unsigned int r, const double value);
90
91 void getIValue(unsigned int c, unsigned int r, double& value) const;
92
93 void setIValue(unsigned int c, unsigned int r, const double value);
94
95 void getValue(unsigned int c, unsigned int r, std::complex<double>& value) const { te::rst::Band::getValue(c, r, value); }
96
97 void setValue(unsigned int c, unsigned int r, const std::complex<double>& value) { te::rst::Band::setValue(c, r, value); }
98
99 void read(int x, int y, void* buffer) const;
100
101 void* read(int /*x*/, int /*y*/);
102
103 void write(int x, int y, void* buffer);
104
105 void getBlockBuffer(void* buffer, int x0, int y0, int width, int height, int outWidth, int outHeight, int dataType);
106
107 virtual std::complex<double> getMinValue(bool readall = false, unsigned int rs = 0, unsigned int cs = 0, unsigned int rf = 0, unsigned int cf = 0) const;
108
109 virtual std::complex<double> getMaxValue(bool readall = false, unsigned int rs = 0, unsigned int cs = 0, unsigned int rf = 0, unsigned int cf = 0) const;
110
111 virtual std::complex<double> getStdValue(unsigned int rs = 0, unsigned int cs = 0, unsigned int rf = 0, unsigned int cf = 0) const;
112
113 virtual std::complex<double> getMeanValue(unsigned int rs = 0, unsigned int cs = 0, unsigned int rf = 0, unsigned int cf = 0) const;
114
115 virtual void getHistogramR(const unsigned int rowStart, const unsigned int colStart, const unsigned int finalRow, const unsigned int finalCol, const unsigned int histoBins,
116 const unsigned int sampleStep, std::map<double, unsigned>& histogram) const;
117
118 void getValueFromBlock(void* block, unsigned int pos, std::complex<double>& value) const;
119
120 void getValueFromBlock(void* block, unsigned int pos, double& value) const;
121
122 private:
123
124 /*!
125 \brief Places the buffer in position adequate to obtain row/column values.
126
127 \param c The column in band to manipulate value.
128 \param r The row in band to manipulate value.
129
130 \warning The caller is responsible for providing correct values for the range [c x r].
131 */
132 int placeBuffer(unsigned c, unsigned r) const;
133
134 /*! \brief The type of function used to insert/extract data from buffers. */
135 //typedef void (*ManipulateBufferValueFPtr)(int index, void* buffer, double* value);
136
137 private:
138
139 te::rst::Raster* m_raster; //!< The Raster associated to this band.
140 GDALRasterBand* m_rasterBand; //!< GDAL Raster band.
141 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, ...).
142 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).
143 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, ...).
144 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).
145 GDALDataType m_gdaltype; //!< The GDAL Data type.
146 void* m_buffer; //!< An internal buffer.
147 mutable int m_x; //!< Actual x buffer position.
148 mutable int m_y; //!< Actual y buffer position.
149 mutable bool m_update_buffer; //!< Flag to update buffer.
150
151 // te::gdal::Band::getValue/setValue internal variables
152 mutable int m_currX; //!< Block x position.
153 mutable int m_currY; //!< Block y position.
154 mutable int m_currC; //!< Block column position.
155 mutable int m_currR; //!< Block row position.
156 mutable int m_i; //!< Block index.
157 };
158 } // end namespace gdal
159} // end namespace te
160
161#endif // __TERRALIB_GDAL_INTERNAL_BAND_H
162
This class represents raster band description.
Definition: Band.h:65
int m_currC
Block column position.
Definition: Band.h:154
void setValue(unsigned int c, unsigned int r, const double value)
Sets the cell attribute value.
void getBlockBuffer(void *buffer, int x0, int y0, int width, int height, int outWidth, int outHeight, int dataType)
It gets the buffer in just only one block that represents the region informed.
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:141
int m_currR
Block row position.
Definition: Band.h:155
void setIValue(unsigned int c, unsigned int r, const double value)
Sets the imaginary attribute value in a complex band of a cell.
void getValueFromBlock(void *block, unsigned int pos, std::complex< double > &value) const
GDALRasterBand * m_rasterBand
GDAL Raster band.
Definition: Band.h:140
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:142
virtual std::complex< double > getMaxValue(bool readall=false, unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const
It computes and returns the maximum occurring value in a window of the band.
int m_i
Block index.
Definition: Band.h:156
void getValueFromBlock(void *block, unsigned int pos, double &value) const
int placeBuffer(unsigned c, unsigned r) const
Places the buffer in position adequate to obtain row/column values.
te::rst::Raster * m_raster
The type of function used to insert/extract data from buffers.
Definition: Band.h:139
int m_currX
Block x position.
Definition: Band.h:152
te::rst::Raster * getRaster() const
Returns the associated raster.
void getIValue(unsigned int c, unsigned int r, double &value) const
Returns 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.
void read(int x, int y, void *buffer) const
It reads a data block to the specified buffer.
void * m_buffer
An internal buffer.
Definition: Band.h:146
~Band()
Virtual destructor.
Band & operator=(const Band &rhs)
bool m_update_buffer
Flag to update buffer.
Definition: Band.h:149
int m_x
Actual x buffer position.
Definition: Band.h:147
Band(const Band &rhs)
void * read(int, int)
It reads and returns a data block.
virtual std::complex< double > getMinValue(bool readall=false, unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const
It computes and returns the minimum occurring value in a window of the band.
virtual std::complex< double > getMeanValue(unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const
It computes and returns the mean of the occurring values in a window of 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...
Definition: Band.h:143
virtual void getHistogramR(const unsigned int rowStart, const unsigned int colStart, const unsigned int finalRow, const unsigned int finalCol, const unsigned int histoBins, const unsigned int sampleStep, std::map< double, unsigned > &histogram) const
It computes and returns the histogram occurring values (real part) in a window of the band.
GDALDataType m_gdaltype
The GDAL Data type.
Definition: Band.h:145
Band(Raster *rstPtr, std::size_t idx, GDALRasterBand *gdalRasterBandPtr)
Constructor.
int m_y
Actual y buffer position.
Definition: Band.h:148
int m_currY
Block y position.
Definition: Band.h:153
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:97
void write(int x, int y, void *buffer)
It writes a data block from the specified buffer.
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:144
virtual std::complex< double > getStdValue(unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const
It computes and returns the standard deviation of the occurring values in a window of the band.
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:95
This class represents Raster data.
Definition: Raster.h:63
A raster band description.
Definition: Band.h:64
virtual void getValue(unsigned int c, unsigned int r, double &value) const =0
Returns the cell attribute value.
virtual void setValue(unsigned int c, unsigned int r, const double value)=0
Sets the cell attribute value.
An abstract class for raster data strucutures.
Definition: Raster.h:72
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
void(* GetBufferValueFPtr)(int index, void *buffer, double *value)
The type of function used to extract data from a buffer.
Definition: BlockUtils.h:37
TerraLib.
#define TEGDALEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:67
Proxy configuration file for TerraView (see terraview_config.h).