Loading...
Searching...
No Matches
SamplePointsGeneratorStratified.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/sa/core/SamplePointsGeneratorStratified.h
22
23 \brief This file contains a class to generate samples points using stratified strategy.
24
25 \reference Adapted from TerraLib4.
26*/
27
28#ifndef __TERRALIB_SA_INTERNAL_SAMPLEPOINTSGENERATORSTRATIFIED_H
29#define __TERRALIB_SA_INTERNAL_SAMPLEPOINTSGENERATORSTRATIFIED_H
30
31// Terralib Includes
32#include "../../geometry/Geometry.h"
34
35// STL Includes
36#include <map>
37#include <memory>
38
39//BOOST
40#include <boost/random/mersenne_twister.hpp>
41#include <boost/random/uniform_int_distribution.hpp>
42
43namespace te
44{
45 //forward declarations
46 namespace da { class DataSet; }
47 namespace da { class DataSetType; }
48 namespace mem { class DataSet; }
49
50 namespace sa
51 {
52 /*!
53 \class SamplePointsGeneratorStratified
54
55 \brief Class to generate samples points using stratified strategy.
56
57 */
59 {
60 public:
61
62 /*! \brief Default constructor. */
64
65 /*! \brief Virtual destructor. */
67
68 public:
69
70 /*! Function used to set the number of points to be generated */
71 void setNumberOfPoints(int nPoints);
72
73 /*! Function used to set the input dataset */
74 void setInputDataSet(std::unique_ptr<te::da::DataSet> dataSet);
75
76 /*! Function used to set attribute from input data selected to generate the samples */
77 void setInputAttributeName(std::string attrName);
78
79 /*! Function used to set if the number of samples has to be proportional to the area */
80 void isProportionalToArea(bool isProp);
81
82 /*! Function used to get the names for the generated classes */
83 std::vector<std::string> getClassNames();
84
85 protected:
86
87 /*! Function used to create the output dataset type */
88 virtual std::unique_ptr<te::da::DataSetType> createDataSetType();
89
90 /*! Function used to create the output data */
91 virtual std::unique_ptr<te::mem::DataSet> generateSamples(te::da::DataSetType* dsType);
92
93 /*! Function used to create the class map */
95
96 /*! Function used to generate a randon point inside a defined geometry */
98
99 protected:
100
101 int m_nPoints; //!< Attribute used to define the number of points to be generated.
102
103 std::unique_ptr<te::da::DataSet> m_dataSet; //!< Attribute with input data.
104
105 std::string m_attrName; //!< Attribute used to get from input data the selected attribute
106
107 bool m_propToArea; //!< Attribute used to indicate if the number of samples has to be proportional to the area.
108
109 std::map<std::string, std::vector<te::gm::Geometry*> > m_classMap; //!< Attribute with polygons for each class from input dataset
110
111 boost::random::uniform_int_distribution<> m_distInt;
112 };
113 } // end namespace sa
114} // end namespace te
115
116
117#endif // __TERRALIB_SA_INTERNAL_SAMPLEPOINTSGENERATORSTRATIFIED_H
This file contains a virtual class to generate samples points.
A class that models the description of a dataset.
Definition: DataSetType.h:73
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
A point with x and y coordinate values.
Definition: Point.h:51
Virtual class to generate samples points.
Class to generate samples points using stratified strategy.
virtual ~SamplePointsGeneratorStratified()
Virtual destructor.
void setInputAttributeName(std::string attrName)
boost::random::uniform_int_distribution m_distInt
void setInputDataSet(std::unique_ptr< te::da::DataSet > dataSet)
te::gm::Point * getPointInGeometry(te::gm::Geometry *g)
std::vector< std::string > getClassNames()
int m_nPoints
Attribute used to define the number of points to be generated.
std::map< std::string, std::vector< te::gm::Geometry * > > m_classMap
Attribute with polygons for each class from input dataset.
virtual std::unique_ptr< te::mem::DataSet > generateSamples(te::da::DataSetType *dsType)
std::string m_attrName
Attribute used to get from input data the selected attribute.
std::unique_ptr< te::da::DataSet > m_dataSet
Attribute with input data.
virtual std::unique_ptr< te::da::DataSetType > createDataSetType()
bool m_propToArea
Attribute used to indicate if the number of samples has to be proportional to the area.
SamplePointsGeneratorStratified()
Default constructor.
TerraLib.
#define TESAEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:133