28 #include "../common/progress/TaskProgress.h"
29 #include "../common/Logger.h"
30 #include "../common/Translator.h"
32 #include "../dataaccess/dataset/DataSet.h"
33 #include "../dataaccess/dataset/DataSetType.h"
35 #include "../datatype/Property.h"
36 #include "../datatype/SimpleProperty.h"
37 #include "../datatype/StringProperty.h"
39 #include "../dataaccess/dataset/ObjectIdSet.h"
40 #include "../dataaccess/query/And.h"
41 #include "../dataaccess/query/DataSetName.h"
42 #include "../dataaccess/query/Expression.h"
43 #include "../dataaccess/query/Field.h"
44 #include "../dataaccess/query/Fields.h"
45 #include "../dataaccess/query/From.h"
46 #include "../dataaccess/query/FromItem.h"
47 #include "../dataaccess/query/Join.h"
48 #include "../dataaccess/query/JoinConditionOn.h"
49 #include "../dataaccess/query/PropertyName.h"
50 #include "../dataaccess/query/Select.h"
51 #include "../dataaccess/query/ST_Intersection.h"
52 #include "../dataaccess/query/ST_Intersects.h"
53 #include "../dataaccess/query/Where.h"
54 #include "../dataaccess/utils/Utils.h"
56 #include "../geometry/Geometry.h"
57 #include "../geometry/GeometryCollection.h"
58 #include "../geometry/GeometryProperty.h"
59 #include "../geometry/Utils.h"
61 #include "../memory/DataSet.h"
62 #include "../memory/DataSetItem.h"
93 std::vector<te::dt::Property*> firstProps = getTabularProps(m_inFirstDsetType.get());
94 std::vector<te::dt::Property*> secondProps;
95 if(m_copyInputColumns)
96 secondProps = getTabularProps(m_inSecondDsetType.get());
107 for(std::size_t i = 0; i < firstProps.size(); ++i)
109 te::da::Field* f_field =
new te::da::Field(firstTableName +
"." + firstProps[i]->getName() +
" ", firstTableName +
"_" + firstProps[i]->getName());
110 fields->push_back(f_field);
113 for(std::size_t i = 0; i < secondProps.size(); ++i)
115 te::da::Field* f_field =
new te::da::Field(secondTableName +
"." + secondProps[i]->getName() +
" ", secondTableName +
"_" + secondProps[i]->getName());
116 fields->push_back(f_field);
122 fields->push_back(f_intersection);
132 from->push_back(join);
139 if(m_firstOidSet && m_secondOidSet)
141 te::da::And* exp_and =
new te::da::And(m_firstOidSet->getExpressionByInClause(m_inFirstDsetType->getName()), m_secondOidSet->getExpressionByInClause(m_inSecondDsetType->getName()));
144 else if(m_firstOidSet)
145 w_oid =
new te::da::Where(m_firstOidSet->getExpressionByInClause(m_inFirstDsetType->getName()));
146 else if(m_secondOidSet)
147 w_oid =
new te::da::Where(m_secondOidSet->getExpressionByInClause(m_inSecondDsetType->getName()));
151 std::auto_ptr<te::da::DataSet> dsQuery = m_inFirstDsrc->query(select);
152 dsQuery->moveBeforeFirst();
154 if(dsQuery->size() == 0)
162 outDataSetType->add(pkProperty);
166 outDataSetType->setPrimaryKey(pk);
168 for(
size_t i = 0; i < firstProps.size(); ++i)
171 if(!m_inFirstDsetType->getTitle().empty())
173 outDataSetType->add(prop);
176 for(
size_t i = 0; i < secondProps.size(); ++i)
180 outDataSetType->add(prop);
187 newGeomProp->setGeometryType(newType);
190 outDataSetType->add(newGeomProp);
192 std::auto_ptr<te::da::DataSet> outDset(this->updateGeomType(outDataSetType.get(), dsQuery.release()));
194 outDset->moveBeforeFirst();
196 te::vp::Save(m_outDsrc.get(), outDset.get(), outDataSetType.get());
205 std::size_t type = 0;
206 std::vector<te::dt::Property*> props = dsType->
getProperties();
211 std::string propName;
216 for(std::size_t i = 1; i < props.size(); ++i)
218 type = props[i]->getType();
219 propName = props[i]->getName();
223 if (!ds->
isNull(propName))
225 std::auto_ptr<te::dt::AbstractData> value = ds->
getValue(propName);
226 dsItem->
setValue(i, value.release());
231 std::auto_ptr<te::gm::Geometry> geom = ds->
getGeometry(propName);
243 newGeom->add(geom.release());
256 newGeom->add(geom.release());
269 newGeom->add(geom.release());
void setAutoNumber(bool a)
It tells if the property is an autonumber or not.
An exception class for the Vector processing module.
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
void setGeometry(std::size_t i, te::gm::Geometry *value)
It sets the value of the i-th property.
Utility functions for the data access module.
An abstract class that models a source of data in a query.
The Field class can be used to model an expression that takes part of the output items of a SELECT...
An atomic property like an integer or double.
Spatial intersects operator.
A class that models the name of a dataset used in a From clause.
Intersection Vector Processing functions.
A class that models the name of any property of an object.
A class that models the description of a dataset.
void Save(te::da::DataSource *source, te::da::DataSet *result, te::da::DataSetType *outDsType)
virtual Property * clone() const =0
It returns a clone of the object.
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property.
#define TE_TR(message)
It marks a string in order to get translated.
It models a property definition.
Boolean logic operator: AND.
This is an abstract class that models a query expression.
void add(DataSetItem *item)
It adds a new item to the dataset and takes its ownership.
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
void setWhere(Where *w)
It sets the filter codition.
void setName(const std::string &name)
It sets the property name.
const std::vector< Property * > & getProperties() const
It returns the list of properties describing the CompositeProperty.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
A class that can be used to model a filter expression that can be applied to a query.
A Join clause combines two FromItems.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
A Select models a query to be used when retrieving data from a DataSource.
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
A dataset is the unit of information manipulated by the data access module of TerraLib.
te::gm::GeomType GeomOpResultType(te::gm::GeomType firstGeom, te::gm::GeomType secondGeom)
Spatial intersection operator.
te::da::DataSet * updateGeomType(te::da::DataSetType *dsType, te::da::DataSet *ds)
It describes a primary key (pk) constraint.
JoinConditionOn is a boolean expression and it specifies which items in a join are considered to matc...
Configuration flags for the Terrralib Vector Processing module.
It is a collection of other geometric objects.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
void setFields(Fields *f)
It sets the list of output expressions used to form the result set.
virtual std::auto_ptr< te::dt::AbstractData > getValue(std::size_t i) const
Method for retrieving any other type of data value stored in the data source.
void setFrom(From *f)
It sets the list of source information.
const std::string & getName() const
It returns the property name.
std::string GetSimpleTableName(std::string fullName)