All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IntersectionOp.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 IntersectionOp.cpp
22  */
23 
24 #include "../dataaccess/dataset/DataSet.h"
25 #include "../dataaccess/dataset/DataSetAdapter.h"
26 #include "../dataaccess/dataset/DataSetType.h"
27 #include "../dataaccess/dataset/DataSetTypeConverter.h"
28 #include "../dataaccess/datasource/DataSource.h"
29 #include "../dataaccess/datasource/DataSourceCapabilities.h"
30 #include "../dataaccess/utils/Utils.h"
31 
32 #include "../datatype/Property.h"
33 #include "../datatype/StringProperty.h"
34 
35 #include "../geometry/GeometryProperty.h"
36 
37 #include "../statistics/core/Utils.h"
38 
39 #include "IntersectionOp.h"
40 
42  m_outDsetName("")
43 {
44 }
45 
47  std::string inFirstDsetName,
48  std::auto_ptr<te::da::DataSetType> inFirstDsetType,
49  te::da::DataSourcePtr inSecondDsrc,
50  std::string inSecondDsetName,
51  std::auto_ptr<te::da::DataSetType> inSecondDsetType,
52  const te::da::ObjectIdSet* firstOidSet,
53  const te::da::ObjectIdSet* secondOidSet)
54 {
55  m_inFirstDsrc = inFirstDsrc;
56  m_inFirstDsetName = inFirstDsetName;
57  m_inFirstDsetType = inFirstDsetType;
58  m_inSecondDsrc = inSecondDsrc;
59  m_inSecondDsetName = inSecondDsetName;
60  m_inSecondDsetType = inSecondDsetType;
61 
62  m_firstOidSet = firstOidSet;
63  m_secondOidSet = secondOidSet;
64 }
65 
66 void te::vp::IntersectionOp::setParams( const bool& copyInputColumns,
67  std::size_t inSRID)
68 {
69  m_copyInputColumns = copyInputColumns;
70  m_SRID = inSRID;
71 }
72 
74 {
75  m_outDsrc = outDsrc;
76  m_outDsetName = dsname;
77 }
78 
80 {
81  if (geom == te::gm::PolygonType)
83 
84  if (geom == te::gm::LineStringType)
86 
87  if (geom == te::gm::PointType)
89 
90  return geom;
91 }
92 
94 {
95  if (!m_inFirstDsetType.get())
96  return false;
97 
98  if (!m_inFirstDsetType->hasGeom())
99  return false;
100 
101  if (!m_inSecondDsetType.get())
102  return false;
103 
104  if (!m_inSecondDsetType->hasGeom())
105  return false;
106 
107  if (m_outDsetName.empty() || !m_outDsrc.get())
108  return false;
109 
110  return true;
111 }
112 
113 std::vector<te::dt::Property*> te::vp::IntersectionOp::getTabularProps(te::da::DataSetType* dsType)
114 {
115  std::vector<te::dt::Property*> props;
116  te::dt::Property* prop;
117 
118  for(std::size_t i = 0; i < dsType->getProperties().size(); ++i)
119  {
120  prop = dsType->getProperty(i);
121 
122  if(prop->getType() != te::dt::GEOMETRY_TYPE && prop->getType() != te::dt::NUMERIC_TYPE)
123  {
124  props.push_back(prop);
125  }
126  }
127 
128  return props;
129 }
std::vector< te::dt::Property * > getTabularProps(te::da::DataSetType *dsType)
Property * getProperty(std::size_t i) const
It returns the i-th property.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
void setInput(te::da::DataSourcePtr inFirstDsrc, std::string inFirstDsetName, std::auto_ptr< te::da::DataSetType > inFirstDsetType, te::da::DataSourcePtr inSecondDsrc, std::string inSecondDsetName, std::auto_ptr< te::da::DataSetType > inSecondDsetType, const te::da::ObjectIdSet *firstOidSet=0, const te::da::ObjectIdSet *secondOidSet=0)
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1435
A class that models the description of a dataset.
Definition: DataSetType.h:72
virtual bool paramsAreValid()
It models a property definition.
Definition: Property.h:59
const std::vector< Property * > & getProperties() const
It returns the list of properties describing the CompositeProperty.
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(const bool &copyInputColumns, std::size_t inSRID)
Intersection operation.
int getType() const
It returns the property data type.
Definition: Property.h:161
te::gm::GeomType getGeomResultType(te::gm::GeomType geom)