Documentation for OpenFLUID 2.2.2
Loading...
Searching...
No Matches
GeoVectorValue.hpp
Go to the documentation of this file.
1/*
2
3 This file is part of OpenFLUID software
4 Copyright(c) 2021-2026, INRAE
5
6
7 == GNU General Public License Usage ==
8
9 OpenFLUID is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 OpenFLUID is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21
22
23 == Other Usage ==
24
25 Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26 license, and requires a written agreement between You and INRA.
27 Licensees for Other Usage of OpenFLUID may use this file in accordance
28 with the terms contained in the written agreement between You and INRA.
29
30*/
31
32
33/**
34 @file GeoVectorValue.hpp
35
36 @author Aline LIBRES <libres@supagro.inra.fr>
37 @author Jean-Christophe Fabre <jean-christophe.fabre@inra.fr>
38*/
39
40
41#ifndef __OPENFLUID_CORE_GEOVECTORVALUE_HPP__
42#define __OPENFLUID_CORE_GEOVECTORVALUE_HPP__
43
44
45#include <gdal_priv.h>
46#include <ogrsf_frmts.h>
47
51
52
53namespace openfluid { namespace core {
54
55
57{
58 protected:
59
60 /**
61 The vector data source associated to this GeoVectorValue.
62 */
63
65
66 /**
67 Open the data source of this GeoVectorValue.
68 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
69 */
70 void tryToOpenSource() override;
71
72 /**
73 Destroy the OGRDataSource.
74 */
76
77
78 public:
79
80 GeoVectorValue() = delete;
81
82 /**
83 Creates a new value.
84 For ESRI Shapefile, the <tt>FileName</tt> may be the name of a .shp, .shx or .dbf file,
85 or a path to a directory containing proper shape files.
86 It doesn't open the associated OGR datasource.
87 @param[in] FilePath The path of the file(s).
88 @param[in] FileName The name or the relative path of the file to open.
89 */
90 GeoVectorValue(const std::string& FilePath, const std::string& FileName);
91
92 /**
93 Destructor. Closes the open OGR datasource.
94 */
95 virtual ~GeoVectorValue();
96
97 /**
98 Returns the type of this GeoVectorValue.
99 */
101
102 /**
103 Gets the associated opened OGR datasource in read-only access.
104 If the datasource is not already opened, tries to open it first.
105 @return The opened OGR datasource.
106 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
107 */
109
110 /**
111 Gets a layer of the shape.
112 @param[in] LayerIndex The index of the asked layer, default 0.
113 @return The layer indexed LayerIndex.
114 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
115 */
116 OGRLayer* layer(unsigned int LayerIndex = 0);
117
118 /**
119 Gets the Feature definition of a layer.
120 @param[in] LayerIndex The index of the asked layer definition, default 0.
121 @return The OGR Feature definition of the LayerIndex layer.
122 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
123 */
124 OGRFeatureDefn* layerDef(unsigned int LayerIndex = 0);
125
126 /**
127 Returns the geometry type of the GeoVectorValue.
128 @param[in] LayerIndex The index of the layer to compare the type, default 0.
129 @return an OGRwkbGeometryType
130 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
131 */
132 OGRwkbGeometryType getGeometryType(unsigned int LayerIndex = 0);
133
134 /**
135 Returns true if the GeoVectorValue is line type, false otherwise.
136 @param[in] LayerIndex The index of the layer to compare the type, default 0.
137 @return True if the type of the layer LayerIndex is wkbLineString, false otherwise.
138 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
139 */
140 bool isLineType(unsigned int LayerIndex = 0);
141
142 /**
143 Returns true if the GeoVectorValue is polygon type, false otherwise.
144 @param[in] LayerIndex The index of the layer to compare the type, default 0.
145 @return True if the type of the layer LayerIndex is wkbPolygon, false otherwise.
146 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
147 */
148 bool isPolygonType(unsigned int LayerIndex = 0);
149
150 /**
151 Returns true if a field exists in the LayerIndex layer.
152 @param[in] FieldName The name of the field to query.
153 @param[in] LayerIndex The index of the layer to query, default 0.
154 @return True if the field FieldName exists, False otherwise.
155 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
156 */
157 bool containsField(const std::string& FieldName, unsigned int LayerIndex = 0);
158
159 /**
160 Gets the index of a field in the LayerIndex layer.
161 @param[in] LayerIndex The index of the layer to query, default 0.
162 @param[in] FieldName The name of the field to query.
163 @return The index of FieldName or -1 if field FieldName doesn't exist.
164 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
165 */
166 int getFieldIndex(const std::string& FieldName, unsigned int LayerIndex = 0);
167
168 /**
169 Returns true if a field is of the type FieldType in the LayerIndex layer.
170 @param[in] FieldName The name of the field to query.
171 @param[in] FieldType The type of the field to query.
172 @param[in] LayerIndex The index of the layer to query, default 0.
173 @return True if the field FieldName is type FieldType.
174 @throw openfluid::base::FrameworkException if the field doesn't exist.
175 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
176 */
177 bool isFieldOfType(const std::string& FieldName, OGRFieldType FieldType,
178 unsigned int LayerIndex = 0);
179
180 /**
181 Returns true if the GeoVectorValue is point type, false otherwise.
182 @param[in] LayerIndex The index of the layer to compare the type, default 0.
183 @return True if the type of the layer LayerIndex is wkbPoint, false otherwise.
184 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
185 */
186 bool isPointType(unsigned int LayerIndex = 0);
187
188 /**
189 Returns true if the GeoVectorValue is MultiPolygon type, false otherwise.
190 @param[in] LayerIndex The index of the layer to compare the type, default 0.
191 @return True if the type of the layer LayerIndex is wkbMultiPolygon, false otherwise.
192 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
193 */
194 bool isMultiPolygonType(unsigned int LayerIndex = 0);
195
196 /**
197 Returns true if the GeoVectorValue is MultiLine type, false otherwise.
198 @param[in] LayerIndex The index of the layer to compare the type, default 0.
199 @return True if the type of the layer LayerIndex is wkbMultiLineString, false otherwise.
200 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
201 */
202 bool isMultiLineType(unsigned int LayerIndex = 0);
203
204 /**
205 Returns true if the GeoVectorValue is MultiPoint type, false otherwise.
206 @param[in] LayerIndex The index of the layer to compare the type, default 0.
207 @return True if the type of the layer LayerIndex is wkbMultiPoint, false otherwise.
208 @throw openfluid::base::FrameworkException if OGR doesn't succeed to open the datasource.
209 */
210 bool isMultiPointType(unsigned int LayerIndex = 0);
211
212};
213
214
215} } // namespaces
216
217
218#endif /* __OPENFLUID_CORE_GEOVECTORVALUE_HPP__ */
#define GDALDataset_COMPAT
Definition GDALCompatibility.hpp:69
Definition GeoValue.hpp:56
Definition GeoVectorValue.hpp:57
OGRFeatureDefn * layerDef(unsigned int LayerIndex=0)
bool isPointType(unsigned int LayerIndex=0)
bool isMultiPointType(unsigned int LayerIndex=0)
GDALDataset_COMPAT * data()
bool isPolygonType(unsigned int LayerIndex=0)
int getFieldIndex(const std::string &FieldName, unsigned int LayerIndex=0)
bool containsField(const std::string &FieldName, unsigned int LayerIndex=0)
GeoVectorValue(const std::string &FilePath, const std::string &FileName)
bool isFieldOfType(const std::string &FieldName, OGRFieldType FieldType, unsigned int LayerIndex=0)
openfluid::core::UnstructuredValue::UnstructuredType getType() const override
OGRLayer * layer(unsigned int LayerIndex=0)
bool isLineType(unsigned int LayerIndex=0)
bool isMultiLineType(unsigned int LayerIndex=0)
OGRwkbGeometryType getGeometryType(unsigned int LayerIndex=0)
bool isMultiPolygonType(unsigned int LayerIndex=0)
GDALDataset_COMPAT * mp_Data
Definition GeoVectorValue.hpp:64
UnstructuredType
Definition UnstructuredValue.hpp:58
#define OPENFLUID_API
Definition dllexport.hpp:86
Definition ApplicationException.hpp:47