SummaryFunctions.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 SummaryFunctions.h
22 
23  \brief A set of functions to calculate the statistic summary from a set of values.
24  */
25 
26 #ifndef __TERRALIB_STATISTICAL_CORE_INTERNAL_SUMMARYFUNCTIONS_H
27 #define __TERRALIB_STATISTICAL_CORE_INTERNAL_SUMMARYFUNCTIONS_H
28 
29 //Terralib
30 #include "Config.h"
31 #include "Enums.h"
34 
35 // STL
36 #include <map>
37 #include <string>
38 #include <vector>
39 
40 namespace te
41 {
42  namespace da { class DataSource; }
43 
44  namespace stat
45  {
46 
47  /*! Fills the summary statistics structure from a set of categorical values.
48 
49  \param values a vector of categorical values. Do not pass empty.
50  \param ss to return the statistical summary.
51  */
52  TESTATEXPORT void GetStringStatisticalSummary(std::vector<std::string>& values, te::stat::StringStatisticalSummary& ss);
53 
54  /*! Fills the summary statistics structure from a set of categorical values.
55 
56  \param values a vector of categorical values. Do not pass empty.
57  \param ss to return the statistical summary.
58  \param nullVal a value to be considered as non-value or invalid value.
59  */
60  TESTATEXPORT void GetStringStatisticalSummary(std::vector<std::string>& values, te::stat::StringStatisticalSummary& ss, const std::string& nullValue);
61 
62  /*! Fills the summary statistics structure from a set of numerical values.
63 
64  \param values a vector of numerical values. Do not pass empty.
65  \param ss to return the statistical summary.
66  \param nullVal a value to be considered as non-value or invalid value.
67  */
68  TESTATEXPORT void GetNumericStatisticalSummary(std::vector<double>& values, te::stat::NumericStatisticalSummary& ss, double nullVal);
69 
70  /*! Fills the summary statistics structure from a set of numerical values.
71 
72  \param values a vector of numerical values. Do not pass empty.
73  \param ss to return the statistical summary.
74  */
76 
77  /*! Fills the percentage of each class by area.
78 
79  \param values a vector of numerical values, representing pixels from a raster. Do not pass empty.
80  \param resolutionX a raster horizontal (x-axis) resolution.
81  \param resolutionY a raster vertical (y-axis) resolution.
82  \param area area of a geometry that intersects the raster.
83  \param ss to return the percentage of each class by area.
84  \param fullIntersection set as true if geometry is all inside of the raster box.
85 
86  */
87  TESTATEXPORT void GetPercentOfEachClassByArea(std::vector<double>& values,
88  double& resolutionX,
89  double& resolutionY,
90  double& area,
92  bool fullIntersection = true);
93 
94  /*! Returns the mode of set of numerical values.
95 
96  \param values a reference to a set of numerical values. Do not pass empty.
97  \param ss to return the mode (most frequent value).
98  */
99  TESTATEXPORT void Mode(const std::vector<double>& values,
101 
102  /*! Returns the mode of set of categorical values.
103 
104  \param values a reference to a set of categorical values;
105  \param ss to return the mode (most frequent value).
106  */
107  TESTATEXPORT void Mode(const std::vector<std::string>& values,
109 
110 
111  /*! Fills the summary statistics structure of a given categorical property from a dataset.
112 
113  \param inDataset a dataset name.
114  \param inDatasource a pointer to a datasource. Do not pass null.
115  \param propName the name of the property to be summarized.
116  \param ss to return the statistical summary.
117  */
118  TESTATEXPORT void GetStringStatisticalSummaryQuery(const std::string& inDataset,
119  te::da::DataSource* inDatasource,
120  const std::string& propName,
122 
123  /*! Fills the summary statistics structure of a given numerical property from a dataset.
124 
125  \param inDataset a dataset name.
126  \param inDatasource a pointer to a datasource. Do not pass null.
127  \param propName the name of the property to be summarized.
128  \param ss to return the statistical summary.
129  */
130  TESTATEXPORT void GetNumericStatisticalSummaryQuery(const std::string& inDataset,
131  te::da::DataSource* inDatasource,
132  const std::string& propName,
134 
135  } // end namespace stat
136 } // end namespace te
137 
138 #endif // __TERRALIB_STATISTICAL_CORE_INTERNAL_SUMMARYFUNCTIONS_H
139 
TESTATEXPORT void GetNumericStatisticalSummaryQuery(const std::string &inDataset, te::da::DataSource *inDatasource, const std::string &propName, te::stat::NumericStatisticalSummary &ss)
A structure to hold the set of statistics from a set of numerical values.
TESTATEXPORT void GetStringStatisticalSummaryQuery(const std::string &inDataset, te::da::DataSource *inDatasource, const std::string &propName, te::stat::StringStatisticalSummary &ss)
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:118
TESTATEXPORT void GetStringStatisticalSummary(std::vector< std::string > &values, te::stat::StringStatisticalSummary &ss)
TESTATEXPORT void GetNumericStatisticalSummary(std::vector< double > &values, te::stat::NumericStatisticalSummary &ss, double nullVal)
TESTATEXPORT void GetPercentOfEachClassByArea(std::vector< double > &values, double &resolutionX, double &resolutionY, double &area, te::stat::NumericStatisticalSummary &ss, bool fullIntersection=true)
URI C++ Library.
Enumerations related to Vector Processing module.
#define TESTATEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
A structure to hold the set of statistics from a set of categorical (sample) values.
TESTATEXPORT void Mode(const std::vector< double > &values, te::stat::NumericStatisticalSummary &ss)
Configuration flags for the Terrralib Statistic module.