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