ClassifierStrategy.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/ClassifierStrategy.h
22 
23  \brief Raster classifier strategy base class.
24  */
25 
26 #ifndef __TERRALIB_RP_INTERNAL_CLASSIFIERSTRATEGY_H
27 #define __TERRALIB_RP_INTERNAL_CLASSIFIERSTRATEGY_H
28 
29 // TerraLib
30 #include "../raster/Raster.h"
31 #include "../raster/BandProperty.h"
33 #include "Config.h"
34 #include "Exception.h"
35 
36 // STL
37 #include <vector>
38 #include <memory>
39 
40 namespace te
41 {
42  namespace rp
43  {
44  /*!
45  \class ClassifierStrategy
46  \brief Raster classifier strategy base class.
47  */
49  {
50  public:
51 
52  /*! \brief Virtual destructor. */
53  virtual ~ClassifierStrategy();
54 
55  /*!
56  \brief Initialize the classification strategy.
57 
58  \param strategyParams A pointer to the user given specific classification strategy parameters ou NULL if no parameters are present.
59 
60  \return true if OK, false on errors.
61  */
62  virtual bool initialize(ClassifierStrategyParameters const* const strategyParams) _NOEXCEPT_OP(false) = 0;
63 
64  /*!
65  \brief Executes the classification strategy.
66  \return true if OK, false on errors.
67  */
68  virtual bool execute() _NOEXCEPT_OP(false) = 0;
69 
70  /*!
71  \brief Set the input raster.
72  \param raster Input raster.
73  */
74  void setInputRaster( const te::rst::Raster& raster );
75 
76  /*!
77  \brief Set the input raste bandsr.
78  \param rasterBands Input raster bands.
79  */
80  void setInputRasterBands( const std::vector<unsigned int>& rasterBands );
81 
82  /*!
83  \brief Returns a pointer to the output raster or a void pointer if there is none.
84  \return Returns a pointer to the output raster or a void pointer if there is none.
85  \note The caller of this method must take the ownership of the returned object.
86  */
87  std::unique_ptr< te::rst::Raster > releaseOutputRaster();
88 
89  /*!
90  \brief Set the input polygons.
91  \param polygonsPtrs Input polygons pointers.
92  \note The caller of this method must keep the ownership of the objects.
93  */
94  void setInputPolygons( const std::vector<te::gm::Polygon*>& polygonsPtrs );
95 
96  /*!
97  \brief Enable / disable the progress interface.
98  \param enable Enable (true) or disable (false) the progress interface.
99  */
100  void enableProgressInterface( const bool& enable );
101 
102  /*!
103  \brief Enable / disable the use of raster data cache.
104  \param enable Enable (true) or disable (false) the use of raster cache.
105  */
106  void enableRasterCache( const bool& enable );
107 
108  /*!
109  \brief Enable / disable the use of multiple threads.
110  \param enable Enable (true) or disable (false) the use of multiple threads.
111  */
112  void enableMultiThread( const bool& enable );
113 
114  /*!
115  \brief Returns strategy-dependent metadata.
116  \param metadata Strategy-dependent metadata.
117  */
118  void getMetaData( std::map< std::string, std::string >& metadata ) const;
119 
120  /*!
121  \brief Enable (true) or disable (false) the creation of a paletted output raster.
122  \param enabled Enable (true) or disable (false) the creation of a paletted output raster.
123  */
124  void enableOutputPalette( const bool enabled );
125 
126  /*!
127  \brief Set the output user palette.
128  \param userPalette User output raster palette (it must be large enough to accomodate all classifyier generated classes or an empty vector to automatically generate an random palette.
129  */
130  void setUserOutputPalette( std::vector< te::rst::BandProperty::ColorEntry >& userPalette );
131 
132  protected:
133 
134  /*!
135  \brief A pointer to the input raster.
136  */
138 
139  /*!
140  \brief Progress interface status.
141  */
143 
144  /*!
145  \brief Enable or disable the use a raster data cache.
146  */
148 
149  /*!
150  \brief Enable or disable the use multipe threads.
151  */
153 
154  /*!
155  \brief Enable (true) or disable (false) the creation of a paletted output raster.
156  */
158 
159  /*!
160  \brief A pointer to the output raster.
161  */
162  std::unique_ptr< te::rst::Raster > m_outputRasterPtr;
163 
164  /*!
165  \brief Input raster bands.
166  */
167  std::vector<unsigned int> m_inputRasterBands;
168 
169  /*!
170  \brief Input polygons.
171  */
172  std::vector<te::gm::Polygon*> const * m_inputPolygonsPtr;
173 
174  /*!
175  \brief Strategy-dependent metadata.
176  */
177  std::map< std::string, std::string > m_metaData;
178 
179  /*!
180  \brief User output raster palette (it must be large enough to accomodate all classifyier generated classes or an empty vector to automatically generate an random palette.
181  */
182  std::vector< te::rst::BandProperty::ColorEntry > m_userOutputPalette;
183 
184  /*! \brief Default constructor. */
186 
187  /*!
188  \brief Create the output raster using the EXPANSIBLE driver.
189  \param bandsDataTypes Bands data types.
190  \param noDataValues A vector of no-data values for each band.
191  \return true if ok,false on errors.
192  \note A pointer to the created raster will be handled by m_outputRasterPtr.
193  */
194  bool createOutputRaster( const std::vector< int >& bandsDataTypes,
195  const std::vector< double >& noDataValues );
196 
197  /*!
198  \brief Create and set the output raster palette folowing the current internal settings.
199  \param size Palette size.
200  \return true if ok,false on errors.
201  */
202  bool setOutputRasterPalette( const unsigned int size );
203 
204  private:
205 
206  /*!
207  \brief Copy constructor.
208 
209  \param rhs The right-hand side Raster.
210  */
212 
213  /*!
214  \brief Assignment operator.
215 
216  \param rhs The right-hand-side copy that would be used to copy from.
217 
218  \return A reference to this object.
219  */
220  const ClassifierStrategy& operator=(const ClassifierStrategy& rhs);
221 
222  /*!
223  \brief Reset to an initial state
224  */
225  void reset();
226  };
227 
228  } // end namespace rp
229 } // end namespace te
230 
231 #endif // __TERRALIB_RP_INTERNAL_CLASSIFIERSTRATEGY_H
232 
bool m_createRasterPalette
Enable (true) or disable (false) the creation of a paletted output raster.
bool m_enableRasterCache
Enable or disable the use a raster data cache.
#define _NOEXCEPT_OP(x)
std::map< std::string, std::string > m_metaData
Strategy-dependent metadata.
std::vector< unsigned int > m_inputRasterBands
Input raster bands.
Exception class.
Raster classifier strategy parameters base class.
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
bool m_enableMultiThread
Enable or disable the use multipe threads.
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
A pointer to the output raster.
Configuration flags for the Raster Processing module of TerraLib.
bool m_progressInterfaceEnabled
Progress interface status.
te::rst::Raster const * m_inputRasterPtr
A pointer to the input raster.
Raster classifier strategy base class.
std::vector< te::rst::BandProperty::ColorEntry > m_userOutputPalette
User output raster palette (it must be large enough to accomodate all classifyier generated classes o...
std::vector< te::gm::Polygon * > const * m_inputPolygonsPtr
Input polygons.