All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Band.cpp
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/terralib4/Band.cpp
22 
23  \brief Band implementation for TerraLib 4.x.
24 */
25 
26 // TerraLib
27 #include "../common/Translator.h"
28 #include "Band.h"
29 #include "Exception.h"
30 #include "Raster.h"
31 
32 // TerraLib 4.x
33 #include <terralib4/kernel/TeDecoderDatabase.h>
34 #include <terralib4/kernel/TeRaster.h>
35 
37 {
38  public:
39 
40  Impl(Raster* parent, TeRaster* iraster);
41 
43  TeRaster* m_raster;
44 };
45 
46 terralib4::Band::Impl::Impl(Raster* parent, TeRaster* iraster)
47  : m_parent(parent), m_raster(iraster)
48 {
49 }
50 
51 terralib4::Band::Band(Raster* parent, TeRaster* iraster, te::rst::BandProperty* bp, std::size_t idx)
52  : te::rst::Band(bp, idx), m_pImpl(0)
53 {
54  m_pImpl = new Impl(parent, iraster);
55 }
56 
58 {
59  delete m_pImpl;
60 }
61 
63 {
64  return m_pImpl->m_parent;
65 }
66 
67 void terralib4::Band::getValue(unsigned int c, unsigned int r, double& value) const
68 {
69  m_pImpl->m_raster->getElement(c, r, value, m_idx);
70 }
71 
72 void terralib4::Band::setValue(unsigned int /*c*/, unsigned int /*r*/, const double /*value*/)
73 {
74  throw Exception(TE_TR("This method is not supported by TerraLib 4.x driver!"));
75 }
76 
77 void terralib4::Band::getIValue(unsigned int /*c*/, unsigned int /*r*/, double& value) const
78 {
79  value = 0.0;
80 }
81 
82 void terralib4::Band::setIValue(unsigned int /*c*/, unsigned int /*r*/, const double /*value*/)
83 {
84  throw Exception(TE_TR("This method is not supported by TerraLib 4.x driver!"));
85 }
86 
87 void terralib4::Band::read(int x, int y, void* buffer) const
88 {
89  TeDecoderDatabase* decDb = dynamic_cast<TeDecoderDatabase*>(m_pImpl->m_raster->decoder());
90 
91  std::string bdIdx = decDb->codifyId(x, y, m_idx, 1, 0);
92 
93  decDb->getRasterBlock(bdIdx, buffer);
94 }
95 
96 void* terralib4::Band::read(int x, int y)
97 {
98  throw;
99 }
100 
101 void terralib4::Band::write(int /*x*/, int /*y*/, void* /*buffer*/)
102 {
103  throw Exception(TE_TR("This method is not supported by TerraLib 4.x driver!"));
104 }
105 
Band implementation for TerraLib 4.x.
Impl * m_pImpl
Definition: Band.h:64
void getValue(unsigned int c, unsigned int r, double &value) const
Returns the cell attribute value.
Definition: Band.cpp:67
A raster band description.
Definition: BandProperty.h:61
Impl(Raster *parent, TeRaster *iraster)
Definition: Band.cpp:46
Band(Raster *parent, TeRaster *iraster, te::rst::BandProperty *bp, std::size_t idx)
Definition: Band.cpp:51
te::rst::Raster * getRaster() const
Returns the associated raster.
Definition: Band.cpp:62
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
Raster * m_parent
Definition: Band.cpp:42
void write(int x, int y, void *buffer)
It writes a data block from the specified buffer.
Definition: Band.cpp:101
An abstract class for raster data strucutures.
Definition: Raster.h:71
TeRaster * m_raster
Definition: Band.cpp:43
void setIValue(unsigned int c, unsigned int r, const double value)
Sets the imaginary attribute value in a complex band of a cell.
Definition: Band.cpp:82
void read(int x, int y, void *buffer) const
It reads a data block to the specified buffer.
Definition: Band.cpp:87
void getIValue(unsigned int c, unsigned int r, double &value) const
Returns the imaginary attribute value in a complex band of a cell.
Definition: Band.cpp:77
~Band()
Virtual destructor.
Definition: Band.cpp:57
Raster implementaton for TerraLib 4.x.
void setValue(unsigned int c, unsigned int r, const double value)
Sets the cell attribute value.
Definition: Band.cpp:72