OTB  5.0.0
Orfeo Toolbox
otbDataNode.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbDataNode_h
19 #define __otbDataNode_h
20 
21 #include "itkPoint.h"
22 #include "otbPolygon.h"
23 #include "otbObjectList.h"
25 
26 #include <iostream>
27 
28 #include "ogrsf_frmts.h"
29 
30 namespace otb
31 {
36 typedef
37 enum
38  {
39  ROOT = 0,
40  DOCUMENT = 1,
41  FOLDER = 2,
49  } NodeType;
50 
71 template <class TPrecision = double, unsigned VDimension = 2, class TValuePrecision = double>
72 class DataNode
73  : public itk::Object
74 {
75 public:
77  typedef DataNode Self;
81 
83  itkNewMacro(Self);
84  itkTypeMacro(DataNode, Object);
86 
88  typedef TPrecision PrecisionType;
89  typedef TValuePrecision ValuePrecisionType;
90  itkStaticConstMacro(Dimension, unsigned int, VDimension);
91 
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  virtual ~DataNode() {}
316 
318  void PrintSelf(std::ostream& os, itk::Indent indent) const;
319 
320  OGRGeometry* ConvertDataNodeToOGRGeometry(const DataNode* dataNode);
321 
322 private:
323  DataNode(const Self&); //purposely not implemented
324  void operator =(const Self&); //purposely not implemented
325 
327  typedef struct
328  {
329  bool valid;
334  } DataType;
335 
338 
340  std::string m_NodeId;
341 
344 
346 // FieldMapType m_FieldMap;
347 };
348 } // end namespace
349 
350 #ifndef OTB_MANUAL_INSTANTIATION
351 #include "otbDataNode.txx"
352 #endif
353 
354 #endif
bool IsMultiPointFeature() const
Polygon< ValuePrecisionType > PolygonType
Definition: otbDataNode.h:97
bool IsPointFeature() const
PolygonListType::ConstPointer PolygonListConstPointerType
Definition: otbDataNode.h:104
PolygonType::ConstPointer PolygonConstPointerType
Definition: otbDataNode.h:101
std::string m_NodeId
Definition: otbDataNode.h:340
itk::SmartPointer< Self > Pointer
Definition: otbDataNode.h:79
bool Within(const DataNode *node)
bool IsLineFeature() const
void SetPolygonInteriorRings(PolygonListType *polygonList)
Definition: otbDataNode.txx:79
DataType m_Data
Definition: otbDataNode.h:343
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:36
This class represents a node of data in a vector data hierarchy.
Definition: otbDataNode.h:72
void SetPoint(PointType point)
Definition: otbDataNode.txx:47
This class represent a 2D polygon.
Definition: otbPolygon.h:41
std::string GetNodeTypeAsString() const
PolygonPointerType exteriorRing
Definition: otbDataNode.h:332
PolygonType::VertexListType VertexListType
Definition: otbDataNode.h:98
TPrecision PrecisionType
Definition: otbDataNode.h:84
VertexListType::ConstPointer VertexListConstPointerType
Definition: otbDataNode.h:99
LinePointerType GetLine() const
LinePointerType line
Definition: otbDataNode.h:331
std::vector< std::string > GetFieldList() const
PointType GetPoint() const
Definition: otbDataNode.txx:94
void PrintSelf(std::ostream &os, itk::Indent indent) const
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >...
Definition: otbObjectList.h:36
otb::PolyLineParametricPathWithValue< ValuePrecisionType, VDimension > LineType
Definition: otbDataNode.h:94
itk::SmartPointer< const Self > ConstPointer
Definition: otbDataNode.h:80
void SetFieldAsDouble(const std::string &key, double value)
bool Intersects(const DataNode *node)
void SetPolygonExteriorRing(PolygonType *polygon)
Definition: otbDataNode.txx:65
bool IsRoot() const
void SetNodeType(NodeType type)
Definition: otbDataNode.txx:38
DataNode Self
Definition: otbDataNode.h:77
virtual ~DataNode()
Definition: otbDataNode.h:315
bool IsMultiLineFeature() const
void SetLine(LineType *line)
Definition: otbDataNode.txx:56
ObjectList< PolygonType > PolygonListType
Definition: otbDataNode.h:102
LineType::ConstPointer LineConstPointerType
Definition: otbDataNode.h:96
PolygonListPointerType interiorRings
Definition: otbDataNode.h:333
Superclass::VertexListType VertexListType
Definition: otbPolygon.h:60
void SetFieldAsString(const std::string &key, const std::string &value)
LineType::Pointer LinePointerType
Definition: otbDataNode.h:95
PolygonType::Pointer PolygonPointerType
Definition: otbDataNode.h:100
std::string GetFieldAsString(const std::string &key) const
int GetFieldAsInt(const std::string &key) const
PolygonListType::Pointer PolygonListPointerType
Definition: otbDataNode.h:103
bool IsFolder() const
TValuePrecision ValuePrecisionType
Definition: otbDataNode.h:89
bool IsPolygonFeature() const
bool IsMultiPolygonFeature() const
PolygonListPointerType GetPolygonInteriorRings() const
itk::Object Superclass
Definition: otbDataNode.h:78
void SetFieldAsInt(const std::string &key, int value)
void operator=(const Self &)
bool IsDocument() const
static const unsigned int Dimension
Definition: otbDataNode.h:90
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:93
NodeType m_NodeType
Definition: otbDataNode.h:337