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-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 
57 
58  /*!
59  \brief Constructor.
60 
61  \param maxMemPercentUsed The maximum free memory percentual to use valid range: [1:100].
62  \param grid The grid definition. The Raster will take its ownership.
63  \param bandsProperties The bands propeties (the raster will take their ownership);
64  */
65  ExpansibleRaster( const unsigned char maxMemPercentUsed,
66  te::rst::Grid* grid,
67  const std::vector<te::rst::BandProperty*> bandsProperties );
68 
69  /*!
70  \brief Constructor.
71 
72  \param grid The grid definition. The Raster will take its ownership.
73 
74  \param bandsProperties The bands propeties (the raster will take their ownership);
75 
76  \param maxNumberOfRAMBlocks The maximum number of RAM blocks.
77  */
79  const std::vector<te::rst::BandProperty*> bandsProperties,
80  const unsigned int maxNumberOfRAMBlocks );
81 
83 
84  void open(const std::map<std::string, std::string>& rinfo, te::common::AccessPolicy p = te::common::RAccess);
85 
86  std::map<std::string, std::string> getInfo() const;
87 
88  std::size_t getNumberOfBands() const
89  {
90  return m_bands.size();
91  };
92 
93  int getBandDataType(std::size_t i) const
94  {
95  assert( i < m_bands.size() );
96  return m_bands[ i ]->getProperty()->m_type;
97  };
98 
99  const te::rst::Band* getBand(std::size_t i) const
100  {
101  assert( i < m_bands.size() );
102  return m_bands[ i ];
103  };
104 
105  te::rst::Band* getBand(std::size_t i)
106  {
107  assert( i < m_bands.size() );
108  return m_bands[ i ];
109  };
110 
111  const te::rst::Band& operator[](std::size_t i) const
112  {
113  assert( i < m_bands.size() );
114  return *(m_bands[ i ]);
115  };
116 
117  te::rst::Band& operator[](std::size_t i)
118  {
119  assert( i < m_bands.size() );
120  return *(m_bands[ i ]);
121  };
122 
123  te::dt::AbstractData* clone() const;
124 
125  /*!
126  \brief New lines will be added at the top of the raster (before the first line).
127 
128  \param number The number of lines to add.
129 
130  \return true if OK, false on errors.
131  */
132  bool addTopLines( const unsigned int number );
133 
134  /*!
135  \brief New lines will be added at the bottom of the raster (after de the last line).
136 
137  \param number The number of lines to add.
138 
139  \return true if OK, false on errors.
140  */
141  bool addBottomLines( const unsigned int number );
142 
143  /*!
144  \brief New columns will be added at the left of the raster (before the first column).
145 
146  \param number The number of columns to add.
147 
148  \return true if OK, false on errors.
149  */
150  bool addLeftColumns( const unsigned int number );
151 
152  /*!
153  \brief New columns will be added at the right of the raster (after the last column).
154 
155  \param number The number of columns to add.
156 
157  \return true if OK, false on errors.
158  */
159  bool addRightColumns( const unsigned int number );
160 
161  /*!
162  \brief New bands will be added at the top of the raster (before the first band).
163 
164  \param number The number of bands to add.
165 
166  \return true if OK, false on errors.
167  */
168  bool addTopBands( const unsigned int number );
169 
170  /*!
171  \brief New bands will be added at the bottom of the raster (after de the last band).
172 
173  \param number The number of bands to add.
174 
175  \return true if OK, false on errors.
176  */
177  bool addBottomBands( const unsigned int number );
178 
179  protected :
180 
181  std::vector<ExpansibleBand*> m_bands; //!< Internal raster bands.
182 
183  ExpansibleBandBlocksManager m_blocksManager; //!< Internal blocks manager.
184 
185  /*! \brief Free all allocated internal resources and go back to the initial state. */
186  void free();
187 
188  /*!
189  \brief Fill all blocks with dummy values.
190  */
191  void dummyFillAllBlocks();
192 
193  /*!
194  \brief Fill the required blocks with dummy values.
195 
196  \param blocksCoords The blocks coords.
197  */
198  void dummyFillBlocks( const std::vector<ExpansibleBandBlocksManager::BlockIndex3D>& blocksCoords );
199 
200  private :
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
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
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.
ExpansibleBandBlocksManager m_blocksManager
Internal blocks manager.
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.
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