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