27 #include "../../common/UnitOfMeasure.h" 28 #include "../../dataaccess/dataset/DataSetAdapter.h" 29 #include "../../dataaccess/dataset/DataSetTypeConverter.h" 30 #include "../../dataaccess/dataset/ObjectIdSet.h" 32 #include "../../dataaccess/datasource/DataSourceInfo.h" 33 #include "../../dataaccess/datasource/DataSourceManager.h" 35 #include "../../dataaccess/query/And.h" 36 #include "../../dataaccess/query/DataSetName.h" 37 #include "../../dataaccess/query/Expression.h" 38 #include "../../dataaccess/query/Field.h" 39 #include "../../dataaccess/query/Fields.h" 40 #include "../../dataaccess/query/From.h" 41 #include "../../dataaccess/query/FromItem.h" 42 #include "../../dataaccess/query/LiteralInt32.h" 43 #include "../../dataaccess/query/PropertyName.h" 44 #include "../../dataaccess/query/ST_SetSRID.h" 45 #include "../../dataaccess/query/ST_Transform.h" 46 #include "../../dataaccess/query/Where.h" 48 #include "../../dataaccess/utils/Utils.h" 50 #include "../../maptools/DataSetLayer.h" 51 #include "../../maptools/QueryLayer.h" 53 #include "../../geometry/Geometry.h" 54 #include "../../geometry/GeometryCollection.h" 55 #include "../../geometry/GeometryProperty.h" 57 #include "../../memory/DataSet.h" 59 #include "../../srs/SpatialReferenceSystemManager.h" 64 #include <QMessageBox> 72 #include <boost/algorithm/string.hpp> 76 std::list<te::map::AbstractLayerPtr> filteredList;
78 for(std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin(); it != layers.end(); ++it)
80 std::string layName = (*it)->getTitle().substr(0, text.size());
82 if(boost::to_upper_copy(layName) == boost::to_upper_copy(text))
83 filteredList.push_back(*it);
95 if (layer->getType() ==
"DATASETLAYER")
100 QMessageBox::information(
nullptr,
"Error",
"Can not execute this operation on this type of layer.");
104 else if (layer->getType() ==
"QUERYLAYER")
109 QMessageBox::information(
nullptr,
"Error",
"Can not execute this operation on this type of layer.");
115 QMessageBox::information(
nullptr,
"Error",
"Can not execute this operation on this type of layer.");
130 fields->push_back(f_all);
134 std::unique_ptr<te::da::DataSetType> dsType = dataSetLayer->
getSchema();
135 std::vector<te::dt::Property*> properties = dsType.get()->getProperties();
137 for (std::size_t i = 0; i < properties.size(); ++i)
142 fields->push_back(currentField);
147 int sourceSRID = sourceGeomProp->
getSRID();
153 if (sourceSRID != srid)
159 fields->push_back(geomField);
168 from->push_back(fromItem);
171 if (onlySelectedObjects)
176 QMessageBox::information(
nullptr,
"Vector Processing",
"Select the layer objects to perform the operation.");
191 std::unique_ptr<te::da::DataSetType> dsType = queryLayer->
getSchema();
192 std::vector<te::dt::Property*> properties = dsType.get()->getProperties();
196 for (std::size_t i = 0; i < properties.size(); ++i)
201 fields->push_back(currentField);
206 int sourceSRID = sourceGeomProp->
getSRID();
212 if (sourceSRID != srid)
218 fields->push_back(geomField);
226 if (onlySelectedObjects)
231 QMessageBox::information(
nullptr,
"Vector Processing",
"Select the layer objects to perform the operation.");
255 std::string sourceId = layer->getDataSourceId();
258 std::unique_ptr<te::da::DataSetType> dataSetType = layer->getSchema();
259 std::unique_ptr<te::da::DataSet> dataSet = dataSource->getDataSet(dataSetType->getName());
261 if (dataSetType.get() && dataSet.get())
263 if (onlySelectedObjects)
268 QMessageBox::information(
nullptr,
"Vector Processing",
"Select the layer objects to perform the operation.");
272 dataSet = dataSource->getDataSet(dataSetType->getName(), oidSet);
280 if (srid != 0 && srid != geomProp->
getSRID())
282 std::unique_ptr<te::da::DataSetTypeConverter> converter(
new te::da::DataSetTypeConverter(dataSetType.get(), dataSource->getCapabilities(), dataSource->getEncoding()));
292 dataSet.reset(dataSetAdapter);
std::unique_ptr< LayerSchema > getSchema() const
It returns the layer schema.
te::da::DataSetType * m_dataSetType
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...
te::da::Select * GetSelectQueryFromLayer(te::map::AbstractLayerPtr layer, bool onlySelectedObjects, int srid=0)
DataStruct GetDataStructFromLayer(te::map::AbstractLayerPtr layer, bool onlySelectedObjects, int srid=0)
A class that models the name of a dataset used in a From clause.
boost::shared_ptr< DataSource > DataSourcePtr
TEDATAACCESSEXPORT void AssociateDataSetTypeConverterSRID(DataSetTypeConverter *converter, const int &inputSRID, const int &outputSRID=TE_UNKNOWN_SRS)
A class that models the name of any property of an object.
A class that models the description of a dataset.
virtual Expression * clone() const =0
It creates a new copy of this expression.
std::unique_ptr< LayerSchema > getSchema() const
It returns the layer schema.
A layer resulting from a query.
Boolean logic operator: AND.
Get a list of AbstractLayer filtered by the name;.
This is an abstract class that models a query expression.
An converter for DataSetType.
std::list< te::map::AbstractLayerPtr > GetFilteredLayers(std::string text, std::list< te::map::AbstractLayerPtr > layers)
Get a list of AbstractLayer filtered by the name;.
void setWhere(Where *w)
It sets the filter codition.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
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.
bool IsProjectionLatLong(const int &srid)
Expression * getExp() const
te::da::Select * getQuery() const
Utility functions for the data access module.
A Select models a query to be used when retrieving data from a DataSource.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
Spatial Set SRID operator.
Where * getWhere() const
It returns the filter condition.
boost::shared_ptr< UnitOfMeasure > UnitOfMeasurePtr
const std::string & getDataSetName() const
A layer with reference to a dataset.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
Expression * getExpression() const
It returns the expression that can be used to retrieve the data set that contains the all indentified...
void setFields(Fields *f)
It sets the list of output expressions used to form the result set.
te::da::DataSet * m_dataSet
void setFrom(From *f)
It sets the list of source information.