All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ExpansibleRaster.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/memory/ExpansibleRaster.h
22 
23  \brief A raster (stored in memory and eventually swapped to disk) where it is possible to dynamically add lines/columns/bands.
24 */
25 
26 #ifndef __TERRALIB_MEMORY_INTERNAL_EXPANSIBLERASTER_H
27 #define __TERRALIB_MEMORY_INTERNAL_EXPANSIBLERASTER_H
28 
29 // TerraLib
30 #include "../raster/BandProperty.h"
31 #include "../raster/Grid.h"
32 #include "../raster/Raster.h"
33 #include "Config.h"
34 #include "ExpansibleBand.h"
36 
37 namespace te
38 {
39  namespace mem
40  {
41  /*!
42  \class ExpansibleRaster
43 
44  \brief A raster (stored in memory and eventually swapped to disk) where it is possible to dynamically add lines/columns/bands.
45 
46  \ingroup mem
47 
48  \note The first band blocking scheme will be taken as reference for the other bands.
49 
50  \note Adding lines/columns may add extra lines/columns to correctly fit the internal blocking structure.
51 
52  \note The geographic limits will be automatically adjust following the requested expansion.
53  */
55  {
56  public:
57 
59 
60  /*!
61  \brief Constructor.
62 
63  \param maxMemPercentUsed The maximum free memory percentual to use valid range: [1:100].
64  \param grid The grid definition. The Raster will take its ownership.
65  \param bandsProperties The bands propeties (the raster will take their ownership);
66  */
67  ExpansibleRaster( const unsigned char maxMemPercentUsed,
68  te::rst::Grid* grid,
69  const std::vector<te::rst::BandProperty*> bandsProperties );
70 
71  /*!
72  \brief Constructor.
73 
74  \param grid The grid definition. The Raster will take its ownership.
75 
76  \param bandsProperties The bands propeties (the raster will take their ownership);
77 
78  \param maxNumberOfRAMBlocks The maximum number of RAM blocks.
79  */
81  const std::vector<te::rst::BandProperty*> bandsProperties,
82  const unsigned int maxNumberOfRAMBlocks );
83 
85 
86  void open(const std::map<std::string, std::string>& rinfo, te::common::AccessPolicy p = te::common::RAccess);
87 
88  std::map<std::string, std::string> getInfo() const;
89 
90  std::size_t getNumberOfBands() const
91  {
92  return m_bands.size();
93  };
94 
95  int getBandDataType(std::size_t i) const
96  {
97  assert( i < m_bands.size() );
98  return m_bands[ i ]->getProperty()->m_type;
99  };
100 
101  const te::rst::Band* getBand(std::size_t i) const
102  {
103  assert( i < m_bands.size() );
104  return m_bands[ i ];
105  };
106 
107  te::rst::Band* getBand(std::size_t i)
108  {
109  assert( i < m_bands.size() );
110  return m_bands[ i ];
111  };
112 
113  const te::rst::Band& operator[](std::size_t i) const
114  {
115  assert( i < m_bands.size() );
116  return *(m_bands[ i ]);
117  };
118 
119  te::rst::Band& operator[](std::size_t i)
120  {
121  assert( i < m_bands.size() );
122  return *(m_bands[ i ]);
123  };
124 
125  te::dt::AbstractData* clone() const;
126 
127  bool createMultiResolution( const unsigned int levels, const te::rst::InterpolationMethod interpMethod )
128  {
129  return false;
130  };
131 
132  bool removeMultiResolution() { return false; };
133 
134  unsigned int getMultiResLevelsCount() const
135  {
136  return 0;
137  }
138 
139  te::rst::Raster* getMultiResLevel( const unsigned int level ) const
140  {
141  return 0;
142  }
143 
144  /*!
145  \brief New lines will be added at the top of the raster (before the first line).
146 
147  \param number The number of lines to add.
148 
149  \return true if OK, false on errors.
150  */
151  bool addTopLines( const unsigned int number );
152 
153  /*!
154  \brief New lines will be added at the bottom of the raster (after de the last line).
155 
156  \param number The number of lines to add.
157 
158  \return true if OK, false on errors.
159  */
160  bool addBottomLines( const unsigned int number );
161 
162  /*!
163  \brief New columns will be added at the left of the raster (before the first column).
164 
165  \param number The number of columns to add.
166 
167  \return true if OK, false on errors.
168  */
169  bool addLeftColumns( const unsigned int number );
170 
171  /*!
172  \brief New columns will be added at the right of the raster (after the last column).
173 
174  \param number The number of columns to add.
175 
176  \return true if OK, false on errors.
177  */
178  bool addRightColumns( const unsigned int number );
179 
180  /*!
181  \brief New bands will be added at the top of the raster (before the first band).
182 
183  \param number The number of bands to add.
184 
185  \return true if OK, false on errors.
186  */
187  bool addTopBands( const unsigned int number );
188 
189  /*!
190  \brief New bands will be added at the bottom of the raster (after de the last band).
191 
192  \param number The number of bands to add.
193 
194  \return true if OK, false on errors.
195  */
196  bool addBottomBands( const unsigned int number );
197 
198  protected :
199 
200  std::vector<ExpansibleBand*> m_bands; //!< Internal raster bands.
201 
202  ExpansibleBandBlocksManager m_blocksManager; //!< Internal blocks manager.
203 
204  /*! \brief Free all allocated internal resources and go back to the initial state. */
205  void free();
206 
207  /*!
208  \brief Fill all blocks with dummy values.
209  */
210  void dummyFillAllBlocks();
211 
212  /*!
213  \brief Fill the required blocks with dummy values.
214 
215  \param blocksCoords The blocks coords.
216  */
217  void dummyFillBlocks( const std::vector<ExpansibleBandBlocksManager::BlockIndex3D>& blocksCoords );
218 
219  private :
220 
221  ExpansibleRaster( const Raster &rhs );
222 
224  };
225 
226  } // end namespace mem
227 } // end namespace te
228 
229 #endif //__TERRALIB_MEMORY_INTERNAL_EXPANSIBLERASTER_H
std::vector< ExpansibleBand * > m_bands
Internal raster bands.
A raster class for memory.
Definition: Raster.h:44
#define TEMEMORYEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:87
bool createMultiResolution(const unsigned int levels, const te::rst::InterpolationMethod interpMethod)
Create a sub-sampled multi-resolution pyramid.
const te::rst::Band & operator[](std::size_t i) const
Access band in i position.
Expansible raster band.
Configuration flags for the TerraLib In-memory Data Access driver.
std::size_t getNumberOfBands() const
Returns the number of bands (dimension of cells attribute values) in the raster.
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:92
ExpansibleBandBlocksManager m_blocksManager
Internal blocks manager.
te::rst::Raster * getMultiResLevel(const unsigned int level) const
Returns the required level of a multi-resolution pyramid or NULL if that level does not exists...
te::rst::Band & operator[](std::size_t i)
Access band in i position.
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
An abstract class for raster data strucutures.
Definition: Raster.h:71
RAM cached and tiled raster band blocks manager.
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
RAM cached and tiled raster band blocks manager.
unsigned int getMultiResLevelsCount() const
Returns the current number of multi-resolution pyramid levels.
te::rst::Band * getBand(std::size_t i)
Returns the raster i-th band.
bool removeMultiResolution()
Remove/Destroy a sub-sampled multi-resolution pyramid, if there is one.
A raster (stored in memory and eventually swapped to disk) where it is possible to dynamically add li...
int getBandDataType(std::size_t i) const
Returns the data type in a particular band (or dimension).
const te::rst::Band * getBand(std::size_t i) const
Returns the raster i-th band.
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68