All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Raster.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/Raster.cpp
22 
23  \brief Raster implementaton for TerraLib 4.x.
24 */
25 
26 // TerraLib
27 #include "../common/Translator.h"
28 #include "../raster/BandProperty.h"
29 #include "../raster/Grid.h"
30 #include "../raster/RasterProperty.h"
31 #include "Band.h"
32 #include "Exception.h"
33 #include "Raster.h"
34 #include "Utils.h"
35 
36 // Boost
37 #include <boost/ptr_container/ptr_vector.hpp>
38 
39 // TerraLib 4.x
40 #include <terralib4/kernel/TeRaster.h>
41 
43 {
44  public:
45 
46  Impl(TeRaster* iraster);
47 
48  TeRaster* m_raster;
49 
50  boost::ptr_vector<Band> m_bands;
51 };
52 
54  : m_raster(iraster)
55 {
56 }
57 
58 terralib4::Raster::Raster(TeRaster* iraster)
59  : m_pImpl(0)
60 {
61  m_pImpl = new Impl(iraster);
62 
63  te::rst::RasterProperty* prop = Convert2T5(iraster->params());
64 
65  m_grid = new te::rst::Grid(*prop->getGrid());
66 
67  for(std::size_t i = 0; i != getNumberOfBands(); ++i)
68  {
69  m_pImpl->m_bands.push_back(new Band(this, iraster, prop->getBandProperties()[i], i));
70 
71  prop->getBandProperties()[i] = 0;
72  }
73 
74  delete prop;
75 }
76 
78 {
79  throw Exception(TE_TR("This method is not supported by TerraLib 4.x driver!"));
80 }
81 
83 {
84  delete m_pImpl;
85 }
86 
87 void terralib4::Raster::open(const std::map<std::string, std::string>& /*rinfo*/,
89 {
90  throw Exception(TE_TR("This method is not supported by TerraLib 4.x driver!"));
91 }
92 
93 std::map<std::string, std::string> terralib4::Raster::getInfo() const
94 {
95  throw;
96 }
97 
99 {
100  return m_pImpl->m_raster->nBands();
101 }
102 
103 int terralib4::Raster::getBandDataType(std::size_t i) const
104 {
105  TeDataType dt = m_pImpl->m_raster->params().dataType_[i];
106 
107  return Convert2T5(dt);
108 }
109 
110 const te::rst::Band* terralib4::Raster::getBand(std::size_t i) const
111 {
112  return &m_pImpl->m_bands[i];
113 }
114 
116 {
117  return &m_pImpl->m_bands[i];
118 }
119 
120 const te::rst::Band& terralib4::Raster::operator[](std::size_t i) const
121 {
122  return m_pImpl->m_bands[i];
123 }
124 
126 {
127  return m_pImpl->m_bands[i];
128 }
129 
131 {
132  throw Exception(TE_TR("This method is not supported by TerraLib 4.x driver!"));
133 }
int getBandDataType(std::size_t i) const
Returns the data type in a particular band (or dimension).
Definition: Raster.cpp:103
Band implementation for TerraLib 4.x.
~Raster()
Virtual destructor.
Definition: Raster.cpp:82
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
te::dt::AbstractData * clone() const
It returns a clone of this object.
Definition: Raster.cpp:130
Raster property.
std::auto_ptr< te::dt::Property > Convert2T5(const TeAttributeRep &attRep)
It creates a valid TerraLib 5 property given a valid TerraLib 4.x attribute representation.
Definition: Utils.cpp:53
const te::rst::Band & operator[](std::size_t i) const
Access band in i position.
Definition: Raster.cpp:120
Grid * m_grid
The spatial support for raster data.
Definition: Raster.h:681
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
Raster()
Default constructor.
Definition: Raster.cpp:49
TeRaster * m_raster
Definition: Raster.cpp:48
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
A raster band description.
Definition: Band.h:63
std::size_t getNumberOfBands() const
Returns the number of bands (dimension of cells attribute values) in the raster.
Definition: Raster.cpp:98
Impl(TeRaster *iraster)
Definition: Raster.cpp:53
void open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
Opens a raster.
Definition: Raster.cpp:87
const te::rst::Band * getBand(std::size_t i) const
Returns the raster i-th band.
Definition: Raster.cpp:110
boost::ptr_vector< Band > m_bands
Definition: Raster.cpp:50
te::rst::Grid * getGrid()
Returns the definition of the raster grid support.
std::vector< te::rst::BandProperty * > & getBandProperties()
Returns a reference to the list of bands definitions.
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68
Utilitary functions for dealing with TerraLib 5 and 4.x conversion.
Impl * m_pImpl
Definition: Raster.h:84
Raster implementaton for TerraLib 4.x.
std::map< std::string, std::string > getInfo() const
It returns additional information about the raster.
Definition: Raster.cpp:93