BufferOp.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 BufferOp.h
22 
23  \brief Buffer operation.
24 
25  \ingroup vp
26  */
27 
28 #ifndef __TERRALIB_VP_INTERNAL_BUFFER_OP_H
29 #define __TERRALIB_VP_INTERNAL_BUFFER_OP_H
30 
31 //Terralib
32 
33 #include "../dataaccess/dataset/DataSet.h"
34 #include "../dataaccess/dataset/DataSetTypeConverter.h"
35 #include "../dataaccess/datasource/DataSource.h"
36 
37 #include "../datatype/Property.h"
38 
39 #include "../memory/DataSet.h"
40 #include "../statistics/core/Enums.h"
41 
42 #include "Config.h"
43 #include "Enums.h"
44 
45 // STL
46 #include <map>
47 #include <memory>
48 #include <string>
49 
50 namespace te
51 {
52  namespace vp
53  {
54  /*!
55  \class BufferOp
56 
57  \brief An abstract class to compute the buffer memory and buffer query operation.
58 
59  \ingroup vp
60  */
62  {
63  public:
64 
65  /*! \brief Default constructor that can be called by subclasses. */
66  BufferOp();
67 
68  /*! \brief Virtual destructor. */
69  virtual ~BufferOp() {}
70 
71  /*!
72  \brief It executes the operation.
73 
74  \return A Boolean value that means if the operation successfully completed or not.
75  */
76  virtual bool run() = 0;
77 
78  /*!
79  \brief It verifies if the parameters are valid.
80 
81  \return A Boolean value that means if the operation successfully completed or not.
82  */
83  virtual bool paramsAreValid();
84 
85  /*!
86  \brief It sets the input data will be calculated.
87 
88  \param inDsrc Where data is located.
89  \param inDsetName DataSet name.
90  \param converter DataSetTypeConverterr.
91  \param oidSet ObjectIdSet - It is necessary if has need to execute with a set of specific objects
92  */
93  void setInput(te::da::DataSourcePtr inDsrc,
94  std::string inDsetName,
95  std::auto_ptr<te::da::DataSetTypeConverter> converter,
96  const te::da::ObjectIdSet* oidSet = 0);
97 
98  /*!
99  \brief It sets the input parameters that will be consumed to execute the operation.
100 
101  \param distance A numeric value to set a fixed distance to buffer.
102  \param bufferPolygonRule The rule used for buffer result (INSIDE_OUTSIDE = 0, ONLY_OUTSIDE = 1, ONLY_INSIDE = 2).
103  \param bufferBoundariesRule The BoundariesBetweenBuffers can be dissolved or not - (DISSOLVE = 0 and NOT_DISSOLVE = 1).
104  \param copyInputColumns Copy columns from input DataSet.
105  \param levels The number of levels buffer will have.
106  \param attributePosition The buffer can be calculated by attribute values. The attribute must be numeric type.
107 
108  \note If uses attibutePosition parameter, the fixed distance will be ignored.
109  \note The attributePosition parameter must be numeric type.
110  \note If there is a null value or zero in chosen attribute, the line that has this value will be ignored.
111  */
112  void setParams(const double& distance,
113  const int& bufferPolygonRule,
114  const int& bufferBoundariesRule,
115  const bool& copyInputColumns,
116  const int& levels,
117  const int& attributePosition = -1);
118 
119  /*!
120  \brief It sets the output parameters that will be used to persist operation result.
121 
122  \param outDsrc Where data is will be persisted.
123  \param dsname The name os output data.
124 
125  \note The output name must be different from other data that is already in dataSource.
126  */
127  void setOutput(te::da::DataSourcePtr outDsrc, std::string dsname);
128 
129  protected:
130 
131  /*!
132  \brief It builds the output DataSetType.
133  */
135 
136  te::da::DataSourcePtr m_inDsrc; //!< The input datasource.
137  std::string m_inDsetName; //!< The input dataset name
138  std::auto_ptr<te::da::DataSetTypeConverter> m_converter; //!< The input datasettype
139  const te::da::ObjectIdSet* m_oidSet; //!< The input objectid set
140 
141  double m_distance; //!< The fixed distance
142  int m_bufferPolygonRule; //!< The buffer polygon rule (INSIDE_OUTSIDE = 0, ONLY_OUTSIDE = 1, ONLY_INSIDE = 2).
143  int m_bufferBoundariesRule; //!< The buffer boundary rule (DISSOLVE = 0 and NOT_DISSOLVE = 1).
144  bool m_copyInputColumns; //!< Copy columns from input DataSet.
145  int m_levels; //!< The number of levels buffer will have.
146  int m_attributePosition; //!< The buffer can be calculated by attribute values. The attribute must be numeric type.
147 
148  te::da::DataSourcePtr m_outDsrc; //!< The output datasource.
149  std::string m_outDsetName; //!< The output dataset name.
150  };
151  }
152 }
153 #endif // __TERRALIB_VP_INTERNAL_BUFFER_OP_H
#define TEVPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
double m_distance
The fixed distance.
Definition: BufferOp.h:141
std::auto_ptr< te::da::DataSetTypeConverter > m_converter
The input datasettype.
Definition: BufferOp.h:138
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1438
An abstract class to compute the buffer memory and buffer query operation.
Definition: BufferOp.h:61
A class that models the description of a dataset.
Definition: DataSetType.h:72
const te::da::ObjectIdSet * m_oidSet
The input objectid set.
Definition: BufferOp.h:139
virtual ~BufferOp()
Virtual destructor.
Definition: BufferOp.h:69
std::string m_outDsetName
The output dataset name.
Definition: BufferOp.h:149
int m_bufferPolygonRule
The buffer polygon rule (INSIDE_OUTSIDE = 0, ONLY_OUTSIDE = 1, ONLY_INSIDE = 2).
Definition: BufferOp.h:142
int m_levels
The number of levels buffer will have.
Definition: BufferOp.h:145
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
int m_bufferBoundariesRule
The buffer boundary rule (DISSOLVE = 0 and NOT_DISSOLVE = 1).
Definition: BufferOp.h:143
URI C++ Library.
Enumerations related to Vector Processing module.
TEDATAACCESSEXPORT DataSetType * GetDataSetType(const std::string &name, const std::string &datasourceId)
int m_attributePosition
The buffer can be calculated by attribute values. The attribute must be numeric type.
Definition: BufferOp.h:146
bool m_copyInputColumns
Copy columns from input DataSet.
Definition: BufferOp.h:144
Configuration flags for the Terrralib Vector Processing module.
te::da::DataSourcePtr m_inDsrc
The input datasource.
Definition: BufferOp.h:136
te::da::DataSourcePtr m_outDsrc
The output datasource.
Definition: BufferOp.h:148
std::string m_inDsetName
The input dataset name.
Definition: BufferOp.h:137