OTB  9.0.0
Orfeo Toolbox
otbDataNode.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbDataNode_h
22 #define otbDataNode_h
23 
24 #include "itkPoint.h"
25 #include "otbPolygon.h"
26 #include "otbObjectList.h"
28 
29 
30 #include "ogrsf_frmts.h"
31 #include <string>
32 
33 namespace otb
34 {
39 typedef enum {
40  ROOT = 0,
41  DOCUMENT = 1,
42  FOLDER = 2,
50 } NodeType;
51 
72 template <class TPrecision = double, unsigned VDimension = 2, class TValuePrecision = double>
73 class DataNode : public itk::Object
74 {
75 public:
77  typedef DataNode Self;
78  typedef itk::Object Superclass;
79  typedef itk::SmartPointer<Self> Pointer;
80  typedef itk::SmartPointer<const Self> ConstPointer;
81 
83  itkNewMacro(Self);
84  itkTypeMacro(DataNode, Object);
86 
88  typedef TPrecision PrecisionType;
89  typedef TValuePrecision ValuePrecisionType;
90  itkStaticConstMacro(Dimension, unsigned int, VDimension);
91 
93  typedef itk::Point<PrecisionType, VDimension> PointType;
99  typedef typename VertexListType::ConstPointer VertexListConstPointerType;
105 
107  // typedef std::map<std::string, std::string> FieldMapType;
108  // typedef std::pair<std::string, std::string> FieldType;
109 
111  itkGetConstMacro(NodeType, NodeType);
112  itkGetStringMacro(NodeId);
113  itkSetStringMacro(NodeId);
115 
120  void SetNodeType(NodeType type);
121 
125  std::string GetNodeTypeAsString() const;
126 
131  PointType GetPoint() const;
132 
137  LinePointerType GetLine() const;
138 
144 
150 
155  void SetPoint(PointType point);
156 
161  void SetLine(LineType* line);
162 
167  void SetPolygonExteriorRing(PolygonType* polygon);
168 
173  void SetPolygonInteriorRings(PolygonListType* polygonList);
174 
178  bool IsDocument() const;
179 
183  bool IsRoot() const;
184 
188  bool IsFolder() const;
189 
193  bool IsPointFeature() const;
194 
198  bool IsLineFeature() const;
199 
203  bool IsPolygonFeature() const;
204 
208  bool IsMultiPointFeature() const;
209 
213  bool IsMultiLineFeature() const;
214 
218  bool IsMultiPolygonFeature() const;
219 
223  bool IsCollectionFeature() const;
224 
230  void SetFieldAsString(const std::string& key, const std::string& value);
231 
237  std::string GetFieldAsString(const std::string& key) const;
238 
244  void SetFieldAsInt(const std::string& key, int value);
245 
251  int GetFieldAsInt(const std::string& key) const;
252 
258  void SetFieldAsDouble(const std::string& key, double value);
259 
265  double GetFieldAsDouble(const std::string& key) const;
266 
271  // void RemoveField(const std::string& key);
272 
277  bool HasField(const std::string& key) const;
278 
283  void CopyFieldList(const DataNode* dataNode);
284 
288  std::vector<std::string> GetFieldList() const;
289 
291  double EuclideanDistanceMetric(const DataNode* node);
292 
293  double EuclideanDistanceMetric(const PointType point);
294 
298  bool Intersects(const DataNode* node);
299 
303  bool Within(const DataNode* node);
304 
308  // void ClearFields();
309 
310 protected:
312  DataNode();
313 
315  ~DataNode() override
316  {
317  }
318 
320  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
321 
322  OGRGeometry* ConvertDataNodeToOGRGeometry(const DataNode* dataNode);
323 
324 private:
325  DataNode(const Self&) = delete;
326  void operator=(const Self&) = delete;
327 
329  typedef struct
330  {
331  bool valid;
336  } DataType;
337 
340 
342  std::string m_NodeId;
343 
346 
348  // FieldMapType m_FieldMap;
349 };
350 } // end namespace
351 
352 #ifndef OTB_MANUAL_INSTANTIATION
353 #include "otbDataNode.hxx"
354 #endif
355 
356 #endif
otb::FEATURE_POINT
@ FEATURE_POINT
Definition: otbDataNode.h:43
otb::DataNode::SetFieldAsInt
void SetFieldAsInt(const std::string &key, int value)
Definition: otbDataNode.hxx:231
otb::DataNode::Dimension
static const unsigned int Dimension
Definition: otbDataNode.h:90
otb::DataNode::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbDataNode.h:79
otb::DataNode::DataNode
DataNode()
Definition: otbDataNode.hxx:30
otb::DataNode::GetPolygonExteriorRing
PolygonPointerType GetPolygonExteriorRing() const
Definition: otbDataNode.hxx:111
otb::DataNode::GetFieldAsDouble
double GetFieldAsDouble(const std::string &key) const
Definition: otbDataNode.hxx:250
otb::DataNode::ValuePrecisionType
TValuePrecision ValuePrecisionType
Definition: otbDataNode.h:89
otb::DataNode::DataType::exteriorRing
PolygonPointerType exteriorRing
Definition: otbDataNode.h:334
otb::DataNode::PolygonType
Polygon< ValuePrecisionType > PolygonType
Definition: otbDataNode.h:97
otb::DataNode::IsMultiPointFeature
bool IsMultiPointFeature() const
Definition: otbDataNode.hxx:428
otb::DataNode::DataType
Definition: otbDataNode.h:329
otbPolygon.h
otb::FEATURE_MULTIPOLYGON
@ FEATURE_MULTIPOLYGON
Definition: otbDataNode.h:48
otb::DataNode::GetNodeTypeAsString
std::string GetNodeTypeAsString() const
Definition: otbDataNode.hxx:146
otb::DataNode::PointType
itk::Point< PrecisionType, VDimension > PointType
Definition: otbDataNode.h:93
otb::DOCUMENT
@ DOCUMENT
Definition: otbDataNode.h:41
otb::DataNode::operator=
void operator=(const Self &)=delete
otb::DataNode::SetPoint
void SetPoint(PointType point)
Definition: otbDataNode.hxx:45
otb::DataNode::m_NodeType
NodeType m_NodeType
Definition: otbDataNode.h:339
otb::DataNode::Self
DataNode Self
Definition: otbDataNode.h:77
otb::DataNode::GetLine
LinePointerType GetLine() const
Definition: otbDataNode.hxx:97
otb::DataNode::IsRoot
bool IsRoot() const
Definition: otbDataNode.hxx:402
otb::DataNode
This class represents a node of data in a vector data hierarchy.
Definition: otbDataNode.h:73
otb::DataNode::IsMultiLineFeature
bool IsMultiLineFeature() const
Definition: otbDataNode.hxx:434
otb::DataNode::PolygonListConstPointerType
PolygonListType::ConstPointer PolygonListConstPointerType
Definition: otbDataNode.h:104
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::FEATURE_LINE
@ FEATURE_LINE
Definition: otbDataNode.h:44
otb::DataNode::GetFieldAsString
std::string GetFieldAsString(const std::string &key) const
Definition: otbDataNode.hxx:279
otb::DataNode::SetFieldAsString
void SetFieldAsString(const std::string &key, const std::string &value)
Definition: otbDataNode.hxx:222
otb::DataNode::DataType::interiorRings
PolygonListPointerType interiorRings
Definition: otbDataNode.h:335
otb::PolyLineParametricPathWithValue::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbPolyLineParametricPathWithValue.h:57
otb::DataNode::PolygonPointerType
PolygonType::Pointer PolygonPointerType
Definition: otbDataNode.h:100
otb::ObjectList::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbObjectList.h:46
otb::DataNode::PolygonConstPointerType
PolygonType::ConstPointer PolygonConstPointerType
Definition: otbDataNode.h:101
otb::DataNode::LinePointerType
LineType::Pointer LinePointerType
Definition: otbDataNode.h:95
otb::DataNode::IsCollectionFeature
bool IsCollectionFeature() const
Definition: otbDataNode.hxx:446
otb::FOLDER
@ FOLDER
Definition: otbDataNode.h:42
otb::DataNode::IsLineFeature
bool IsLineFeature() const
Definition: otbDataNode.hxx:417
otb::DataNode::LineConstPointerType
LineType::ConstPointer LineConstPointerType
Definition: otbDataNode.h:96
otb::DataNode::CopyFieldList
void CopyFieldList(const DataNode *dataNode)
Definition: otbDataNode.hxx:361
otb::DataNode::Within
bool Within(const DataNode *node)
Definition: otbDataNode.hxx:561
otb::DataNode::DataType::point
PointType point
Definition: otbDataNode.h:332
otb::DataNode::GetPoint
PointType GetPoint() const
Definition: otbDataNode.hxx:84
otb::DataNode::ConvertDataNodeToOGRGeometry
OGRGeometry * ConvertDataNodeToOGRGeometry(const DataNode *dataNode)
Definition: otbDataNode.hxx:453
otb::DataNode::Superclass
itk::Object Superclass
Definition: otbDataNode.h:78
otb::DataNode::IsPolygonFeature
bool IsPolygonFeature() const
Definition: otbDataNode.hxx:422
otb::DataNode::IsDocument
bool IsDocument() const
Definition: otbDataNode.hxx:397
otb::Polygon::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbPolygon.h:51
otb::DataNode::Intersects
bool Intersects(const DataNode *node)
Definition: otbDataNode.hxx:550
otb::DataNode::m_Data
DataType m_Data
Definition: otbDataNode.h:345
otb::NodeType
NodeType
Definition: otbDataNode.h:39
otb::DataNode::VertexListType
PolygonType::VertexListType VertexListType
Definition: otbDataNode.h:98
otb::DataNode::EuclideanDistanceMetric
double EuclideanDistanceMetric(const DataNode *node)
Definition: otbDataNode.hxx:524
otb::DataNode::GetFieldList
std::vector< std::string > GetFieldList() const
Definition: otbDataNode.hxx:375
otb::DataNode::~DataNode
~DataNode() override
Definition: otbDataNode.h:315
otb::DataNode::GetPolygonInteriorRings
PolygonListPointerType GetPolygonInteriorRings() const
Definition: otbDataNode.hxx:126
otb::DataNode::VertexListConstPointerType
VertexListType::ConstPointer VertexListConstPointerType
Definition: otbDataNode.h:99
otb::DataNode::PrecisionType
TPrecision PrecisionType
Definition: otbDataNode.h:84
otbObjectList.h
otb::DataNode::IsMultiPolygonFeature
bool IsMultiPolygonFeature() const
Definition: otbDataNode.hxx:440
otb::PolyLineParametricPathWithValue::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbPolyLineParametricPathWithValue.h:56
otb::DataNode::SetNodeType
void SetNodeType(NodeType type)
Definition: otbDataNode.hxx:38
otb::Polygon::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbPolygon.h:50
otb::FEATURE_POLYGON
@ FEATURE_POLYGON
Definition: otbDataNode.h:45
otb::PolyLineParametricPathWithValue
This class implement a PolyLineParametricPath for which a value can be set. The value is stored in th...
Definition: otbPolyLineParametricPathWithValue.h:50
otb::DataNode::GetFieldAsInt
int GetFieldAsInt(const std::string &key) const
Definition: otbDataNode.hxx:291
otb::DataNode::m_NodeId
std::string m_NodeId
Definition: otbDataNode.h:342
otb::DataNode::LineType
otb::PolyLineParametricPathWithValue< ValuePrecisionType, VDimension > LineType
Definition: otbDataNode.h:94
otb::DataNode::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbDataNode.hxx:140
otbVectorDataKeywordlist.h
otb::FEATURE_MULTIPOINT
@ FEATURE_MULTIPOINT
Definition: otbDataNode.h:46
otbDataNode.hxx
otb::DataNode::IsFolder
bool IsFolder() const
Definition: otbDataNode.hxx:407
otb::ObjectList::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbObjectList.h:47
otb::DataNode::IsPointFeature
bool IsPointFeature() const
Definition: otbDataNode.hxx:412
otb::DataNode::PolygonListPointerType
PolygonListType::Pointer PolygonListPointerType
Definition: otbDataNode.h:103
otb::DataNode::SetPolygonExteriorRing
void SetPolygonExteriorRing(PolygonType *polygon)
Definition: otbDataNode.hxx:60
otb::Polygon
This class represent a 2D polygon.
Definition: otbPolygon.h:44
otb::FEATURE_COLLECTION
@ FEATURE_COLLECTION
Definition: otbDataNode.h:49
otb::DataNode::SetLine
void SetLine(LineType *line)
Definition: otbDataNode.hxx:53
otb::FEATURE_MULTILINE
@ FEATURE_MULTILINE
Definition: otbDataNode.h:47
otb::ROOT
@ ROOT
Definition: otbDataNode.h:40
otb::ObjectList
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >.
Definition: otbObjectList.h:40
otb::DataNode::DataType::valid
bool valid
Definition: otbDataNode.h:331
otb::Polygon::VertexListType
Superclass::VertexListType VertexListType
Definition: otbPolygon.h:62
otb::DataNode::SetFieldAsDouble
void SetFieldAsDouble(const std::string &key, double value)
Definition: otbDataNode.hxx:240
otb::DataNode::HasField
bool HasField(const std::string &key) const
Definition: otbDataNode.hxx:321
otb::DataNode::PolygonListType
ObjectList< PolygonType > PolygonListType
Definition: otbDataNode.h:102
otb::DataNode::DataType::line
LinePointerType line
Definition: otbDataNode.h:333
otb::DataNode::SetPolygonInteriorRings
void SetPolygonInteriorRings(PolygonListType *polygonList)
Definition: otbDataNode.hxx:72
otb::DataNode::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbDataNode.h:80