Loading...
Searching...
No Matches
Dummy.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/classification/Dummy.h
22
23 \brief Dummy classifier (just for testing purposes).
24*/
25
26#ifndef __TERRALIB_CLASSIFICATION_INTERNAL_DUMMY_H
27#define __TERRALIB_CLASSIFICATION_INTERNAL_DUMMY_H
28
29// TerraLib
30#include "../common/AbstractParameters.h"
31#include "../geometry/Coord2D.h"
32#include "../geometry/Envelope.h"
33#include "../geometry/Point.h"
34#include "../geometry/Polygon.h"
35#include "../raster/Grid.h"
36#include "Config.h"
37#include "Exception.h"
38
39// STL
40#include <iostream>
41#include <stdlib.h>
42
43namespace te
44{
45 namespace cl
46 {
47 /*!
48 \class Dummy
49
50 \brief Dummy classifier (just for testing purposes).
51 */
52 template<class TTRAIN, class TCLASSIFY>
53 class Dummy
54 {
55 public:
56
57 /*!
58 \class Parameters
59
60 \brief Classifier Parameters
61 */
63 {
64 public:
65
66 unsigned int m_dummyParameter; //!< A dummy parameter.
67
68 Parameters();
69
71
72 //overload
73 const Parameters& operator=(const Parameters& params);
74
75 //overload
76 void reset() ;
77
78 //overload
80 };
81
82 public:
83
84 Dummy();
85
86 ~Dummy();
87
88 bool initialize(const Parameters& params) ;
89
90 bool train(TTRAIN& itBegin, TTRAIN& itEnd,
91 const std::vector<unsigned int>& attributesIndices,
92 const std::vector<unsigned int>& labels,
93 const bool enableProgressInterface) ;
94
95 bool classify(TCLASSIFY& itBegin, TCLASSIFY& itEnd,
96 const std::vector<unsigned int>& attributesIndices,
97 std::vector<unsigned int>& classification,
98 const bool enableProgressInterface) ;
99 protected:
100
101 bool m_isInitialized; //!< True if this instance is initialized.
102 Parameters m_parameters; //!< Internal execution parameters.
103 };
104
105 }; // end namespace cl
106}; // end namespace te
107
108// class of Parameters
109template <class TTRAIN, class TCLASSIFY>
111{
112 reset();
113}
114
115template <class TTRAIN, class TCLASSIFY>
117{
118}
119
120template <class TTRAIN, class TCLASSIFY>
122{
123 reset();
124
125 m_dummyParameter = rhs.m_dummyParameter;
126
127 return *this;
128}
129
130template <class TTRAIN, class TCLASSIFY>
132{
133 m_dummyParameter = 0;
134}
135
136template <class TTRAIN, class TCLASSIFY>
138{
140}
141
142// class Dummy Strategy
143template <class TTRAIN, class TCLASSIFY>
145{
146 m_isInitialized = false;
147}
148
149template <class TTRAIN, class TCLASSIFY>
151{
152}
153
154template <class TTRAIN, class TCLASSIFY>
156{
157 m_isInitialized = false;
158
159 m_parameters = params;
160
162 {
163 TE_TR("The value of dummy must be at least 2.");
164 return false;
165 }
166
167 m_isInitialized = true;
168
169 return true;
170}
171
172template<class TTRAIN, class TCLASSIFY>
173bool te::cl::Dummy<TTRAIN, TCLASSIFY>::train(TTRAIN& itBegin, TTRAIN& itEnd,
174 const std::vector<unsigned int>& attributesIndices,
175 const std::vector<unsigned int>& labels,
176 const bool enableProgressInterface)
177{
178 return true;
179}
180
181template<class TTRAIN, class TCLASSIFY>
182bool te::cl::Dummy<TTRAIN, TCLASSIFY>::classify(TCLASSIFY& itBegin, TCLASSIFY& itEnd,
183 const std::vector<unsigned int>& attributesIndices,
184 std::vector<unsigned int>& classification,
185 const bool enableProgressInterface)
186{
187 TCLASSIFY it = itBegin;
188 while(it != itEnd)
189 {
190 classification.push_back(rand() % m_parameters.m_dummyParameter + 1);
191
192 ++it;
193 }
194
195 return true;
196}
197
198#endif // __TERRALIB_CLASSIFICATION_INTERNAL_DUMMY_H
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:264
Classifier Parameters.
Definition: Dummy.h:63
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
Definition: Dummy.h:131
const Parameters & operator=(const Parameters &params)
Definition: Dummy.h:121
unsigned int m_dummyParameter
A dummy parameter.
Definition: Dummy.h:66
AbstractParameters * clone() const
Create a clone copy of this instance.
Definition: Dummy.h:137
Dummy classifier (just for testing purposes).
Definition: Dummy.h:54
bool m_isInitialized
True if this instance is initialized.
Definition: Dummy.h:101
Parameters m_parameters
Internal execution parameters.
Definition: Dummy.h:102
bool classify(TCLASSIFY &itBegin, TCLASSIFY &itEnd, const std::vector< unsigned int > &attributesIndices, std::vector< unsigned int > &classification, const bool enableProgressInterface)
Definition: Dummy.h:182
bool train(TTRAIN &itBegin, TTRAIN &itEnd, const std::vector< unsigned int > &attributesIndices, const std::vector< unsigned int > &labels, const bool enableProgressInterface)
Definition: Dummy.h:173
bool initialize(const Parameters &params)
Definition: Dummy.h:155
Abstract parameters base interface.
TerraLib.
Proxy configuration file for TerraView (see terraview_config.h).
An exception class for the XML module.