Loading...
Searching...
No Matches
FeedersRaster.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/rp/FeedersRaster.h
22 \brief Raster objects feeders.
23 */
24
25#ifndef __TERRALIB_RP_INTERNAL_FEEDERSRASTER_H
26#define __TERRALIB_RP_INTERNAL_FEEDERSRASTER_H
27
28#include "Config.h"
29#include "AbstractFeeder.h"
30#include "../raster/Raster.h"
31#include "../geometry/Geometry.h"
32
33#include <string>
34#include <vector>
35#include <map>
36#include <memory>
37
38namespace te
39{
40 namespace rp
41 {
42 /*!
43 \class FeederConstRaster
44 \brief Feeder from a input rasters.
45 */
46 class TERPEXPORT FeederConstRaster : public AbstractFeeder< const te::rst::Raster >
47 {
48 public :
49
50 virtual ~FeederConstRaster() {};
51
52 //overloads
53 virtual te::rst::Raster const* getCurrentObj() const = 0;
54 virtual bool moveNext() = 0;
55 virtual bool moveTo( const unsigned int index ) = 0;
56 virtual void reset() = 0;
57 virtual unsigned int getObjsCount() const = 0;
58 virtual unsigned int getCurrentOffset() const = 0;
59
60 /*!
61 \brief Returns a vector of all rasters names.
62 \param uriStrings A vector of all rasters names.
63 */
64 void getRasterNames( std::vector< std::string >& rasterNames );
65
66 protected :
67
69 };
70
71 /*!
72 \class FeederConstRasterVector
73 \brief A feeder from a input rasters vector;
74 */
76 {
77 public :
78
79 /*!
80 \brief Constructor from a vector of input rasters pointers;
81 \param rasters Input vector of rasters pointers.
82 \note The given rasters must always be avaliable.
83 \note The feeder WILL NOT ACQUIRE the pointers.
84 */
85 FeederConstRasterVector( const std::vector< const te::rst::Raster* > rasters );
86
88
89 //overloads
91 bool moveNext();
92 bool moveTo( const unsigned int index );
93 void reset();
94 unsigned int getObjsCount() const;
95 unsigned int getCurrentOffset() const;
96
97 protected :
98
99 std::vector< const te::rst::Raster* >::size_type m_currentOffset;
100 std::vector< const te::rst::Raster* > m_rasters;
101
103 };
104
105 /*!
106 \class FeederConstRasterFileNames
107 \brief A feeder from a vector of input rasters infos.
108 */
110 {
111 public :
112
113 /*!
114 \brief Constructor from a vector of input rasters infos;
115 \param rTypes The name of the specific drivers to instantiate each raster.
116 \param rInfos The necessary information to instantiate each raster.
117 \note The given rasters must always be avaliable.
118 */
119 FeederConstRasterInfo( const std::vector< std::string >& rTypes,
120 const std::vector< std::map< std::string, std::string > >& rInfos );
121
123
124 //overloads
126 bool moveNext();
127 bool moveTo( const unsigned int index );
128 void reset();
129 unsigned int getObjsCount() const;
130 unsigned int getCurrentOffset() const;
131
132 protected :
133
134 std::vector< std::string >::size_type m_currentOffset;
135 std::vector< std::string > m_rTypes;
136 std::vector< std::map< std::string, std::string > > m_rInfos;
137 std::unique_ptr< te::rst::Raster > m_currentRasterPtr;
138
140 };
141
142 /*!
143 \class FeederConstRasterFileNames
144 \brief A feeder from a mix of a vector of input rasters and a vector of rasters infos.
145 */
147 {
148 public :
149
150 /*!
151 \brief Constructor from a vector of input rasters infos;
152 \param rTypes The name of the specific drivers to instantiate each raster.
153 \param rInfos The necessary information to instantiate each raster.
154 \param rastersPtrsVec Input vector of rasters pointers.
155 \note The given rasters must always be avaliable.
156 */
158 const std::vector< const te::rst::Raster* > rastersPtrsVec,
159 const std::vector< std::string >& rTypes,
160 const std::vector< std::map< std::string, std::string > >& rInfos );
161
163
164 //overloads
166 bool moveNext();
167 bool moveTo( const unsigned int index );
168 void reset();
169 unsigned int getObjsCount() const;
170 unsigned int getCurrentOffset() const;
171
172 protected :
173
174 std::vector< const te::rst::Raster* >::size_type m_CurrentRasterOffset;
176
177 std::vector< const te::rst::Raster* > m_rasters;
178 std::vector< std::string > m_rTypes;
179 std::vector< std::map< std::string, std::string > > m_rInfos;
180 std::unique_ptr< te::rst::Raster > m_currentRasterHandler;
181
183 };
184
185
186 /*!
187 \class FeederConstRasterDirectory
188 \brief A feeder from an input directory name.
189 */
191 {
192 public :
193
194 /*!
195 \brief Constructor from an input directory name.
196 \param directoryName The directory full path name.
197 \param recursive true if a recursive search must be performed.
198 \param rType The name of the specific driver to instantiate each raster ( See te::rst::RasterFactory dictionary for valid registered values ).
199 \param sortFileNames If true, the file names will be sorted.
200 \param fileExtensions The file extensions filter (example: ".tif"), or an empty vector if all extensions must be accepted.
201 */
202 FeederConstRasterDirectory( const std::string& directoryName,
203 const bool recursive,
204 const std::string& rType,
205 const bool sortFileNames,
206 const std::vector< std::string >& fileExtensions );
207
208 /*!
209 \brief Constructor from an input directory name with a restriction geometry.
210 \param directoryName The directory full path name.
211 \param recursive true if a recursive search must be performed.
212 \param rType The name of the specific driver to instantiate each raster.
213 \param sortFileNames If true, the file names will be sorted.
214 \param fileExtensions The file extensions filter (example: ".tif"), or an empty vector if all extensions must be accepted.
215 \param restrictionGeomPtr A pointer to a restriction geometry (only rasters intercepting this geomtry will be considered) or a null pointer if there is no restriction.
216 \param ignoreInvalidRasterFiles If true, invalid raster files will be ignored.
217 */
218 FeederConstRasterDirectory( const std::string& directoryName,
219 const bool recursive,
220 const std::string& rType,
221 const bool sortFileNames,
222 const std::vector< std::string >& fileExtensions,
223 te::gm::Geometry const * const restrictionGeomPtr,
224 const bool ignoreInvalidRasterFiles );
225
227
228 /*!
229 \brief Returns the current raster file name.
230 \return Returns the current raster file name.
231 */
232 const std::string& getCurrentRasterFileName();
233
234 //overloads
236 bool moveNext();
237 bool moveTo( const unsigned int index );
238 void reset();
239 unsigned int getObjsCount() const;
240 unsigned int getCurrentOffset() const;
241
242 /*!
243 \brief Apply a new geometry intersect restriction selecting only those rasters intersecting the given geometry.
244 \param restrictionGeom The new restrigion geometry.
245 */
246 void applyGeometryRestriction( const te::gm::Geometry& restrictionGeom );
247
248 protected :
249
250 bool m_ignoreInvalidRasterFiles; //!< If true, invalid raster files will be ignored.
251 std::string m_rType;
252 std::vector< unsigned int > m_selectedRastersIndexes;
253 std::vector< unsigned int > ::size_type m_selectedRasterIndexesOffset;
254 std::vector< std::string > m_allRasterFileNames;
255 std::vector< te::gm::Polygon > m_allRastersBoundingBoxes;
256 std::unique_ptr< te::rst::Raster > m_currentRasterPtr;
257 std::unique_ptr< te::gm::Geometry > m_restrictionGeomPtr;
258
260
261 /*!
262 \brief Initialize this instance
263 \param directoryName The directory full path name.
264 \param recursive true if a recursive search must be performed.
265 \param rType The name of the specific driver to instantiate each raster.
266 \param sortFileNames If true, the file names will be sorted.
267 \param fileExtensions The file extensions filter (example: ".tif"), or an empty vector if all extensions must be accepted.
268 \param restrictionGeomPtr A pointer to a restriction geometry (only rasters intercepting this geomtry will be considered) or a null pointer if there is no restriction.
269 \param ignoreInvalidRasterFiles If true, invalid raster files will be ignored.
270 */
271 bool initialize( const std::string& directoryName,
272 const bool recursive,
273 const std::string& rType,
274 const bool sortFileNames,
275 const std::vector< std::string >& fileExtensions,
276 te::gm::Geometry const * const restrictionGeomPtr,
277 const bool ignoreInvalidRasterFiles );
278 };
279 } // end namespace rp
280} // end namespace te
281
282#endif // __TERRALIB_RP_INTERNAL_FEEDERSRASTER_H
283
Abstract objects feeder.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
Abstract objects feeder.
A feeder from an input directory name.
bool moveTo(const unsigned int index)
Jump to the given object index.
std::vector< te::gm::Polygon > m_allRastersBoundingBoxes
unsigned int getCurrentOffset() const
Return the index of the current object.
unsigned int getObjsCount() const
Return the total number of feeder objects.
void applyGeometryRestriction(const te::gm::Geometry &restrictionGeom)
Apply a new geometry intersect restriction selecting only those rasters intersecting the given geomet...
const std::string & getCurrentRasterFileName()
Returns the current raster file name.
std::unique_ptr< te::gm::Geometry > m_restrictionGeomPtr
std::vector< unsigned int > m_selectedRastersIndexes
bool moveNext()
Advances to the next sequence obeject.
std::unique_ptr< te::rst::Raster > m_currentRasterPtr
bool initialize(const std::string &directoryName, const bool recursive, const std::string &rType, const bool sortFileNames, const std::vector< std::string > &fileExtensions, te::gm::Geometry const *const restrictionGeomPtr, const bool ignoreInvalidRasterFiles)
Initialize this instance.
std::vector< unsignedint >::size_type m_selectedRasterIndexesOffset
void reset()
Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct...
bool m_ignoreInvalidRasterFiles
If true, invalid raster files will be ignored.
FeederConstRasterDirectory(const std::string &directoryName, const bool recursive, const std::string &rType, const bool sortFileNames, const std::vector< std::string > &fileExtensions, te::gm::Geometry const *const restrictionGeomPtr, const bool ignoreInvalidRasterFiles)
Constructor from an input directory name with a restriction geometry.
std::vector< std::string > m_allRasterFileNames
te::rst::Raster const * getCurrentObj() const
Return the current sequence object.
FeederConstRasterDirectory(const std::string &directoryName, const bool recursive, const std::string &rType, const bool sortFileNames, const std::vector< std::string > &fileExtensions)
Constructor from an input directory name.
bool moveTo(const unsigned int index)
Jump to the given object index.
te::rst::Raster const * getCurrentObj() const
Return the current sequence object.
unsigned int getObjsCount() const
Return the total number of feeder objects.
std::vector< const te::rst::Raster * > m_rasters
FeederConstRasterInfoAndVector(const std::vector< const te::rst::Raster * > rastersPtrsVec, const std::vector< std::string > &rTypes, const std::vector< std::map< std::string, std::string > > &rInfos)
Constructor from a vector of input rasters infos;.
bool moveNext()
Advances to the next sequence obeject.
void reset()
Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct...
std::vector< constte::rst::Raster * >::size_type m_CurrentRasterOffset
unsigned int getCurrentOffset() const
Return the index of the current object.
std::vector< std::map< std::string, std::string > > m_rInfos
std::unique_ptr< te::rst::Raster > m_currentRasterHandler
std::vector< std::string > m_rTypes
te::rst::Raster const * m_currentRasterNakedPtr
std::vector< std::string >::size_type m_currentOffset
void reset()
Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct...
unsigned int getObjsCount() const
Return the total number of feeder objects.
bool moveNext()
Advances to the next sequence obeject.
bool moveTo(const unsigned int index)
Jump to the given object index.
unsigned int getCurrentOffset() const
Return the index of the current object.
std::unique_ptr< te::rst::Raster > m_currentRasterPtr
std::vector< std::string > m_rTypes
std::vector< std::map< std::string, std::string > > m_rInfos
te::rst::Raster const * getCurrentObj() const
Return the current sequence object.
FeederConstRasterInfo(const std::vector< std::string > &rTypes, const std::vector< std::map< std::string, std::string > > &rInfos)
Constructor from a vector of input rasters infos;.
A feeder from a input rasters vector;.
Definition: FeedersRaster.h:76
te::rst::Raster const * getCurrentObj() const
Return the current sequence object.
void reset()
Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct...
unsigned int getCurrentOffset() const
Return the index of the current object.
FeederConstRasterVector(const std::vector< const te::rst::Raster * > rasters)
Constructor from a vector of input rasters pointers;.
std::vector< constte::rst::Raster * >::size_type m_currentOffset
Definition: FeedersRaster.h:99
bool moveTo(const unsigned int index)
Jump to the given object index.
bool moveNext()
Advances to the next sequence obeject.
unsigned int getObjsCount() const
Return the total number of feeder objects.
std::vector< const te::rst::Raster * > m_rasters
Feeder from a input rasters.
Definition: FeedersRaster.h:47
virtual te::rst::Raster const * getCurrentObj() const =0
Return the current sequence object.
virtual unsigned int getObjsCount() const =0
Return the total number of feeder objects.
virtual unsigned int getCurrentOffset() const =0
Return the index of the current object.
virtual bool moveNext()=0
Advances to the next sequence obeject.
void getRasterNames(std::vector< std::string > &rasterNames)
Returns a vector of all rasters names.
virtual void reset()=0
Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct...
virtual bool moveTo(const unsigned int index)=0
Jump to the given object index.
An abstract class for raster data strucutures.
Definition: Raster.h:72
TerraLib.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
Proxy configuration file for TerraView (see terraview_config.h).