Loading...
Searching...
No Matches
CachedRaster.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/CachedRaster.h
22
23 \brief A RAM cache adaptor to an external existent raster that must always be avaliable.
24*/
25
26#ifndef __TERRALIB_MEMORY_INTERNAL_CACHEDRASTER_H
27#define __TERRALIB_MEMORY_INTERNAL_CACHEDRASTER_H
28
29// TerraLib
30#include "../raster/Raster.h"
31#include "CachedBand.h"
33#include "Config.h"
34
35// STL
36#include <cassert>
37#include <vector>
38
39namespace te
40{
41 namespace mem
42 {
43 /*!
44 \class CachedRaster
45
46 \brief A RAM cache adaptor to an external existent raster that must always be avaliable.
47
48 \ingroup mem
49
50 \details A RAM cache adaptor to an external existent raster that must always be avaliable.
51 */
53 {
54 public:
55
56 /*!
57 \brief Constructor.
58
59 \param rhs The external raster where the data will be read/written.
60
61 \param maxMemPercentUsed The maximum free memory percentual to use valid range: [1:100].
62
63 \param dataPrefetchThreshold The read-ahead data prefetch threshold (0-will disable prefetch, 1-data always prefetched, higher values will do prefetch when necessary).
64 */
65 CachedRaster( const te::rst::Raster& rhs, const unsigned char maxMemPercentUsed,
66 const unsigned int dataPrefetchThreshold );
67
68 /*!
69 \brief Constructor.
70
71 \param rhs The external raster where the data will be read/written.
72
73 \param maxNumberOfCacheBlocks The maximum number of cache blocks.
74
75 \param dataPrefetchThreshold The read-ahead data prefetch threshold (0-will disable prefetch, 1-data always prefetched, higher values will do prefetch when necessary).
76 */
77 CachedRaster( const unsigned int maxNumberOfCacheBlocks, const te::rst::Raster& rhs,
78 const unsigned int dataPrefetchThreshold );
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 inline std::size_t getNumberOfBands() const
87 {
88 return m_bands.size();
89 };
90
91 inline int getBandDataType(std::size_t i) const
92 {
93 assert( m_blocksManager.getRaster() );
94 return m_blocksManager.getRaster()->getBandDataType( i );
95 };
96
97 inline 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 inline te::rst::Band* getBand(std::size_t i)
104 {
105 assert( i < m_bands.size() );
106 return m_bands[ i ];
107 };
108
109 inline 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 inline te::rst::Band& operator[](std::size_t i)
116 {
117 assert( i < m_bands.size() );
118 return *(m_bands[ i ]);
119 };
120
122
123 bool createMultiResolution( const unsigned int levels, const te::rst::InterpolationMethod interpMethod )
124 {
125 return false;
126 };
127
128 bool removeMultiResolution() { return false; };
129
130 unsigned int getMultiResLevelsCount() const
131 {
132 return 0;
133 }
134
135 te::rst::Raster* getMultiResLevel( const unsigned int level ) const
136 {
137 return 0;
138 }
139
140 protected:
141
142 /*! \brief Free all allocated internal resources and go back to the initial state. */
143 void free();
144
145 private :
146
148
150
151 protected :
152
153 std::vector< CachedBand* > m_bands; //!< Internal raster bands.
154
155 CachedBandBlocksManager m_blocksManager; //!< Internal blocks manager.
156 };
157
158 } // end namespace mem
159} // end namespace te
160
161#endif //__TERRALIB_MEMORY_INTERNAL_CACHEDRASTER_H
RAM cached and tiled raster band blocks manager.
RAM cached and tiled raster band.
A base class for values that can be retrieved from the data access module.
RAM cached and tiled raster band blocks manager.
A RAM cache adaptor to an external existent raster that must always be avaliable.
CachedRaster(te::rst::Grid *grid, te::common::AccessPolicy p=te::common::RAccess)
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.
bool removeMultiResolution()
Remove/Destroy a sub-sampled multi-resolution pyramid, if there is one.
CachedRaster(const te::rst::Raster &rhs, const unsigned char maxMemPercentUsed, const unsigned int dataPrefetchThreshold)
Constructor.
CachedBandBlocksManager m_blocksManager
Internal blocks manager.
CachedRaster(const unsigned int maxNumberOfCacheBlocks, const te::rst::Raster &rhs, const unsigned int dataPrefetchThreshold)
Constructor.
std::map< std::string, std::string > getInfo() const
It returns additional information about the raster.
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 createMultiResolution(const unsigned int levels, const te::rst::InterpolationMethod interpMethod)
Create a sub-sampled multi-resolution pyramid.
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 free()
Free all allocated internal resources and go back to the initial state.
void open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
Opens a raster.
const te::rst::Band * getBand(std::size_t i) const
Returns the raster i-th band.
const te::rst::Band & operator[](std::size_t i) const
Access band in i position.
te::rst::Band & operator[](std::size_t i)
Access band in i position.
int getBandDataType(std::size_t i) const
Returns the data type in a particular band (or dimension).
std::vector< CachedBand * > m_bands
Internal raster bands.
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).