OTB  6.1.0
Orfeo Toolbox
otbDataNode.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2017 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 #include <iostream>
30 
31 #include "ogrsf_frmts.h"
32 
33 namespace otb
34 {
39 typedef
40 enum
41  {
42  ROOT = 0,
43  DOCUMENT = 1,
44  FOLDER = 2,
52  } NodeType;
53 
74 template <class TPrecision = double, unsigned VDimension = 2, class TValuePrecision = double>
75 class DataNode
76  : public itk::Object
77 {
78 public:
80  typedef DataNode Self;
84 
86  itkNewMacro(Self);
87  itkTypeMacro(DataNode, Object);
89 
91  typedef TPrecision PrecisionType;
92  typedef TValuePrecision ValuePrecisionType;
93  itkStaticConstMacro(Dimension, unsigned int, VDimension);
94 
102  typedef typename VertexListType::ConstPointer VertexListConstPointerType;
108 
110 // typedef std::map<std::string, std::string> FieldMapType;
111 // typedef std::pair<std::string, std::string> FieldType;
112 
114  itkGetConstMacro(NodeType, NodeType);
115  itkGetStringMacro(NodeId);
116  itkSetStringMacro(NodeId);
118 
123  void SetNodeType(NodeType type);
124 
128  std::string GetNodeTypeAsString() const;
129 
134  PointType GetPoint() const;
135 
140  LinePointerType GetLine() const;
141 
147 
153 
158  void SetPoint(PointType point);
159 
164  void SetLine(LineType* line);
165 
170  void SetPolygonExteriorRing(PolygonType* polygon);
171 
176  void SetPolygonInteriorRings(PolygonListType* polygonList);
177 
181  bool IsDocument() const;
182 
186  bool IsRoot() const;
187 
191  bool IsFolder() const;
192 
196  bool IsPointFeature() const;
197 
201  bool IsLineFeature() const;
202 
206  bool IsPolygonFeature() const;
207 
211  bool IsMultiPointFeature() const;
212 
216  bool IsMultiLineFeature() const;
217 
221  bool IsMultiPolygonFeature() const;
222 
226  bool IsCollectionFeature() const;
227 
233  void SetFieldAsString(const std::string& key, const std::string& value);
234 
240  std::string GetFieldAsString(const std::string& key) const;
241 
247  void SetFieldAsInt(const std::string& key, int value);
248 
254  int GetFieldAsInt(const std::string& key) const;
255 
261  void SetFieldAsDouble(const std::string& key, double value);
262 
268  double GetFieldAsDouble(const std::string& key) const;
269 
274  // void RemoveField(const std::string& key);
275 
280  bool HasField(const std::string& key) const;
281 
286  void CopyFieldList(const DataNode * dataNode);
287 
291  std::vector<std::string> GetFieldList() const;
292 
294  double EuclideanDistanceMetric(const DataNode* node);
295 
296  double EuclideanDistanceMetric(const PointType point);
297 
301  bool Intersects(const DataNode* node);
302 
306  bool Within(const DataNode* node);
307 
311 // void ClearFields();
312 
313 protected:
315  DataNode();
316 
318  ~DataNode() ITK_OVERRIDE {}
319 
321  void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
322 
323  OGRGeometry* ConvertDataNodeToOGRGeometry(const DataNode* dataNode);
324 
325 private:
326  DataNode(const Self&); //purposely not implemented
327  void operator =(const Self&); //purposely not implemented
328 
330  typedef struct
331  {
332  bool valid;
337  } DataType;
338 
341 
343  std::string m_NodeId;
344 
347 
349 // FieldMapType m_FieldMap;
350 };
351 } // end namespace
352 
353 #ifndef OTB_MANUAL_INSTANTIATION
354 #include "otbDataNode.txx"
355 #endif
356 
357 #endif
bool IsMultiPointFeature() const
Polygon< ValuePrecisionType > PolygonType
Definition: otbDataNode.h:100
bool IsPointFeature() const
PolygonListType::ConstPointer PolygonListConstPointerType
Definition: otbDataNode.h:107
PolygonType::ConstPointer PolygonConstPointerType
Definition: otbDataNode.h:104
std::string m_NodeId
Definition: otbDataNode.h:343
itk::SmartPointer< Self > Pointer
Definition: otbDataNode.h:82
bool Within(const DataNode *node)
bool IsLineFeature() const
void SetPolygonInteriorRings(PolygonListType *polygonList)
Definition: otbDataNode.txx:82
DataType m_Data
Definition: otbDataNode.h:346
double EuclideanDistanceMetric(const DataNode *node)
OGRGeometry * ConvertDataNodeToOGRGeometry(const DataNode *dataNode)
This class implement a PolyLineParametricPath for which a value can be set. The value is stored in th...
NodeType
Definition: otbDataNode.h:39
This class represents a node of data in a vector data hierarchy.
Definition: otbDataNode.h:75
void SetPoint(PointType point)
Definition: otbDataNode.txx:50
This class represent a 2D polygon.
Definition: otbPolygon.h:44
std::string GetNodeTypeAsString() const
PolygonPointerType exteriorRing
Definition: otbDataNode.h:335
PolygonType::VertexListType VertexListType
Definition: otbDataNode.h:101
TPrecision PrecisionType
Definition: otbDataNode.h:87
VertexListType::ConstPointer VertexListConstPointerType
Definition: otbDataNode.h:102
LinePointerType GetLine() const
LinePointerType line
Definition: otbDataNode.h:334
std::vector< std::string > GetFieldList() const
PointType GetPoint() const
Definition: otbDataNode.txx:97
void PrintSelf(std::ostream &os, itk::Indent indent) const ITK_OVERRIDE
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >...
Definition: otbObjectList.h:39
otb::PolyLineParametricPathWithValue< ValuePrecisionType, VDimension > LineType
Definition: otbDataNode.h:97
itk::SmartPointer< const Self > ConstPointer
Definition: otbDataNode.h:83
void SetFieldAsDouble(const std::string &key, double value)
bool Intersects(const DataNode *node)
void SetPolygonExteriorRing(PolygonType *polygon)
Definition: otbDataNode.txx:68
bool IsRoot() const
void SetNodeType(NodeType type)
Definition: otbDataNode.txx:41
~DataNode() ITK_OVERRIDE
Definition: otbDataNode.h:318
DataNode Self
Definition: otbDataNode.h:80
bool IsMultiLineFeature() const
void SetLine(LineType *line)
Definition: otbDataNode.txx:59
ObjectList< PolygonType > PolygonListType
Definition: otbDataNode.h:105
LineType::ConstPointer LineConstPointerType
Definition: otbDataNode.h:99
PolygonListPointerType interiorRings
Definition: otbDataNode.h:336
Superclass::VertexListType VertexListType
Definition: otbPolygon.h:63
void SetFieldAsString(const std::string &key, const std::string &value)
LineType::Pointer LinePointerType
Definition: otbDataNode.h:98
PolygonType::Pointer PolygonPointerType
Definition: otbDataNode.h:103
std::string GetFieldAsString(const std::string &key) const
int GetFieldAsInt(const std::string &key) const
PolygonListType::Pointer PolygonListPointerType
Definition: otbDataNode.h:106
bool IsFolder() const
TValuePrecision ValuePrecisionType
Definition: otbDataNode.h:92
bool IsPolygonFeature() const
bool IsMultiPolygonFeature() const
PolygonListPointerType GetPolygonInteriorRings() const
itk::Object Superclass
Definition: otbDataNode.h:81
void SetFieldAsInt(const std::string &key, int value)
void operator=(const Self &)
bool IsDocument() const
static const unsigned int Dimension
Definition: otbDataNode.h:93
double GetFieldAsDouble(const std::string &key) const
bool HasField(const std::string &key) const
bool IsCollectionFeature() const
void CopyFieldList(const DataNode *dataNode)
PolygonPointerType GetPolygonExteriorRing() const
itk::Point< PrecisionType, VDimension > PointType
Definition: otbDataNode.h:96
NodeType m_NodeType
Definition: otbDataNode.h:340