Utils.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/vp/Utils.h
22 
23  \brief Utility functions for Vector Processing.
24 */
25 
26 #ifndef __TERRALIB_VP_INTERNAL_UTILS_H
27 #define __TERRALIB_VP_INTERNAL_UTILS_H
28 
29 // Terralib
30 #include "../dataaccess/datasource/DataSource.h"
31 
32 #include "../geometry/CommonDataStructures.h"
33 #include "../geometry/Enums.h"
34 
35 #include "../sam/rtree.h"
36 
37 #include "Config.h"
38 #include "CommonDataStructures.h"
39 
40 //STL
41 #include <map>
42 #include <string>
43 
44 namespace te
45 {
46  namespace da
47  {
48  class DataSet;
49  class DataSetType;
50  }
51 
52  namespace gm
53  {
54  class Geometry;
55  class GeometryCollection;
56  }
57 
58  namespace mem
59  {
60  class DataSetItem;
61  }
62 
63  namespace vp
64  {
65  class AlgorithmParams;
66  class AbstractDataHandler;
67  class AbstractOperation;
68  class FeatureSet;
69 
70  enum Strategy
71  {
74  };
75 
76  /*!
77  \brief It returns the union of a geometry vector.
78 
79  \param items Vector of itens that represents a group.
80 
81  \return Union of the geometry.
82  */
83  TEVPEXPORT te::gm::Geometry* GetGeometryUnion(const std::vector<te::mem::DataSetItem*>& items, size_t geomIdx, te::gm::GeomType outGeoType);
84 
85  TEVPEXPORT te::gm::Geometry* GetGeometryUnion(const std::vector<te::mem::DataSetItem*>& items, size_t geomIdx);
86 
88 
89  TEVPEXPORT std::string GetSimpleTableName(std::string fullName);
90 
91  TEVPEXPORT std::unique_ptr<te::da::DataSet> PrepareAdd(te::da::DataSet* ds, te::da::DataSetType* dt);
92 
93  TEVPEXPORT void Save(te::da::DataSource* source, te::da::DataSet* result, te::da::DataSetType* outDsType, const bool& enableProgress = true);
94 
96 
97  TEVPEXPORT void ValidateAlgorithmParams(AlgorithmParams* mainParams, Strategy st);
98 
100 
102 
103  TEVPEXPORT std::string GetDistinctName(const std::string& name, std::vector<std::string> names, std::size_t maxSize = 0);
104 
105  TEVPEXPORT bool IsPointType(const te::gm::GeomType& geomType);
106 
107  TEVPEXPORT bool IsLineStringType(const te::gm::GeomType& geomType);
108 
109  TEVPEXPORT bool IsPolygonType(const te::gm::GeomType& geomType);
110 
111  /*!
112  \brief It returns a memory item with all properties filled with values
113  from the current position dataset.
114 
115  \param dataSet DataSet in the current position to get values.
116 
117  \return A memory item with attributes filled with dataSet values.
118  */
120 
121  /*!
122  \brief Creates a memory dataSet based on the given featureSet
123 
124  \param dataSetName The name of the dataSet
125  \param dataSetType The dataSetType of the dataSet
126  \param featureSet The featureSet to be converted
127 
128  \return A memory dataSet containing all the given features
129  */
130  TEVPEXPORT std::unique_ptr<te::da::DataSet> CreateDataSetFromFeatureSet(const std::string& dataSetName, const te::da::DataSetType* dataSetType, const te::vp::FeatureSet& featureSet);
131 
132  //!< Extracts the GeometryVector from the given FeatureSet. The caller must free the memory after using the resulting geometry vector
134 
135  //!< Gets the GeometryVector from the given FeatureSet. The caller must NOT free the memory after using the resulting geometry vector as this method returns the reference to the geometries
137 
138  /*!
139  \brief Creates a data source located in the temporary folder of the user filesystem
140  \return A a data source located in the temporary folder of the user filesystem
141  */
143 
145 
146  TEVPEXPORT te::vp::AbstractOperation* CreateOperation(const std::string& operationName);
147 
148  TEVPEXPORT te::vp::AbstractDataHandler* CreateDataHandler(const std::string& dataHandlerName);
149 
150  } // end namespace vp
151 } // end namespace te
152 
153 #endif // __TERRALIB_VP_INTERNAL_UTILS_H
std::vector< te::gm::Geometry * > GeometryVector
#define TEVPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
TEVPEXPORT te::da::DataSourcePtr CreateTemporaryDataSource()
Creates a data source located in the temporary folder of the user filesystem.
TEVPEXPORT te::da::DataSourcePtr CreateOGRDataSource(std::string repository)
TEVPEXPORT te::gm::GeometryVector ExtractGeometriesFromFeatureSet(const te::vp::FeatureSet &featureSet)
Gets the GeometryVector from the given FeatureSet. The caller must NOT free the memory after using th...
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1449
A class that represents an R-tree.
Definition: Index.h:56
A class that models the description of a dataset.
Definition: DataSetType.h:72
TEVPEXPORT void ValidateAlgorithmParams(AlgorithmParams *mainParams, Strategy st)
TEVPEXPORT te::vp::AbstractOperation * CreateOperation(const std::string &operationName)
TEVPEXPORT void DropTemporaryDataSource(te::da::DataSourcePtr dataSource)
TEVPEXPORT void Save(te::da::DataSource *source, te::da::DataSet *result, te::da::DataSetType *outDsType, const bool &enableProgress=true)
This abstract class represents handler to help reading and writing data from/to a dataSource by divid...
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:119
TEVPEXPORT void SplitGeometryCollection(te::gm::GeometryCollection *geomIn, te::gm::GeometryCollection *gcOut)
TEVPEXPORT bool IsLineStringType(const te::gm::GeomType &geomType)
TEVPEXPORT te::vp::AbstractDataHandler * CreateDataHandler(const std::string &dataHandlerName)
An alias for a set of Features.
Definition: Feature.h:60
TEVPEXPORT te::mem::DataSetItem * GetFilledItemMemory(te::da::DataSet *dataSet)
It returns a memory item with all properties filled with values from the current position dataset...
Abstract class used to define an operation.
TEVPEXPORT std::string GetDistinctName(const std::string &name, std::vector< std::string > names, std::size_t maxSize=0)
std::vector< const te::gm::Geometry * > GeometryVectorConst
TEVPEXPORT te::gm::Geometry * SetGeomAsMulti(const te::gm::Geometry &geom)
TerraLib.
TEVPEXPORT std::string GetSimpleTableName(std::string fullName)
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:77
TEVPEXPORT te::gm::GeometryVectorConst GetGeometriesFromFeatureSet(const te::vp::FeatureSet &featureSet)
TEVPEXPORT bool IsPolygonType(const te::gm::GeomType &geomType)
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
Definition: DataSetItem.h:54
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:113
TEVPEXPORT bool IsPointType(const te::gm::GeomType &geomType)
TEVPEXPORT std::unique_ptr< te::da::DataSet > CreateDataSetFromFeatureSet(const std::string &dataSetName, const te::da::DataSetType *dataSetType, const te::vp::FeatureSet &featureSet)
Creates a memory dataSet based on the given featureSet.
Configuration flags for the Terrralib Vector Processing module.
TEVPEXPORT te::sam::rtree::Index< size_t, 8 > * GetRtree(te::da::DataSet *data)
It is a collection of other geometric objects.
TEVPEXPORT te::gm::Geometry * GetGeometryUnion(const std::vector< te::mem::DataSetItem *> &items, size_t geomIdx, te::gm::GeomType outGeoType)
It returns the union of a geometry vector.
Strategy
Definition: Utils.h:70
TEVPEXPORT std::unique_ptr< te::da::DataSet > PrepareAdd(te::da::DataSet *ds, te::da::DataSetType *dt)