Loading...
Searching...
No Matches
HistogramUtils.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/qt/widgets/charts/HistogramUtils.h
22
23 \brief This file contains a set of utility histogram functions
24*/
25
26#ifndef __TERRALIB_QT_WIDGETS_INTERNAL_HISTOGRAMUTILS_H
27#define __TERRALIB_QT_WIDGETS_INTERNAL_HISTOGRAMUTILS_H
28
29//TerraLib
30#include "../Config.h"
31#include "../../../datatype/SimpleData.h"
32#include "../../../dataaccess/dataset/ObjectId.h"
33
34//STL
35#include <map>
36#include <set>
37#include <string>
38
39// Boost
40#include <boost/multi_index_container.hpp>
41#include <boost/multi_index/ordered_index.hpp>
42#include <boost/multi_index/identity.hpp>
43#include <boost/multi_index/member.hpp>
44#include <boost/multi_index/mem_fun.hpp>
45
46namespace te
47{
48 namespace qt
49 {
50 namespace widgets
51 {
52
53 //The struct used to sort the elements of the HistogramValues map
55 {
57 {
58 int type = v1->getTypeCode();
59 switch(type)
60 {
62 return (static_cast<te::dt::Double*>(v1)->getValue() < static_cast<te::dt::Double*>(v2)->getValue());
64 return (static_cast<te::dt::String*>(v1)->getValue() < static_cast<te::dt::String*>(v2)->getValue());
65 default:
66 return false;
67 }
68 }
69 };
70
71 typedef std::map<te::dt::AbstractData*, unsigned int, CompareHistogramInterval> HistogramValues; //!< Histogram's values
72
73 // The struct used to store the interval and it's object id
75 {
78
79 IntervalToObjectId(te::dt::AbstractData* p_interval, te::da::ObjectId* p_oid) : interval(p_interval), oid(p_oid){}
80
81 bool operator<(const IntervalToObjectId& v) const
82 {
84 return comp(interval, v.interval);
85 }
86
87 std::string getObjIdAsString() const
88 {
89 return oid->getValueAsString();
90 }
91 };
92
93 // define a multiply indexed set with indices by
94 typedef boost::multi_index::multi_index_container<
95 IntervalToObjectId,
96 boost::multi_index::indexed_by<
97
98 // sort by less<string> or < on Interval
99 boost::multi_index::ordered_non_unique<
100 boost::multi_index::identity<IntervalToObjectId> >,
101
102 // sort by less<string> on objectID
103 boost::multi_index::ordered_unique<
104 boost::multi_index::const_mem_fun<IntervalToObjectId, std::string, &IntervalToObjectId::getObjIdAsString> >
105 >
107
108 } // end namespace widgets
109 } // end namespace qt
110} // end namespace te
111
112#endif // __TERRALIB_QT_WIDGETS_INTERNAL_HISTOGRAMUTILS_H
This class represents an unique id for a data set element.
Definition: ObjectId.h:48
std::string getValueAsString() const
It gets the properties values used to uniquely identify a data set element as string.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:56
virtual int getTypeCode() const =0
It returns the data type code associated to the data value.
A template for atomic data types (integers, floats, strings and others).
Definition: SimpleData.h:60
@ DOUBLE_TYPE
Definition: Enums.h:198
@ STRING_TYPE
Definition: Enums.h:200
std::map< te::dt::AbstractData *, unsigned int, CompareHistogramInterval > HistogramValues
Histogram's values.
boost::multi_index::multi_index_container< IntervalToObjectId, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< boost::multi_index::identity< IntervalToObjectId > >, boost::multi_index::ordered_unique< boost::multi_index::const_mem_fun< IntervalToObjectId, std::string, &IntervalToObjectId::getObjIdAsString > > > > IntervalToObjectIdSet
TerraLib.
bool operator()(te::dt::AbstractData *v1, te::dt::AbstractData *v2) const
bool operator<(const IntervalToObjectId &v) const
te::dt::AbstractData * interval
IntervalToObjectId(te::dt::AbstractData *p_interval, te::da::ObjectId *p_oid)
std::string getObjIdAsString() const