18 #ifndef __otbDataNode_txx
19 #define __otbDataNode_txx
27 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
36 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
45 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
55 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
63 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
69 m_Data.exteriorRing = polygon;
70 if (!m_Data.interiorRings)
72 m_Data.interiorRings = PolygonListType::New();
77 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
83 m_Data.interiorRings = polygonList;
84 if (!m_Data.exteriorRing)
86 m_Data.exteriorRing = PolygonType::New();
91 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
97 if (!IsPointFeature())
99 itkGenericExceptionMacro(<<
"Node " << m_NodeId <<
" is not a point.");
103 itkGenericExceptionMacro(<<
"Invalid point node.");
107 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
113 if (!IsLineFeature())
115 itkGenericExceptionMacro(<<
"Node " << m_NodeId <<
" is not a line.");
119 itkGenericExceptionMacro(<<
"Invalid line node.");
124 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
130 if (!IsPolygonFeature())
132 itkGenericExceptionMacro(<<
"Node " << m_NodeId <<
" is not a polygon.");
134 if (!m_Data.valid || !m_Data.exteriorRing)
136 itkGenericExceptionMacro(<<
"Invalid polygon node.");
138 return m_Data.exteriorRing;
141 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
143 ::PolygonListPointerType
147 if (!IsPolygonFeature())
149 itkGenericExceptionMacro(<<
"Node " << m_NodeId <<
" is not a polygon.");
151 if (!m_Data.valid || !m_Data.interiorRings)
153 itkGenericExceptionMacro(<<
"Invalid polygon node.");
155 return m_Data.interiorRings;
158 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
163 os << indent << this->GetNodeTypeAsString();
166 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
171 std::ostringstream oss;
176 oss <<
"Root (" << m_NodeId <<
")";
181 oss <<
"Document (" << m_NodeId <<
")";
186 oss <<
"Folder (" << m_NodeId <<
")";
191 oss <<
"Point (" << m_NodeId <<
") " << m_Data.point;
196 oss <<
"Line (" << m_NodeId <<
") " << m_Data.line->GetVertexList()->Size() <<
" points";
201 oss <<
"Polygon (" << m_NodeId <<
") " << this->GetPolygonExteriorRing()->GetVertexList()->Size() <<
203 this->GetPolygonInteriorRings()->Size() <<
" interior rings";
208 oss <<
"MultiPoint (" << m_NodeId <<
")";
213 oss <<
"MultiLine (" << m_NodeId <<
")";
218 oss <<
"MultiPolygon (" << m_NodeId <<
")";
223 oss <<
"Collection (" << m_NodeId <<
")";
231 oss <<
"\n -> Metadata: " << kwl;
245 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
251 itk::ExposeMetaData<VectorDataKeywordlist>(this->GetMetaDataDictionary(),
255 itk::EncapsulateMetaData<VectorDataKeywordlist>(this->GetMetaDataDictionary(),
260 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
266 itk::ExposeMetaData<VectorDataKeywordlist>(this->GetMetaDataDictionary(),
270 itk::EncapsulateMetaData<VectorDataKeywordlist>(this->GetMetaDataDictionary(),
275 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
281 itk::ExposeMetaData<VectorDataKeywordlist>(this->GetMetaDataDictionary(),
286 itk::EncapsulateMetaData<VectorDataKeywordlist>(this->GetMetaDataDictionary(),
291 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
299 itk::ExposeMetaData<VectorDataKeywordlist>(this->GetMetaDataDictionary(),
323 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
331 itk::ExposeMetaData<VectorDataKeywordlist>(this->GetMetaDataDictionary(),
338 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
346 itk::ExposeMetaData<VectorDataKeywordlist>(this->GetMetaDataDictionary(),
371 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
379 itk::ExposeMetaData<VectorDataKeywordlist>(this->GetMetaDataDictionary(),
414 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
426 itk::ExposeMetaData<VectorDataKeywordlist>(this->GetMetaDataDictionary(),
431 itk::EncapsulateMetaData<VectorDataKeywordlist>(this->GetMetaDataDictionary(),
436 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
437 std::vector<std::string>
444 itk::ExposeMetaData<VectorDataKeywordlist>(this->GetMetaDataDictionary(),
448 std::vector<std::string> empty;
461 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
468 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
473 return m_NodeType ==
ROOT;
475 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
480 return m_NodeType ==
FOLDER;
482 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
489 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
496 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
504 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
512 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
520 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
528 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
537 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
546 OGRPoint *ogrPoint = (OGRPoint *) OGRGeometryFactory::createGeometry(wkbPoint);
547 ogrPoint->setX(dataNode->
GetPoint()[0]);
548 ogrPoint->setY(dataNode->
GetPoint()[1]);
555 OGRLineString * ogrLine = (OGRLineString *) OGRGeometryFactory::createGeometry(wkbLineString);
557 typename VertexListType::ConstIterator vIt = vertexList->Begin();
559 while (vIt != vertexList->End())
562 ogrPoint.setX(vIt.Value()[0]);
563 ogrPoint.setY(vIt.Value()[1]);
566 ogrPoint.setZ(vIt.Value()[2]);
568 ogrLine->addPoint(&ogrPoint);
576 OGRPolygon * polygon = (OGRPolygon *) OGRGeometryFactory::createGeometry(wkbPolygon);
577 OGRLinearRing * ogrExternalRing = (OGRLinearRing *) OGRGeometryFactory::createGeometry(wkbLinearRing);
581 typename VertexListType::ConstIterator vIt = vertexList->Begin();
583 while (vIt != vertexList->End())
586 ogrPoint.setX(vIt.Value()[0]);
587 ogrPoint.setY(vIt.Value()[1]);
590 ogrPoint.setZ(vIt.Value()[2]);
593 ogrExternalRing->addPoint(&ogrPoint);
596 polygon->addRing(ogrExternalRing);
598 polygon->closeRings();
599 OGRGeometryFactory::destroyGeometry(ogrExternalRing);
609 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
615 OGRGeometry * dstGeomtery = this->ConvertDataNodeToOGRGeometry(node);
616 OGRGeometry * currentGeometry = this->ConvertDataNodeToOGRGeometry(
this);
619 return currentGeometry->Distance(dstGeomtery);
622 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
628 OGRPoint ogrPointSrc;
629 ogrPointSrc.setX(point[0]);
630 ogrPointSrc.setY(point[1]);
633 OGRGeometry * currentGeometry = this->ConvertDataNodeToOGRGeometry(
this);
636 return currentGeometry->Distance(&ogrPointSrc);
639 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
645 OGRGeometry * dstGeomtery = this->ConvertDataNodeToOGRGeometry(node);
646 OGRGeometry * currentGeometry = this->ConvertDataNodeToOGRGeometry(
this);
649 return currentGeometry->Intersects(dstGeomtery);
652 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
658 OGRGeometry * dstGeomtery = this->ConvertDataNodeToOGRGeometry(node);
659 OGRGeometry * currentGeometry = this->ConvertDataNodeToOGRGeometry(
this);
662 return currentGeometry->Within(dstGeomtery);