Loading...
Searching...
No Matches
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
44namespace 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
133
134 bool createMultiResolution( const unsigned int levels, const te::rst::InterpolationMethod interpMethod );
135
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 */
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 */
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
237 /*!
238 \brief This instance info.
239 */
240 std::map<std::string, std::string> m_rasterInfo;
241
243
244 /*!
245 \brief update This instance raster info.
246 */
248 };
249
250 } // end namespace mem
251} // end namespace te
252
253#endif //__TERRALIB_MEMORY_INTERNAL_EXPANSIBLERASTER_H
RAM cached and tiled raster band blocks manager.
Expansible raster band.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:56
A raster (stored in memory and eventually swapped to disk) where it is possible to dynamically add li...
ExpansibleRaster(const unsigned char maxMemPercentUsed, te::rst::Grid *grid, const std::vector< te::rst::BandProperty * > bandsProperties)
Constructor.
bool createMultiResolution(const unsigned int levels, const te::rst::InterpolationMethod interpMethod)
Create a sub-sampled multi-resolution pyramid.
bool addLeftColumns(const unsigned int number)
New columns will be added at the left of the raster (before the first column).
bool removeMultiResolution()
Remove/Destroy a sub-sampled multi-resolution pyramid, if there is one.
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.
unsigned int getMultiResLevelsCount() const
Returns the current number of multi-resolution pyramid levels.
ExpansibleRaster(te::rst::Grid *grid, te::common::AccessPolicy p=te::common::RAccess)
void dummyFillAllBlocks()
Fill all blocks with dummy values.
te::rst::Band & operator[](std::size_t i)
Access band in i position.
std::map< std::string, std::string > m_rasterInfo
This instance info.
ExpansibleRaster(ExpansibleRaster &rhs)
Constructor from other expansible raster instance.
bool addTopLines(const unsigned int number)
New lines will be added at the top of the raster (before the first line).
int getBandDataType(std::size_t i) const
Returns the data type in a particular band (or dimension).
void dummyFillBlocks(const std::vector< ExpansibleBandBlocksManager::BlockIndex3D > &blocksCoords)
Fill the required blocks with dummy values.
te::dt::AbstractData * clone() const
It returns a clone of this object.
std::size_t getNumberOfBands() const
Returns the number of bands (dimension of cells attribute values) in the raster.
void open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
Opens a raster.
bool addTopBands(const unsigned int number)
New bands will be added at the top of the raster (before the first band).
void updateRasterInfo()
update This instance raster info.
bool addRightColumns(const unsigned int number)
New columns will be added at the right of the raster (after the last column).
boost::shared_ptr< ExpansibleBandBlocksManager > m_blocksManagerPtr
Internal blocks manager.
ExpansibleRaster(const te::rst::Raster &rhs)
Constructor from other expansible raster instance.
bool addBottomLines(const unsigned int number)
New lines will be added at the bottom of the raster (after de the last line).
std::map< std::string, std::string > getInfo() const
It returns additional information about the raster.
const te::rst::Band * getBand(std::size_t i) const
Returns the raster i-th band.
te::rst::Band * getBand(std::size_t i)
Returns the raster i-th band.
const te::rst::Band & operator[](std::size_t i) const
Access band in i position.
ExpansibleRaster(te::rst::Grid *grid, const std::vector< te::rst::BandProperty * > bandsProperties, const unsigned int maxNumberOfRAMBlocks)
Constructor.
std::vector< ExpansibleBand * > m_bands
Internal raster bands.
void free()
Free all allocated internal resources and go back to the initial state.
bool addBottomBands(const unsigned int number)
New bands will be added at the bottom of the raster (after de the last band).
std::vector< boost::shared_ptr< ExpansibleRaster > > m_multiResRasters
Pointer to Multi-resolution versions of this raster instance.
A raster band description.
Definition: Band.h:64
A rectified grid is the spatial support for raster data.
Definition: Grid.h:69
An abstract class for raster data strucutures.
Definition: Raster.h:72
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:41
@ RAccess
Definition: Enums.h:43
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:93
TerraLib.
#define TEMEMORYEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:84
Proxy configuration file for TerraView (see terraview_config.h).