AggregationOp.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 AggregationOp.cpp
22  */
23 
24 #include "../dataaccess/dataset/DataSet.h"
25 #include "../dataaccess/dataset/DataSetAdapter.h"
26 #include "../dataaccess/dataset/ObjectIdSet.h"
27 #include "../dataaccess/datasource/DataSource.h"
28 #include "../dataaccess/datasource/DataSourceCapabilities.h"
29 #include "../dataaccess/utils/Utils.h"
30 
31 #include "../datatype/Property.h"
32 #include "../datatype/StringProperty.h"
33 
34 #include "../geometry/GeometryProperty.h"
35 
36 #include "../statistics/core/Utils.h"
37 
38 #include "AggregationOp.h"
39 
41  : m_oidSet(0),
42  m_outDset("")
43 {
44 }
45 
47  std::string inDsetName,
48  std::auto_ptr<te::da::DataSetTypeConverter> converter,
49  const te::da::ObjectIdSet* oidSet)
50 {
51  m_inDsrc = inDsrc;
52  m_inDsetName = inDsetName;
53  m_converter = converter;
54  m_oidSet = oidSet;
55 }
56 
57 void te::vp::AggregationOp::setParams(std::vector<te::dt::Property*>& groupProps,
58  std::map<te::dt::Property*, std::vector<te::stat::StatisticalSummary> >&statSum)
59 {
60  m_groupProps = groupProps;
61  m_statSum = statSum;
62 }
63 
65 {
66  m_outDsrc = outDsrc;
67  m_outDset = dsname;
68 }
69 
71 {
72  if ((geom == te::gm::PolygonType) ||
73  (geom == te::gm::PolygonZType) ||
74  (geom == te::gm::PolygonMType) ||
75  (geom == te::gm::PolygonZMType) ||
76  (geom == te::gm::MultiPolygonZType) ||
77  (geom == te::gm::MultiPolygonMType) ||
80 
81  if ((geom == te::gm::LineStringType) ||
82  (geom == te::gm::LineStringZType) ||
83  (geom == te::gm::LineStringMType) ||
84  (geom == te::gm::LineStringZMType) ||
85  (geom == te::gm::MultiLineStringZType) ||
86  (geom == te::gm::MultiLineStringMType) ||
89 
90  if ((geom == te::gm::PointType) ||
91  (geom == te::gm::PointZType) ||
92  (geom == te::gm::PointMType) ||
93  (geom == te::gm::PointZMType) ||
94  (geom == te::gm::PointKdType) ||
95  (geom == te::gm::MultiPointZType) ||
96  (geom == te::gm::MultiPointMType) ||
97  (geom == te::gm::MultiPointZMType))
99 
100  return geom;
101 }
102 
104 {
105  if (!m_converter.get())
106  return false;
107 
108  if (!m_converter->getResult()->hasGeom())
109  return false;
110 
111  if (m_groupProps.empty())
112  return false;
113 
114  if (m_outDset.empty() || !m_outDsrc.get())
115  return false;
116 
117  return true;
118 }
Aggregation operation.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
void setInput(te::da::DataSourcePtr inDsrc, std::string inDsetName, std::auto_ptr< te::da::DataSetTypeConverter > converter, const te::da::ObjectIdSet *oidSet=0)
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1435
te::gm::GeomType getGeomResultType(te::gm::GeomType geom)
It models a property definition.
Definition: Property.h:59
virtual bool paramsAreValid()
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
void setOutput(te::da::DataSourcePtr outDsrc, std::string dsname)
void setParams(std::vector< te::dt::Property * > &groupProps, std::map< te::dt::Property *, std::vector< te::stat::StatisticalSummary > > &statSum)