All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Grouping.cpp
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 Grouping.cpp
22 
23  \brief This class contains the parameters needed for grouping the values of a Property.
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "../datatype/Enums.h"
29 #include "Grouping.h"
30 #include "GroupingItem.h"
31 
32 
33 te::map::Grouping::Grouping(const std::string& propertyName, te::map::GroupingType type, size_t precision)
34  : m_propertyName(propertyName),
35  m_type(type),
36  m_precision(precision),
37  m_isVisible(true),
38  m_summary("AVERAGE")
39 {
41 }
42 
44  : m_propertyName(rhs.m_propertyName),
45  m_type((te::map::GroupingType)rhs.m_propertyType),
46  m_precision(rhs.m_precision),
47  m_isVisible(true),
48  m_summary(rhs.m_summary)
49 {
52 
53  std::vector<te::map::GroupingItem*> items;
54  for(std::size_t i = 0; i < rhs.m_items.size(); ++i)
55  {
57  items.push_back(item);
58  }
59 
60  setGroupingItems(items);
61 }
62 
64 {
65  te::common::FreeContents(m_items);
66 }
67 
69 {
70  return m_propertyName;
71 }
72 
73 
74 void te::map::Grouping::setPropertyName(const std::string& name)
75 {
76  m_propertyName = name;
77 }
78 
80 {
81  return m_propertyType;
82 }
83 
85 {
86  m_propertyType = type;
87 }
88 
89 
91 {
92  return m_type;
93 }
94 
96 {
97  m_type = type;
98 }
99 
101 {
102  return m_precision;
103 }
104 
105 void te::map::Grouping::setPrecision(size_t precision)
106 {
107  m_precision = precision;
108 }
109 
111 {
112  return m_numSlices;
113 }
114 
115 void te::map::Grouping::setNumSlices(size_t numSlices)
116 {
117  m_numSlices = numSlices;
118 }
119 
121 {
122  return m_stdDeviation;
123 }
124 
125 void te::map::Grouping::setStdDeviation(double stdDeviation)
126 {
127  m_stdDeviation = stdDeviation;
128 }
129 
130 const std::vector<te::map::GroupingItem*>& te::map::Grouping::getGroupingItems() const
131 {
132  return m_items;
133 }
134 
135 void te::map::Grouping::setGroupingItems(std::vector<te::map::GroupingItem*>& items)
136 {
137  m_items = items;
138 
139  m_numSlices = m_items.size();
140 }
141 
143 {
144  return m_isVisible;
145 }
146 
148 {
149  m_isVisible = visible;
150 }
151 
152 std::string te::map::Grouping::getSummary() const
153 {
154  return m_summary;
155 }
156 
157 void te::map::Grouping::setSummary(const std::string& summary)
158 {
159  m_summary = summary;
160 }
void setPrecision(size_t precision)
It sets the precision to be used for the property values.
Definition: Grouping.cpp:105
const double getStdDeviation() const
It gets the standard deviation used in the Standard Deviation grouping.
Definition: Grouping.cpp:120
int getPropertyType() const
It gets the property type whose values will be grouped.
Definition: Grouping.cpp:79
~Grouping()
Destructor.
Definition: Grouping.cpp:63
void setGroupingItems(std::vector< te::map::GroupingItem * > &items)
It sets the vector of grouping items.
Definition: Grouping.cpp:135
const size_t getPrecision() const
It gets the precision used for the property values.
Definition: Grouping.cpp:100
std::string getPropertyName() const
It gets the property name whose values will be grouped.
Definition: Grouping.cpp:68
void setStdDeviation(double stdDeviation)
It sets the standard deviation for the Standard Deviation grouping.
Definition: Grouping.cpp:125
This class contains the parameters needed for grouping the values of a Property.
Definition: Grouping.h:59
void setPropertyName(const std::string &name)
It sets the property name whose values will be grouped.
Definition: Grouping.cpp:74
void setNumSlices(size_t numSlices)
It sets the number of slices for the EqualSteps and Quantil groupings.
Definition: Grouping.cpp:115
A GroupingItem contains information about a grouping item associated to a layer.
Definition: GroupingItem.h:48
void setPropertyType(const int &type)
It sets the property type whose values will be grouped.
Definition: Grouping.cpp:84
void setVisibility(bool visible)
It sets the grouping visibility.
Definition: Grouping.cpp:147
int m_propertyType
The property type whose values will be used to make the grouping.
Definition: Grouping.h:200
double m_stdDeviation
The standard deviation used in the Standard Deviation grouping.
Definition: Grouping.h:204
bool isVisible() const
It gets the grouping visibility.
Definition: Grouping.cpp:142
std::vector< te::map::GroupingItem * > m_items
The vector of grouping items.
Definition: Grouping.h:206
void setSummary(const std::string &summary)
It gets the grouping summary. It is used only in case 1 to n.
Definition: Grouping.cpp:157
const std::vector< te::map::GroupingItem * > & getGroupingItems() const
It gets the vector of grouping items.
Definition: Grouping.cpp:130
GroupingType
The grouping type associated to the layer.
Definition: Enums.h:150
Grouping(const std::string &propertyName, GroupingType type, size_t precision=6)
It constructs a new Grouping instance.
Definition: Grouping.cpp:33
std::string getSummary() const
It gets the grouping summary. It is used only in case 1 to n.
Definition: Grouping.cpp:152
const GroupingType getType() const
It gets the grouping type.
Definition: Grouping.cpp:90
size_t m_numSlices
The number of slices used in the Equal Steps and Quantil groupings.
Definition: Grouping.h:203
This class contains the parameters needed for grouping the values of a Property.
const size_t getNumSlices() const
It gets the number of slices used in the Equal Steps and Quantil groupings.
Definition: Grouping.cpp:110
void setType(GroupingType type)
It sets the grouping type.
Definition: Grouping.cpp:95
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
Definition: BoostUtils.h:55