src/terralib/terralib4/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 "../core/translator/Translator.h"
28 #include "Band.h"
29 #include "Exception.h"
30 #include "Raster.h"
31 #include "Utils.h"
32 
33 // TerraLib 4.x
34 #include <terralib4/kernel/TeDecoderDatabase.h>
35 #include <terralib4/kernel/TeRaster.h>
36 
38 {
39  public:
40 
41  Impl(Raster* parent, TeRaster* iraster);
42 
45 };
46 
48  : m_parent(parent), m_raster(iraster)
49 {
50 }
51 
52 terralib4::Band::Band(Raster* parent, TeRaster* iraster, te::rst::BandProperty* bp, std::size_t idx)
53  : te::rst::Band(bp, idx), m_pImpl(0)
54 {
55  m_pImpl = new Impl(parent, iraster);
56 }
57 
59 {
60  delete m_pImpl;
61 }
62 
64 {
65  return m_pImpl->m_parent;
66 }
67 
68 void terralib4::Band::getValue(unsigned int c, unsigned int r, double& value) const
69 {
70  m_pImpl->m_raster->getElement(c, r, value, (int)m_idx);
71 }
72 
73 void terralib4::Band::setValue(unsigned int /*c*/, unsigned int /*r*/, const double /*value*/)
74 {
75  throw Exception(TE_TR("This method is not supported by TerraLib 4.x driver!"));
76 }
77 
78 void terralib4::Band::getIValue(unsigned int /*c*/, unsigned int /*r*/, double& value) const
79 {
80  value = 0.0;
81 }
82 
83 void terralib4::Band::setIValue(unsigned int /*c*/, unsigned int /*r*/, const double /*value*/)
84 {
85  throw Exception(TE_TR("This method is not supported by TerraLib 4.x driver!"));
86 }
87 
88 void terralib4::Band::read(int x, int y, void* buffer) const
89 {
90  TeDecoderDatabase* decDb = dynamic_cast<TeDecoderDatabase*>(m_pImpl->m_raster->decoder());
91 
92  std::string decDbIdxUtf8 = terralib4::Convert2Utf8(decDb->codifyId(x, y, (int)m_idx, 1, 0));
93 
94  decDb->getRasterBlock(decDbIdxUtf8, buffer);
95 }
96 
97 void* terralib4::Band::read(int, int)
98 {
99  throw;
100 }
101 
102 void terralib4::Band::write(int /*x*/, int /*y*/, void* /*buffer*/)
103 {
104  throw Exception(TE_TR("This method is not supported by TerraLib 4.x driver!"));
105 }
106 
TETERRALIB4EXPORT std::string Convert2Utf8(const std::string &str)
void getValue(unsigned int c, unsigned int r, double &value) const
Returns the cell attribute value.
A raster band description.
Definition: BandProperty.h:61
Impl(Raster *parent, TeRaster *iraster)
Band(Raster *parent, TeRaster *iraster, te::rst::BandProperty *bp, std::size_t idx)
te::rst::Raster * getRaster() const
Returns the associated raster.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
void write(int x, int y, void *buffer)
It writes a data block from the specified buffer.
Band implementation for TerraLib 4.x.
An abstract class for raster data strucutures.
URI C++ Library.
Definition: Attributes.h:37
struct TeRaster_t TeRaster
Definition: CTypes.h:69
void setIValue(unsigned int c, unsigned int r, const double value)
Sets the imaginary attribute value in a complex band of a cell.
std::size_t m_idx
The band index.
Utilitary functions for dealing with TerraLib 5 and 4.x conversion.
void read(int x, int y, void *buffer) const
It reads a data block to the specified buffer.
void getIValue(unsigned int c, unsigned int r, double &value) const
Returns the imaginary attribute value in a complex band of a cell.
Raster implementaton for TerraLib 4.x.
~Band()
Virtual destructor.
void setValue(unsigned int c, unsigned int r, const double value)
Sets the cell attribute value.