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 
43 namespace 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
te::sa::SamplePointsGeneratorStratified::setNumberOfPoints
void setNumberOfPoints(int nPoints)
te::sa::SamplePointsGeneratorStratified::m_nPoints
int m_nPoints
Attribute used to define the number of points to be generated.
Definition: SamplePointsGeneratorStratified.h:101
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::sa::SamplePointsGeneratorStratified::setInputDataSet
void setInputDataSet(std::unique_ptr< te::da::DataSet > dataSet)
te::sa::SamplePointsGeneratorStratified
Class to generate samples points using stratified strategy.
Definition: SamplePointsGeneratorStratified.h:59
te::sa::SamplePointsGeneratorStratified::getClassNames
std::vector< std::string > getClassNames()
te::sa::SamplePointsGeneratorStratified::m_dataSet
std::unique_ptr< te::da::DataSet > m_dataSet
Attribute with input data.
Definition: SamplePointsGeneratorStratified.h:103
te::sa::SamplePointsGeneratorStratified::getPointInGeometry
te::gm::Point * getPointInGeometry(te::gm::Geometry *g)
te::sa::SamplePointsGeneratorStratified::m_propToArea
bool m_propToArea
Attribute used to indicate if the number of samples has to be proportional to the area.
Definition: SamplePointsGeneratorStratified.h:107
TESAEXPORT
#define TESAEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:133
te::sa::SamplePointsGeneratorStratified::m_attrName
std::string m_attrName
Attribute used to get from input data the selected attribute.
Definition: SamplePointsGeneratorStratified.h:105
te::sa::SamplePointsGeneratorAbstract
Virtual class to generate samples points.
Definition: SamplePointsGeneratorAbstract.h:60
te::sa::SamplePointsGeneratorStratified::createClassMap
void createClassMap()
te::sa::SamplePointsGeneratorStratified::SamplePointsGeneratorStratified
SamplePointsGeneratorStratified()
Default constructor.
SamplePointsGeneratorAbstract.h
This file contains a virtual class to generate samples points.
te::sa::SamplePointsGeneratorStratified::m_distInt
boost::random::uniform_int_distribution m_distInt
Definition: SamplePointsGeneratorStratified.h:111
te::sa::SamplePointsGeneratorStratified::createDataSetType
virtual std::unique_ptr< te::da::DataSetType > createDataSetType()
te::sa::SamplePointsGeneratorStratified::generateSamples
virtual std::unique_ptr< te::mem::DataSet > generateSamples(te::da::DataSetType *dsType)
te::sa::SamplePointsGeneratorStratified::~SamplePointsGeneratorStratified
virtual ~SamplePointsGeneratorStratified()
Virtual destructor.
te::sa::SamplePointsGeneratorStratified::setInputAttributeName
void setInputAttributeName(std::string attrName)
te::sa::SamplePointsGeneratorStratified::m_classMap
std::map< std::string, std::vector< te::gm::Geometry * > > m_classMap
Attribute with polygons for each class from input dataset.
Definition: SamplePointsGeneratorStratified.h:109
te::sa::SamplePointsGeneratorStratified::isProportionalToArea
void isProportionalToArea(bool isProp)
te::da::DataSetType
A class that models the description of a dataset.
Definition: DataSetType.h:73
te::gm::Geometry
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
te::gm::Point
A point with x and y coordinate values.
Definition: Point.h:51