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 // Boost
38 
39 #include <boost/shared_ptr.hpp>
40 
41 // STL
42 #include <vector>
43 
44 namespace te
45 {
46  namespace mem
47  {
48  /*!
49  \class ExpansibleRaster
50 
51  \brief A raster (stored in memory and eventually swapped to disk) where it is possible to dynamically add lines/columns/bands.
52 
53  \ingroup mem
54 
55  \note The first band blocking scheme will be taken as reference for the other bands.
56 
57  \note Adding lines/columns may add extra lines/columns to correctly fit the internal blocking structure.
58 
59  \note The geographic limits will be automatically adjust following the requested expansion.
60  */
62  {
63  public:
64 
66 
67  /*!
68  \brief Constructor.
69 
70  \param maxMemPercentUsed The maximum free memory percentual to use valid range: [1:100].
71  \param grid The grid definition. The Raster will take its ownership.
72  \param bandsProperties The bands propeties (the raster will take their ownership);
73  */
74  ExpansibleRaster( const unsigned char maxMemPercentUsed,
75  te::rst::Grid* grid,
76  const std::vector<te::rst::BandProperty*> bandsProperties );
77 
78  /*!
79  \brief Constructor.
80 
81  \param grid The grid definition. The Raster will take its ownership.
82 
83  \param bandsProperties The bands propeties (the raster will take their ownership);
84 
85  \param maxNumberOfRAMBlocks The maximum number of RAM blocks.
86  */
88  const std::vector<te::rst::BandProperty*> bandsProperties,
89  const unsigned int maxNumberOfRAMBlocks );
90 
92 
93  void open(const std::map<std::string, std::string>& rinfo, te::common::AccessPolicy p = te::common::RAccess);
94 
95  std::map<std::string, std::string> getInfo() const;
96 
97  std::size_t getNumberOfBands() const
98  {
99  return m_bands.size();
100  };
101 
102  int getBandDataType(std::size_t i) const
103  {
104  assert( i < m_bands.size() );
105  return m_bands[ i ]->getProperty()->m_type;
106  };
107 
108  const te::rst::Band* getBand(std::size_t i) const
109  {
110  assert( i < m_bands.size() );
111  return m_bands[ i ];
112  };
113 
114  te::rst::Band* getBand(std::size_t i)
115  {
116  assert( i < m_bands.size() );
117  return m_bands[ i ];
118  };
119 
120  const te::rst::Band& operator[](std::size_t i) const
121  {
122  assert( i < m_bands.size() );
123  return *(m_bands[ i ]);
124  };
125 
126  te::rst::Band& operator[](std::size_t i)
127  {
128  assert( i < m_bands.size() );
129  return *(m_bands[ i ]);
130  };
131 
132  te::dt::AbstractData* clone() const;
133 
134  bool createMultiResolution( const unsigned int levels, const te::rst::InterpolationMethod interpMethod );
135 
136  bool removeMultiResolution();
137 
138  unsigned int getMultiResLevelsCount() const;
139 
140  te::rst::Raster* getMultiResLevel( const unsigned int level ) const;
141 
142  /*!
143  \brief New lines will be added at the top of the raster (before the first line).
144 
145  \param number The number of lines to add.
146 
147  \return true if OK, false on errors.
148  */
149  bool addTopLines( const unsigned int number );
150 
151  /*!
152  \brief New lines will be added at the bottom of the raster (after de the last line).
153 
154  \param number The number of lines to add.
155 
156  \return true if OK, false on errors.
157  */
158  bool addBottomLines( const unsigned int number );
159 
160  /*!
161  \brief New columns will be added at the left of the raster (before the first column).
162 
163  \param number The number of columns to add.
164 
165  \return true if OK, false on errors.
166  */
167  bool addLeftColumns( const unsigned int number );
168 
169  /*!
170  \brief New columns will be added at the right of the raster (after the last column).
171 
172  \param number The number of columns to add.
173 
174  \return true if OK, false on errors.
175  */
176  bool addRightColumns( const unsigned int number );
177 
178  /*!
179  \brief New bands will be added at the top of the raster (before the first band).
180 
181  \param number The number of bands to add.
182 
183  \return true if OK, false on errors.
184  */
185  bool addTopBands( const unsigned int number );
186 
187  /*!
188  \brief New bands will be added at the bottom of the raster (after de the last band).
189 
190  \param number The number of bands to add.
191 
192  \return true if OK, false on errors.
193  */
194  bool addBottomBands( const unsigned int number );
195 
196  protected :
197 
198  std::vector<ExpansibleBand*> m_bands; //!< Internal raster bands.
199 
200  boost::shared_ptr< ExpansibleBandBlocksManager > m_blocksManagerPtr; //!< Internal blocks manager.
201 
202  std::vector< boost::shared_ptr< ExpansibleRaster > > m_multiResRasters; //!< Pointer to Multi-resolution versions of this raster instance.
203 
204  /*!
205  \brief Constructor from other expansible raster instance
206 
207  \param other The other expansible raster instance.
208  \note Both instances will share the same blocks manager instance.
209  */
211 
212  /*!
213  \brief Constructor from other expansible raster instance
214 
215  \param other The other expansible raster instance.
216  \note Both instances will share the same blocks manager instance.
217  */
218  ExpansibleRaster( const te::rst::Raster& rhs );
219 
220  /*! \brief Free all allocated internal resources and go back to the initial state. */
221  void free();
222 
223  /*!
224  \brief Fill all blocks with dummy values.
225  */
226  void dummyFillAllBlocks();
227 
228  /*!
229  \brief Fill the required blocks with dummy values.
230 
231  \param blocksCoords The blocks coords.
232  */
233  void dummyFillBlocks( const std::vector<ExpansibleBandBlocksManager::BlockIndex3D>& blocksCoords );
234 
235  private :
236 
238  };
239 
240  } // end namespace mem
241 } // end namespace te
242 
243 #endif //__TERRALIB_MEMORY_INTERNAL_EXPANSIBLERASTER_H
std::vector< ExpansibleBand * > m_bands
Internal raster bands.
#define TEMEMORYEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:84
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::vector< boost::shared_ptr< ExpansibleRaster > > m_multiResRasters
Pointer to Multi-resolution versions of this raster instance.
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
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
URI C++ Library.
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.
boost::shared_ptr< ExpansibleBandBlocksManager > m_blocksManagerPtr
Internal blocks manager.
te::rst::Band * getBand(std::size_t i)
Returns the raster i-th band.
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