ProxyRaster.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/raster/ProxyRaster.h
22 
23  \brief A proxy class for bands of several rasters over the same region.
24 */
25 
26 #ifndef __TERRALIB_RASTER_INTERNAL_PROXYRASTER_H
27 #define __TERRALIB_RASTER_INTERNAL_PROXYRASTER_H
28 
29 // TerraLib
30 #include "Raster.h"
31 
32 namespace te
33 {
34  namespace rst
35  {
36  /*!
37  \class ProxyRaster
38 
39  \brief A proxy class for bands of several rasters over the same region.
40 
41  \ingroup rst
42  */
44  {
45  public:
46 
47  /*!
48  \brief Constructor from a set of rasters.
49 
50  The bands of the proxy raster will be taken from the input set of raster.
51 
52  \param rasters A vector with the list of raster covering the same region (all pointers must remain valid while this instance is active).
53 
54  \param takeRastersOwnership If true, this instance will take input rasters ownership.
55 
56  \pre All rasters must cover the same region, have the same grid parameters.
57 
58  \note It is desired, but not required, that all raster have the same block size.
59 
60  */
61  ProxyRaster( const std::vector< te::rst::Raster* >& rasters,
62  const bool takeRastersOwnership );
63 
64  /*!
65  \brief Constructor from a set of rasters.
66 
67  The bands of the proxy raster will be taken from the input set of raster.
68 
69  \param rasters A vector with the list of raster covering the same region.
70 
71  \pre All rasters must cover the same region, have the same grid parameters.
72 
73  \note It is desired, but not required, that all raster have the same block size.
74  */
75  ProxyRaster(const std::vector<RasterPtr>& rasters);
76 
77  /*!
78  \brief Copy constructor.
79 
80  \param rhs The right-hand side Raster.
81  */
82  ProxyRaster(const ProxyRaster& rhs);
83 
84  /*! \brief Destructor. */
86 
87  void swap(std::size_t first, std::size_t second);
88 
89  void open(const std::map<std::string, std::string>& rinfo, te::common::AccessPolicy p = te::common::RAccess);
90 
91  std::map<std::string, std::string> getInfo() const;
92 
93  std::size_t getNumberOfBands() const;
94 
95  int getBandDataType(std::size_t i) const;
96 
97  const Band* getBand(std::size_t i) const;
98 
99  Band* getBand(std::size_t i);
100 
101  const Band& operator[](std::size_t i) const;
102 
103  Band& operator[](std::size_t i);
104 
106 
107  bool createMultiResolution( const unsigned int levels, const InterpolationMethod interpMethod )
108  {
109  return false;
110  };
111 
112  bool removeMultiResolution() { return false; };
113 
114  unsigned int getMultiResLevelsCount() const
115  {
116  return 0;
117  }
118 
119  Raster* getMultiResLevel( const unsigned int level ) const
120  {
121  return 0;
122  }
123 
124  protected:
125 
126  std::vector<RasterPtr> m_rasters; //!< The list of proxed rasters.
127  std::vector<Band*> m_bands; //!< The proxy raster bands.
128 
129  /*!
130  \brief This instance info.
131  */
132  std::map<std::string, std::string> m_rasterInfo;
133 
134  /*!
135  \brief update This instance raster info.
136  */
138  };
139 
140  typedef boost::shared_ptr<ProxyRaster> ProxyRasterPtr;
141 
142  } // end namespace rst
143 } // end namespace te
144 
145 #endif //__TERRALIB_RASTER_INTERNAL_PROXYRASTER_H
Raster.h
Raster implementaton for TerraLib 4.x.
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rst::ProxyRaster::m_bands
std::vector< Band * > m_bands
The proxy raster bands.
Definition: ProxyRaster.h:127
te::rst::Band
A raster band description.
Definition: Band.h:64
te::rst::ProxyRaster::operator[]
Band & operator[](std::size_t i)
Access band in i position.
te::rst::ProxyRaster::removeMultiResolution
bool removeMultiResolution()
Remove/Destroy a sub-sampled multi-resolution pyramid, if there is one.
Definition: ProxyRaster.h:112
te::rst::Raster
An abstract class for raster data strucutures.
Definition: Raster.h:72
te::common::RAccess
@ RAccess
Definition: Enums.h:43
te::rst::ProxyRasterPtr
boost::shared_ptr< ProxyRaster > ProxyRasterPtr
Definition: ProxyRaster.h:140
te::rst::ProxyRaster::getBand
Band * getBand(std::size_t i)
Returns the raster i-th band.
te::rst::ProxyRaster::m_rasters
std::vector< RasterPtr > m_rasters
The list of proxed rasters.
Definition: ProxyRaster.h:126
te::rst::ProxyRaster::getBand
const Band * getBand(std::size_t i) const
Returns the raster i-th band.
te::rst::ProxyRaster::getNumberOfBands
std::size_t getNumberOfBands() const
Returns the number of bands (dimension of cells attribute values) in the raster.
te::rst::ProxyRaster::~ProxyRaster
~ProxyRaster()
Destructor.
TERASTEREXPORT
#define TERASTEREXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
te::rst::InterpolationMethod
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:93
te::rst::ProxyRaster::getInfo
std::map< std::string, std::string > getInfo() const
It returns additional information about the raster.
te::rst::ProxyRaster::open
void open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
Opens a raster.
te::rst::ProxyRaster::ProxyRaster
ProxyRaster(const std::vector< te::rst::Raster * > &rasters, const bool takeRastersOwnership)
Constructor from a set of rasters.
te::rst::ProxyRaster::getMultiResLevel
Raster * getMultiResLevel(const unsigned int level) const
Returns the required level of a multi-resolution pyramid or NULL if that level does not exists.
Definition: ProxyRaster.h:119
te::rst::ProxyRaster::operator[]
const Band & operator[](std::size_t i) const
Access band in i position.
te::rst::ProxyRaster::createMultiResolution
bool createMultiResolution(const unsigned int levels, const InterpolationMethod interpMethod)
Create a sub-sampled multi-resolution pyramid.
Definition: ProxyRaster.h:107
te::rst::ProxyRaster::clone
te::dt::AbstractData * clone() const
It returns a clone of this object.
te::rst::ProxyRaster::getMultiResLevelsCount
unsigned int getMultiResLevelsCount() const
Returns the current number of multi-resolution pyramid levels.
Definition: ProxyRaster.h:114
te::dt::AbstractData
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:56
te::rst::ProxyRaster::ProxyRaster
ProxyRaster(const std::vector< RasterPtr > &rasters)
Constructor from a set of rasters.
te::rst::ProxyRaster::ProxyRaster
ProxyRaster(const ProxyRaster &rhs)
Copy constructor.
te::rst::ProxyRaster::updateRasterInfo
void updateRasterInfo()
update This instance raster info.
te::rst::ProxyRaster::swap
void swap(std::size_t first, std::size_t second)
te::rst::ProxyRaster::m_rasterInfo
std::map< std::string, std::string > m_rasterInfo
This instance info.
Definition: ProxyRaster.h:132
te::common::AccessPolicy
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:41
te::rst::ProxyRaster::getBandDataType
int getBandDataType(std::size_t i) const
Returns the data type in a particular band (or dimension).
te::rst::ProxyRaster
A proxy class for bands of several rasters over the same region.
Definition: ProxyRaster.h:44