Loading...
Searching...
No Matches
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"
34#include "Config.h"
35#include "Exception.h"
36
37// STL
38#include <vector>
39#include <memory>
40
41namespace te
42{
43 namespace rp
44 {
45 /*!
46 \class ClassifierStrategy
47 \brief Raster classifier strategy base class.
48 */
50 {
51 public:
52
53 /*! \brief Virtual destructor. */
55
56 /*!
57 \brief Initialize the classification strategy.
58
59 \param strategyParams A pointer to the user given specific classification strategy parameters ou NULL if no parameters are present.
60
61 \return true if OK, false on errors.
62 */
63 virtual bool initialize(ClassifierStrategyParameters const* const strategyParams) _NOEXCEPT_OP(false) = 0;
64
65 /*!
66 \brief Executes the classification strategy.
67 \return true if OK, false on errors.
68 */
69 virtual bool execute() _NOEXCEPT_OP(false) = 0;
70
71 /*!
72 \brief Set the input raster.
73 \param raster Input raster.
74 */
75 void setInputRaster( const te::rst::Raster& raster );
76
77 /*!
78 \brief Set the input raste bandsr.
79 \param rasterBands Input raster bands.
80 */
81 void setInputRasterBands( const std::vector<unsigned int>& rasterBands );
82
83 /*!
84 \brief Returns a pointer to the output raster or a void pointer if there is none.
85 \return Returns a pointer to the output raster or a void pointer if there is none.
86 \note The caller of this method must take the ownership of the returned object.
87 */
88 std::unique_ptr< te::rst::Raster > releaseOutputRaster();
89
90 /*!
91 \brief Set the input polygons.
92 \param polygonsPtrs Input polygons pointers.
93 \note The caller of this method must keep the ownership of the objects.
94 */
95 void setInputPolygons( const std::vector<te::gm::Polygon*>& polygonsPtrs );
96
97 /*!
98 \brief Enable / disable the progress interface.
99 \param enable Enable (true) or disable (false) the progress interface.
100 */
101 void enableProgressInterface( const bool& enable );
102
103 /*!
104 \brief Enable / disable the use of raster data cache.
105 \param enable Enable (true) or disable (false) the use of raster cache.
106 */
107 void enableRasterCache( const bool& enable );
108
109 /*!
110 \brief Enable / disable the use of multiple threads.
111 \param enable Enable (true) or disable (false) the use of multiple threads.
112 */
113 void enableMultiThread( const bool& enable );
114
115 /*!
116 \brief Returns strategy-dependent metadata.
117 \param metadata Strategy-dependent metadata.
118 */
119 void getMetaData( std::map< std::string, std::string >& metadata ) const;
120
121 /*!
122 \brief Enable (true) or disable (false) the creation of a paletted output raster.
123 \param enabled Enable (true) or disable (false) the creation of a paletted output raster.
124 */
125 void enableOutputPalette( const bool enabled );
126
127 /*!
128 \brief Set the output user palette.
129 \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.
130 */
131 void setUserOutputPalette( std::vector< te::rst::BandProperty::ColorEntry >& userPalette );
132
133 /*!
134 \brief Return the current error message if there is any.
135
136 \return Return the current error message if there is any.
137 */
138 const std::string& getErrorMessage() const;
139
140 /*!
141 \brief Returns a pointer to the strategy output execution parameters or a null pointer if there are none.
142
143 \return Returns a pointer to the strategy output execution parameters or a null pointer if there are none.
144 */
146
147 protected:
148
149 /*!
150 \brief A pointer to the input raster.
151 */
152 te::rst::Raster const * m_inputRasterPtr;
153
154 /*!
155 \brief Progress interface status.
156 */
158
159 /*!
160 \brief Enable or disable the use a raster data cache.
161 */
163
164 /*!
165 \brief Enable or disable the use multipe threads.
166 */
168
169 /*!
170 \brief Enable (true) or disable (false) the creation of a paletted output raster.
171 */
173
174 /*!
175 \brief A pointer to the output raster.
176 */
177 std::unique_ptr< te::rst::Raster > m_outputRasterPtr;
178
179 /*!
180 \brief Input raster bands.
181 */
182 std::vector<unsigned int> m_inputRasterBands;
183
184 /*!
185 \brief Input polygons.
186 */
187 std::vector<te::gm::Polygon*> const * m_inputPolygonsPtr;
188
189 /*!
190 \brief Strategy-dependent metadata.
191 */
192 std::map< std::string, std::string > m_metaData;
193
194 /*!
195 \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.
196 */
197 std::vector< te::rst::BandProperty::ColorEntry > m_userOutputPalette;
198
199 /*! \brief Default constructor. */
201
202 /*!
203 \brief Create the output raster using the EXPANSIBLE driver.
204 \param bandsDataTypes Bands data types.
205 \param noDataValues A vector of no-data values for each band.
206 \return true if ok,false on errors.
207 \note A pointer to the created raster will be handled by m_outputRasterPtr.
208 */
209 bool createOutputRaster( const std::vector< int >& bandsDataTypes,
210 const std::vector< double >& noDataValues );
211
212 /*!
213 \brief Create and set the output raster palette folowing the current internal settings.
214 \param size Palette size.
215 \return true if ok,false on errors.
216 */
217 bool setOutputRasterPalette( const unsigned int size );
218
219 /*!
220 \brief Set the current error message.
221
222 \param newErrorMessage New error message;
223 */
224 void setErrorMessage( const std::string& newErrorMessage );
225
226 /*!
227 \brief Reset to an initial state
228 */
229 virtual void reset();
230
231 private:
232
233 /*!
234 \brief Current error message.
235 */
236 std::string m_errorMessage;
237
238 /*!
239 \brief Copy constructor.
240
241 \param rhs The right-hand side Raster.
242 */
244
245 /*!
246 \brief Assignment operator.
247
248 \param rhs The right-hand-side copy that would be used to copy from.
249
250 \return A reference to this object.
251 */
252 const ClassifierStrategy& operator=(const ClassifierStrategy& rhs);
253 };
254
255 } // end namespace rp
256} // end namespace te
257
258#endif // __TERRALIB_RP_INTERNAL_CLASSIFIERSTRATEGY_H
259
It describes one band (or dimension) of a raster.
Raster classifier strategy parameters base class.
#define _NOEXCEPT_OP(x)
void setUserOutputPalette(std::vector< te::rst::BandProperty::ColorEntry > &userPalette)
Set the output user palette.
void setInputRaster(const te::rst::Raster &raster)
Set the input raster.
virtual ClassifierStrategyOutParameters const * getOutputParameters() const
Returns a pointer to the strategy output execution parameters or a null pointer if there are none.
void enableRasterCache(const bool &enable)
Enable / disable the use of raster data cache.
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.
std::vector< unsigned int > m_inputRasterBands
Input raster bands.
ClassifierStrategy()
Default constructor.
void getMetaData(std::map< std::string, std::string > &metadata) const
Returns strategy-dependent metadata.
std::string m_errorMessage
Current error message.
void setInputPolygons(const std::vector< te::gm::Polygon * > &polygonsPtrs)
Set the input polygons.
bool m_enableMultiThread
Enable or disable the use multipe threads.
te::rst::Raster const * m_inputRasterPtr
A pointer to the input raster.
bool createOutputRaster(const std::vector< int > &bandsDataTypes, const std::vector< double > &noDataValues)
Create the output raster using the EXPANSIBLE driver.
void setInputRasterBands(const std::vector< unsigned int > &rasterBands)
Set the input raste bandsr.
void enableOutputPalette(const bool enabled)
Enable (true) or disable (false) the creation of a paletted output raster.
bool m_progressInterfaceEnabled
Progress interface status.
void setErrorMessage(const std::string &newErrorMessage)
Set the current error message.
virtual bool execute() _NOEXCEPT_OP(false)=0
Executes the classification strategy.
virtual ~ClassifierStrategy()
Virtual destructor.
virtual bool initialize(ClassifierStrategyParameters const *const strategyParams) _NOEXCEPT_OP(false)=0
Initialize the classification strategy.
std::unique_ptr< te::rst::Raster > releaseOutputRaster()
Returns a pointer to the output raster or a void pointer if there is none.
virtual void reset()
Reset to an initial state.
bool m_createRasterPalette
Enable (true) or disable (false) the creation of a paletted output raster.
std::map< std::string, std::string > m_metaData
Strategy-dependent metadata.
bool setOutputRasterPalette(const unsigned int size)
Create and set the output raster palette folowing the current internal settings.
void enableMultiThread(const bool &enable)
Enable / disable the use of multiple threads.
bool m_enableRasterCache
Enable or disable the use a raster data cache.
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
A pointer to the output raster.
void enableProgressInterface(const bool &enable)
Enable / disable the progress interface.
const std::string & getErrorMessage() const
Return the current error message if there is any.
Namespace for the Vector Geometry module of TerraLib.
Definition DataSource.h:46
Namespace for the Map Tools module of TerraLib.
Namespace for Raster Processing module of TerraLib.
Namespace for the Raster module of TerraLib.
TerraLib.
An abstract class for raster data strucutures.
Exception class.
Configuration flags for the Raster Processing module of TerraLib.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition Config.h:139