MakeGeometryValid.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 MakeGeometryValid.h
22 
23  \brief Functions to make geometry valid.
24 
25  \ingroup vp
26  */
27 
28 #ifndef __TERRALIB_VP_INTERNAL_MAKEGEOMETRYVALID_H
29 #define __TERRALIB_VP_INTERNAL_MAKEGEOMETRYVALID_H
30 
31 //Terralib
32 
33 #include "../common/Static.h"
34 
35 #include "../dataaccess/datasource/DataSource.h"
36 #include "../dataaccess/dataset/ObjectIdSet.h"
37 
38 #include "Config.h"
39 
40 namespace te
41 {
42  namespace vp
43  {
44  /*!
45  \class MakeGeometryValid
46 
47  \brief A static class with methods to make geometry valid.
48  */
50  {
51  public:
52 
53  /*!
54  \brief This method gets the datasource capabilities and calls the specific function to fix geometry.
55 
56  \param dataSource The data source information.
57  \param dataSetName The input data name.
58  \param errorMessage Variable to catch any error occurred during execution.
59  \param oidSet Set of object ids to filter iconsistent geometries.
60 
61  \return True, if the function was executed successfully and the geometries fixed was updated.
62  */
63  static bool makeValid(const te::da::DataSourcePtr dataSource,
64  const std::string& dataSetName,
65  std::string& errorMessage,
66  te::da::ObjectIdSet* oidSet = 0);
67 
68  private:
69 
70  /*!
71  \brief It tries to fix invalid geometry by SQL clause ST_MakeValid and updates the source data.
72 
73  \param dataSource The data source information.
74  \param dataSetName The input data name.
75  \param errorMessage Variable to catch any error occurred during execution.
76 
77  \return True, if the query was executed successfully and the geometries fixed was updated.
78 
79  \note The layer must be inserted in a database with spatial extent.
80  */
81  static bool makeValidQuery(const te::da::DataSourcePtr dataSource,
82  const std::string& dataSetName,
83  std::string& errorMessage,
84  te::da::ObjectIdSet* oidSet = 0);
85 
86  /*!
87  \brief It tries to fix invalid geometry by GEOS and updates the source data.
88 
89  \param dataSource The data source information.
90  \param dataSetName The input data name.
91  \param errorMessage Variable to catch any error occurred during execution.
92 
93  \return True, if the query was executed successfully and the geometries fixed was updated.
94  */
95  static bool makeValidMemory(const te::da::DataSourcePtr dataSource,
96  const std::string& dataSetName,
97  std::string& errorMessage,
98  te::da::ObjectIdSet* oidSet = 0);
99  };
100  }
101 }
102 #endif // __TERRALIB_VP_INTERNAL_MAKEGEOMETRYVALID_H
#define TEVPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1440
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
URI C++ Library.
Configuration flags for the Terrralib Vector Processing module.
A base type for static classes.
Definition: Static.h:43
A static class with methods to make geometry valid.