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  /*!
138  \class FeederConstRasterDirectory
139  \brief A feeder from an input directory name.
140  */
142  {
143  public :
144 
145  /*!
146  \brief Constructor from an input directory name.
147  \param directoryName The directory full path name.
148  \param recursive true if a recursive search must be performed.
149  \param rType The name of the specific driver to instantiate each raster ( See te::rst::RasterFactory dictionary for valid registered values ).
150  \param sortFileNames If true, the file names will be sorted.
151  \param fileExtensions The file extensions filter (example: ".tif"), or an empty vector if all extensions must be accepted.
152  */
153  FeederConstRasterDirectory( const std::string& directoryName,
154  const bool recursive,
155  const std::string& rType,
156  const bool sortFileNames,
157  const std::vector< std::string >& fileExtensions );
158 
159  /*!
160  \brief Constructor from an input directory name with a restriction geometry.
161  \param directoryName The directory full path name.
162  \param recursive true if a recursive search must be performed.
163  \param rType The name of the specific driver to instantiate each raster.
164  \param sortFileNames If true, the file names will be sorted.
165  \param fileExtensions The file extensions filter (example: ".tif"), or an empty vector if all extensions must be accepted.
166  \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.
167  \param ignoreInvalidRasterFiles If true, invalid raster files will be ignored.
168  */
169  FeederConstRasterDirectory( const std::string& directoryName,
170  const bool recursive,
171  const std::string& rType,
172  const bool sortFileNames,
173  const std::vector< std::string >& fileExtensions,
174  te::gm::Geometry const * const restrictionGeomPtr,
175  const bool ignoreInvalidRasterFiles );
176 
178 
179  /*!
180  \brief Returns the current raster file name.
181  \return Returns the current raster file name.
182  */
183  const std::string& getCurrentRasterFileName();
184 
185  //overloads
186  te::rst::Raster const* getCurrentObj() const;
187  bool moveNext();
188  bool moveTo( const unsigned int index );
189  void reset();
190  unsigned int getObjsCount() const;
191  unsigned int getCurrentOffset() const;
192 
193  /*!
194  \brief Apply a new geometry intersect restriction selecting only those rasters intersecting the given geometry.
195  \param restrictionGeom The new restrigion geometry.
196  */
197  void applyGeometryRestriction( const te::gm::Geometry& restrictionGeom );
198 
199  protected :
200 
201  bool m_ignoreInvalidRasterFiles; //!< If true, invalid raster files will be ignored.
202  std::string m_rType;
203  std::vector< unsigned int > m_selectedRastersIndexes;
204  std::vector< unsigned int > ::size_type m_selectedRasterIndexesOffset;
205  std::vector< std::string > m_allRasterFileNames;
206  std::vector< te::gm::Polygon > m_allRastersBoundingBoxes;
207  std::auto_ptr< te::rst::Raster > m_currentRasterPtr;
208  std::auto_ptr< te::gm::Geometry > m_restrictionGeomPtr;
209 
211 
212  /*!
213  \brief Initialize this instance
214  \param directoryName The directory full path name.
215  \param recursive true if a recursive search must be performed.
216  \param rType The name of the specific driver to instantiate each raster.
217  \param sortFileNames If true, the file names will be sorted.
218  \param fileExtensions The file extensions filter (example: ".tif"), or an empty vector if all extensions must be accepted.
219  \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.
220  \param ignoreInvalidRasterFiles If true, invalid raster files will be ignored.
221  */
222  bool initialize( const std::string& directoryName,
223  const bool recursive,
224  const std::string& rType,
225  const bool sortFileNames,
226  const std::vector< std::string >& fileExtensions,
227  te::gm::Geometry const * const restrictionGeomPtr,
228  const bool ignoreInvalidRasterFiles );
229  };
230  } // end namespace rp
231 } // end namespace te
232 
233 #endif // __TERRALIB_RP_INTERNAL_FEEDERSRASTER_H
234 
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::auto_ptr< te::gm::Geometry > m_restrictionGeomPtr
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
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
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
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