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  {
73  QUERY
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 
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 
108 
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
A class that models the description of a dataset.
Definition: DataSetType.h:73
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:114
An abstract class for data providers like a DBMS, Web Services or a regular file.
Definition: DataSource.h:120
It is a collection of other geometric objects.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver.
Definition: DataSetItem.h:55
A class that represents an R-tree.
Definition: Index.h:57
This abstract class represents handler to help reading and writing data from/to a dataSource by divid...
Abstract class used to define an operation.
An alias for a set of Features.
Definition: Feature.h:60
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1449
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:42
std::vector< te::gm::Geometry * > GeometryVector
std::vector< const te::gm::Geometry * > GeometryVectorConst
TEVPEXPORT te::da::DataSourcePtr CreateOGRDataSource(std::string repository)
TEVPEXPORT void DropTemporaryDataSource(te::da::DataSourcePtr dataSource)
TEVPEXPORT bool IsLineStringType(const te::gm::GeomType &geomType)
TEVPEXPORT void Save(te::da::DataSource *source, te::da::DataSet *result, te::da::DataSetType *outDsType, const bool &enableProgress=true)
TEVPEXPORT std::string GetDistinctName(const std::string &name, std::vector< std::string > names, std::size_t maxSize=0)
TEVPEXPORT te::vp::AbstractDataHandler * CreateDataHandler(const std::string &dataHandlerName)
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...
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.
TEVPEXPORT std::unique_ptr< te::da::DataSet > PrepareAdd(te::da::DataSet *ds, te::da::DataSetType *dt)
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.
TEVPEXPORT bool IsPointType(const te::gm::GeomType &geomType)
TEVPEXPORT bool IsPolygonType(const te::gm::GeomType &geomType)
Strategy
Definition: Utils.h:71
@ QUERY
Definition: Utils.h:73
@ MEMORY
Definition: Utils.h:72
TEVPEXPORT te::vp::AbstractOperation * CreateOperation(const std::string &operationName)
TEVPEXPORT std::string GetSimpleTableName(std::string fullName)
TEVPEXPORT void ValidateAlgorithmParams(AlgorithmParams *mainParams, Strategy st)
TEVPEXPORT te::gm::Geometry * SetGeomAsMulti(const te::gm::Geometry &geom)
TEVPEXPORT te::da::DataSourcePtr CreateTemporaryDataSource()
Creates a data source located in the temporary folder of the user filesystem.
TEVPEXPORT te::sam::rtree::Index< size_t, 8 > * GetRtree(te::da::DataSet *data)
TEVPEXPORT te::gm::GeometryVectorConst GetGeometriesFromFeatureSet(const te::vp::FeatureSet &featureSet)
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.
TEVPEXPORT void SplitGeometryCollection(te::gm::GeometryCollection *geomIn, te::gm::GeometryCollection *gcOut)
TerraLib.
#define TEVPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
Proxy configuration file for TerraView (see terraview_config.h).
Utility classes, structures and definitions for Vector Processing.