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 
38 namespace 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  protected :
61 
63  };
64 
65  /*!
66  \class FeederConstRasterVector
67  \brief A feeder from a input rasters vector;
68  */
70  {
71  public :
72 
73  /*!
74  \brief Constructor from a vector of input rasters pointers;
75  \param rasters Input vector of rasters pointers.
76  \note The given rasters must always be avaliable.
77  \note The feeder WILL NOT ACQUIRE the pointers.
78  */
79  FeederConstRasterVector( const std::vector< const te::rst::Raster* > rasters );
80 
82 
83  //overloads
84  te::rst::Raster const* getCurrentObj() const;
85  bool moveNext();
86  bool moveTo( const unsigned int index );
87  void reset();
88  unsigned int getObjsCount() const;
89  unsigned int getCurrentOffset() const;
90 
91  protected :
92 
93  std::vector< const te::rst::Raster* >::size_type m_currentOffset;
94  std::vector< const te::rst::Raster* > m_rasters;
95 
97  };
98 
99  /*!
100  \class FeederConstRasterFileNames
101  \brief A feeder from a vector of input rasters infos.
102  */
104  {
105  public :
106 
107  /*!
108  \brief Constructor from a vector of input rasters infos;
109  \param rTypes The name of the specific drivers to instantiate each raster.
110  \param rInfos The necessary information to instantiate each raster.
111  \note The given rasters must always be avaliable.
112  */
113  FeederConstRasterInfo( const std::vector< std::string >& rTypes,
114  const std::vector< std::map< std::string, std::string > >& rInfos );
115 
117 
118  //overloads
119  te::rst::Raster const* getCurrentObj() const;
120  bool moveNext();
121  bool moveTo( const unsigned int index );
122  void reset();
123  unsigned int getObjsCount() const;
124  unsigned int getCurrentOffset() const;
125 
126  protected :
127 
128  std::vector< std::string >::size_type m_currentOffset;
129  std::vector< std::string > m_rTypes;
130  std::vector< std::map< std::string, std::string > > m_rInfos;
131  std::auto_ptr< te::rst::Raster > m_currentRasterPtr;
132 
134  };
135 
136  /*!
137  \class FeederConstRasterFileNames
138  \brief A feeder from a mix of a vector of input rasters and a vector of rasters infos.
139  */
141  {
142  public :
143 
144  /*!
145  \brief Constructor from a vector of input rasters infos;
146  \param rTypes The name of the specific drivers to instantiate each raster.
147  \param rInfos The necessary information to instantiate each raster.
148  \param rastersPtrsVec Input vector of rasters pointers.
149  \note The given rasters must always be avaliable.
150  */
152  const std::vector< const te::rst::Raster* > rastersPtrsVec,
153  const std::vector< std::string >& rTypes,
154  const std::vector< std::map< std::string, std::string > >& rInfos );
155 
157 
158  //overloads
159  te::rst::Raster const* getCurrentObj() const;
160  bool moveNext();
161  bool moveTo( const unsigned int index );
162  void reset();
163  unsigned int getObjsCount() const;
164  unsigned int getCurrentOffset() const;
165 
166  protected :
167 
168  std::vector< const te::rst::Raster* >::size_type m_CurrentRasterOffset;
170 
171  std::vector< const te::rst::Raster* > m_rasters;
172  std::vector< std::string > m_rTypes;
173  std::vector< std::map< std::string, std::string > > m_rInfos;
174  std::auto_ptr< te::rst::Raster > m_currentRasterHandler;
175 
177  };
178 
179 
180  /*!
181  \class FeederConstRasterDirectory
182  \brief A feeder from an input directory name.
183  */
185  {
186  public :
187 
188  /*!
189  \brief Constructor from an input directory name.
190  \param directoryName The directory full path name.
191  \param recursive true if a recursive search must be performed.
192  \param rType The name of the specific driver to instantiate each raster ( See te::rst::RasterFactory dictionary for valid registered values ).
193  \param sortFileNames If true, the file names will be sorted.
194  \param fileExtensions The file extensions filter (example: ".tif"), or an empty vector if all extensions must be accepted.
195  */
196  FeederConstRasterDirectory( const std::string& directoryName,
197  const bool recursive,
198  const std::string& rType,
199  const bool sortFileNames,
200  const std::vector< std::string >& fileExtensions );
201 
202  /*!
203  \brief Constructor from an input directory name with a restriction geometry.
204  \param directoryName The directory full path name.
205  \param recursive true if a recursive search must be performed.
206  \param rType The name of the specific driver to instantiate each raster.
207  \param sortFileNames If true, the file names will be sorted.
208  \param fileExtensions The file extensions filter (example: ".tif"), or an empty vector if all extensions must be accepted.
209  \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.
210  \param ignoreInvalidRasterFiles If true, invalid raster files will be ignored.
211  */
212  FeederConstRasterDirectory( const std::string& directoryName,
213  const bool recursive,
214  const std::string& rType,
215  const bool sortFileNames,
216  const std::vector< std::string >& fileExtensions,
217  te::gm::Geometry const * const restrictionGeomPtr,
218  const bool ignoreInvalidRasterFiles );
219 
221 
222  /*!
223  \brief Returns the current raster file name.
224  \return Returns the current raster file name.
225  */
226  const std::string& getCurrentRasterFileName();
227 
228  //overloads
229  te::rst::Raster const* getCurrentObj() const;
230  bool moveNext();
231  bool moveTo( const unsigned int index );
232  void reset();
233  unsigned int getObjsCount() const;
234  unsigned int getCurrentOffset() const;
235 
236  /*!
237  \brief Apply a new geometry intersect restriction selecting only those rasters intersecting the given geometry.
238  \param restrictionGeom The new restrigion geometry.
239  */
240  void applyGeometryRestriction( const te::gm::Geometry& restrictionGeom );
241 
242  protected :
243 
244  bool m_ignoreInvalidRasterFiles; //!< If true, invalid raster files will be ignored.
245  std::string m_rType;
246  std::vector< unsigned int > m_selectedRastersIndexes;
247  std::vector< unsigned int > ::size_type m_selectedRasterIndexesOffset;
248  std::vector< std::string > m_allRasterFileNames;
249  std::vector< te::gm::Polygon > m_allRastersBoundingBoxes;
250  std::auto_ptr< te::rst::Raster > m_currentRasterPtr;
251  std::auto_ptr< te::gm::Geometry > m_restrictionGeomPtr;
252 
254 
255  /*!
256  \brief Initialize this instance
257  \param directoryName The directory full path name.
258  \param recursive true if a recursive search must be performed.
259  \param rType The name of the specific driver to instantiate each raster.
260  \param sortFileNames If true, the file names will be sorted.
261  \param fileExtensions The file extensions filter (example: ".tif"), or an empty vector if all extensions must be accepted.
262  \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.
263  \param ignoreInvalidRasterFiles If true, invalid raster files will be ignored.
264  */
265  bool initialize( const std::string& directoryName,
266  const bool recursive,
267  const std::string& rType,
268  const bool sortFileNames,
269  const std::vector< std::string >& fileExtensions,
270  te::gm::Geometry const * const restrictionGeomPtr,
271  const bool ignoreInvalidRasterFiles );
272  };
273  } // end namespace rp
274 } // end namespace te
275 
276 #endif // __TERRALIB_RP_INTERNAL_FEEDERSRASTER_H
277 
Abstract objects feeder.
A feeder from a input rasters vector;.
Definition: FeedersRaster.h:69
std::vector< te::gm::Polygon > m_allRastersBoundingBoxes
Abstract objects feeder.
std::vector< const te::rst::Raster * > m_rasters
std::auto_ptr< te::gm::Geometry > m_restrictionGeomPtr
std::auto_ptr< te::rst::Raster > m_currentRasterHandler
te::rst::Raster const * m_currentRasterNakedPtr
std::vector< const te::rst::Raster * >::size_type m_currentOffset
Definition: FeedersRaster.h:93
std::vector< unsigned int >::size_type m_selectedRasterIndexesOffset
std::vector< const te::rst::Raster * > m_rasters
Definition: FeedersRaster.h:94
std::vector< const te::rst::Raster * >::size_type m_CurrentRasterOffset
An abstract class for raster data strucutures.
Definition: Raster.h:71
URI C++ Library.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
std::auto_ptr< te::rst::Raster > m_currentRasterPtr
std::vector< std::map< std::string, std::string > > m_rInfos
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:74
std::vector< std::string > m_rTypes
Configuration flags for the Raster Processing module of TerraLib.
Feeder from a input rasters.
Definition: FeedersRaster.h:46
A feeder from an input directory name.
std::vector< std::map< std::string, std::string > > m_rInfos
std::vector< unsigned int > m_selectedRastersIndexes
std::vector< std::string >::size_type m_currentOffset
std::auto_ptr< te::rst::Raster > m_currentRasterPtr
bool m_ignoreInvalidRasterFiles
If true, invalid raster files will be ignored.
std::vector< std::string > m_rTypes
std::vector< std::string > m_allRasterFileNames