Orfeo ToolBox  4.2
Orfeo ToolBox is not a black box
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"
23 #include "otbPolygon.h"
24 #include "otbObjectList.h"
26 
27 #include <iostream>
28 
29 #include "ogrsf_frmts.h"
30 
31 namespace otb
32 {
37 typedef
38 enum
39  {
40  ROOT = 0,
41  DOCUMENT = 1,
42  FOLDER = 2,
50  } NodeType;
51 
70 template <class TPrecision = double, unsigned VDimension = 2, class TValuePrecision = double>
71 class DataNode
72  : public itk::Object
73 {
74 public:
76  typedef DataNode Self;
80 
82  itkNewMacro(Self);
83  itkTypeMacro(DataNode, Object);
84 
86  typedef TPrecision PrecisionType;
87  typedef TValuePrecision ValuePrecisionType;
88  itkStaticConstMacro(Dimension, unsigned int, VDimension);
89 
97  typedef typename VertexListType::ConstPointer VertexListConstPointerType;
103 
105 // typedef std::map<std::string, std::string> FieldMapType;
106 // typedef std::pair<std::string, std::string> FieldType;
107 
109  itkGetConstMacro(NodeType, NodeType);
110  itkGetStringMacro(NodeId);
111  itkSetStringMacro(NodeId);
112 
117  void SetNodeType(NodeType type);
121  std::string GetNodeTypeAsString() const;
126  PointType GetPoint() const;
131  LinePointerType GetLine() const;
146  void SetPoint(PointType point);
151  void SetLine(LineType* line);
156  void SetPolygonExteriorRing(PolygonType* polygon);
157 
162  void SetPolygonInteriorRings(PolygonListType* polygonList);
163 
167  bool IsDocument() const;
171  bool IsRoot() const;
175  bool IsFolder() const;
179  bool IsPointFeature() const;
183  bool IsLineFeature() const;
187  bool IsPolygonFeature() const;
191  bool IsMultiPointFeature() const;
195  bool IsMultiLineFeature() const;
199  bool IsMultiPolygonFeature() const;
203  bool IsCollectionFeature() const;
209  void SetFieldAsString(const std::string& key, const std::string& value);
215  std::string GetFieldAsString(const std::string& key) const;
216 
222  void SetFieldAsInt(const std::string& key, int value);
228  int GetFieldAsInt(const std::string& key) const;
229 
235  void SetFieldAsDouble(const std::string& key, double value);
241  double GetFieldAsDouble(const std::string& key) const;
242 
243  // /**
244  // * Remove the field associated with the given key, if possible.
245  // * \param key The name of the field.
246  // */
247  // void RemoveField(const std::string& key);
252  bool HasField(const std::string& key) const;
253 
258  void CopyFieldList(const DataNode * dataNode);
259 
263  std::vector<std::string> GetFieldList() const;
264 
266  double EuclideanDistanceMetric(const DataNode* node);
267 
268  double EuclideanDistanceMetric(const PointType point);
269 
273  bool Intersects(const DataNode* node);
274 
278  bool Within(const DataNode* node);
279 
283 // void ClearFields();
284 
285 protected:
287  DataNode();
289  virtual ~DataNode() {}
291  void PrintSelf(std::ostream& os, itk::Indent indent) const;
292 
293  OGRGeometry* ConvertDataNodeToOGRGeometry(const DataNode* dataNode);
294 
295 private:
296  DataNode(const Self&); //purposely not implemented
297  void operator =(const Self&); //purposely not implemented
298 
300  typedef struct
301  {
302  bool valid;
307  } DataType;
308 
311 
313  std::string m_NodeId;
314 
317 
319 // FieldMapType m_FieldMap;
320 };
321 } // end namespace
322 
323 #ifndef OTB_MANUAL_INSTANTIATION
324 #include "otbDataNode.txx"
325 #endif
326 
327 #endif
bool IsMultiPointFeature() const
Polygon< ValuePrecisionType > PolygonType
Definition: otbDataNode.h:95
bool IsPointFeature() const
PolygonListType::ConstPointer PolygonListConstPointerType
Definition: otbDataNode.h:102
PolygonType::ConstPointer PolygonConstPointerType
Definition: otbDataNode.h:99
std::string m_NodeId
Definition: otbDataNode.h:313
itk::SmartPointer< Self > Pointer
Definition: otbDataNode.h:78
bool Within(const DataNode *node)
bool IsLineFeature() const
void SetPolygonInteriorRings(PolygonListType *polygonList)
Definition: otbDataNode.txx:80
DataType m_Data
Definition: otbDataNode.h:316
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...
Object(const Self &)
NodeType
Definition: otbDataNode.h:37
This class represents a node of data in a vector data hierarchy.
Definition: otbDataNode.h:71
void SetPoint(PointType point)
Definition: otbDataNode.txx:48
This class represent a 2D polygon.
Definition: otbPolygon.h:39
std::string GetNodeTypeAsString() const
PolygonPointerType exteriorRing
Definition: otbDataNode.h:305
PolygonType::VertexListType VertexListType
Definition: otbDataNode.h:96
TPrecision PrecisionType
Definition: otbDataNode.h:83
VertexListType::ConstPointer VertexListConstPointerType
Definition: otbDataNode.h:97
LinePointerType GetLine() const
LinePointerType line
Definition: otbDataNode.h:304
std::vector< std::string > GetFieldList() const
PointType GetPoint() const
Definition: otbDataNode.txx:95
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:34
otb::PolyLineParametricPathWithValue< ValuePrecisionType, VDimension > LineType
Definition: otbDataNode.h:92
itk::SmartPointer< const Self > ConstPointer
Definition: otbDataNode.h:79
void SetFieldAsDouble(const std::string &key, double value)
bool Intersects(const DataNode *node)
void SetPolygonExteriorRing(PolygonType *polygon)
Definition: otbDataNode.txx:66
bool IsRoot() const
void SetNodeType(NodeType type)
Definition: otbDataNode.txx:39
DataNode Self
Definition: otbDataNode.h:76
virtual ~DataNode()
Definition: otbDataNode.h:289
bool IsMultiLineFeature() const
void SetLine(LineType *line)
Definition: otbDataNode.txx:57
ObjectList< PolygonType > PolygonListType
Definition: otbDataNode.h:100
LineType::ConstPointer LineConstPointerType
Definition: otbDataNode.h:94
PolygonListPointerType interiorRings
Definition: otbDataNode.h:306
Superclass::VertexListType VertexListType
Definition: otbPolygon.h:57
void SetFieldAsString(const std::string &key, const std::string &value)
LineType::Pointer LinePointerType
Definition: otbDataNode.h:93
PolygonType::Pointer PolygonPointerType
Definition: otbDataNode.h:98
std::string GetFieldAsString(const std::string &key) const
int GetFieldAsInt(const std::string &key) const
PolygonListType::Pointer PolygonListPointerType
Definition: otbDataNode.h:101
bool IsFolder() const
TValuePrecision ValuePrecisionType
Definition: otbDataNode.h:87
bool IsPolygonFeature() const
bool IsMultiPolygonFeature() const
PolygonListPointerType GetPolygonInteriorRings() const
itk::Object Superclass
Definition: otbDataNode.h:77
void SetFieldAsInt(const std::string &key, int value)
void operator=(const Self &)
bool IsDocument() const
static const unsigned int Dimension
Definition: otbDataNode.h:88
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:91
NodeType m_NodeType
Definition: otbDataNode.h:310