21 #ifndef otbDataNode_hxx
22 #define otbDataNode_hxx
29 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
37 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
44 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
52 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
59 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
63 m_Data.exteriorRing = polygon;
64 if (!m_Data.interiorRings)
66 m_Data.interiorRings = PolygonListType::New();
71 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
75 m_Data.interiorRings = polygonList;
76 if (!m_Data.exteriorRing)
78 m_Data.exteriorRing = PolygonType::New();
83 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
86 if (!IsPointFeature())
88 itkGenericExceptionMacro(<<
"Node " << m_NodeId <<
" is not a point.");
92 itkGenericExceptionMacro(<<
"Invalid point node.");
96 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
101 itkGenericExceptionMacro(<<
"Node " << m_NodeId <<
" is not a line.");
105 itkGenericExceptionMacro(<<
"Invalid line node.");
110 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
113 if (!IsPolygonFeature())
115 itkGenericExceptionMacro(<<
"Node " << m_NodeId <<
" is not a polygon.");
117 if (!m_Data.valid || !m_Data.exteriorRing)
119 itkGenericExceptionMacro(<<
"Invalid polygon node.");
121 return m_Data.exteriorRing;
124 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
128 if (!IsPolygonFeature())
130 itkGenericExceptionMacro(<<
"Node " << m_NodeId <<
" is not a polygon.");
132 if (!m_Data.valid || !m_Data.interiorRings)
134 itkGenericExceptionMacro(<<
"Invalid polygon node.");
136 return m_Data.interiorRings;
139 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
142 os << indent << this->GetNodeTypeAsString();
145 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
148 std::ostringstream oss;
153 oss <<
"Root (" << m_NodeId <<
")";
158 oss <<
"Document (" << m_NodeId <<
")";
163 oss <<
"Folder (" << m_NodeId <<
")";
168 oss <<
"Point (" << m_NodeId <<
") " << m_Data.point;
173 oss <<
"Line (" << m_NodeId <<
") " << m_Data.line->GetVertexList()->Size() <<
" points";
178 oss <<
"Polygon (" << m_NodeId <<
") " << this->GetPolygonExteriorRing()->GetVertexList()->Size() <<
" points, " << this->GetPolygonInteriorRings()->Size()
179 <<
" interior rings";
184 oss <<
"MultiPoint (" << m_NodeId <<
")";
189 oss <<
"MultiLine (" << m_NodeId <<
")";
194 oss <<
"MultiPolygon (" << m_NodeId <<
")";
199 oss <<
"Collection (" << m_NodeId <<
")";
207 oss <<
"\n -> Metadata: " << kwl;
221 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
230 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
239 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
249 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
278 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
290 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
320 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
360 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
374 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
383 std::vector<std::string> empty;
396 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
401 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
404 return m_NodeType ==
ROOT;
406 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
409 return m_NodeType ==
FOLDER;
411 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
416 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
421 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
427 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
433 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
439 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
445 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
452 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
459 OGRPoint* ogrPoint = (OGRPoint*)OGRGeometryFactory::createGeometry(wkbPoint);
460 ogrPoint->setX(dataNode->
GetPoint()[0]);
461 ogrPoint->setY(dataNode->
GetPoint()[1]);
468 OGRLineString* ogrLine = (OGRLineString*)OGRGeometryFactory::createGeometry(wkbLineString);
470 typename VertexListType::ConstIterator vIt = vertexList->Begin();
472 while (vIt != vertexList->End())
475 ogrPoint.setX(vIt.Value()[0]);
476 ogrPoint.setY(vIt.Value()[1]);
479 ogrPoint.setZ(vIt.Value()[2]);
481 ogrLine->addPoint(&ogrPoint);
489 OGRPolygon* polygon = (OGRPolygon*)OGRGeometryFactory::createGeometry(wkbPolygon);
490 OGRLinearRing* ogrExternalRing = (OGRLinearRing*)OGRGeometryFactory::createGeometry(wkbLinearRing);
494 typename VertexListType::ConstIterator vIt = vertexList->Begin();
496 while (vIt != vertexList->End())
499 ogrPoint.setX(vIt.Value()[0]);
500 ogrPoint.setY(vIt.Value()[1]);
503 ogrPoint.setZ(vIt.Value()[2]);
506 ogrExternalRing->addPoint(&ogrPoint);
509 polygon->addRing(ogrExternalRing);
511 polygon->closeRings();
512 OGRGeometryFactory::destroyGeometry(ogrExternalRing);
523 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
527 OGRGeometry* dstGeomtery = this->ConvertDataNodeToOGRGeometry(node);
528 OGRGeometry* currentGeometry = this->ConvertDataNodeToOGRGeometry(
this);
531 return currentGeometry->Distance(dstGeomtery);
534 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
538 OGRPoint ogrPointSrc;
539 ogrPointSrc.setX(point[0]);
540 ogrPointSrc.setY(point[1]);
543 OGRGeometry* currentGeometry = this->ConvertDataNodeToOGRGeometry(
this);
546 return currentGeometry->Distance(&ogrPointSrc);
549 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
553 OGRGeometry* dstGeomtery = this->ConvertDataNodeToOGRGeometry(node);
554 OGRGeometry* currentGeometry = this->ConvertDataNodeToOGRGeometry(
this);
557 return currentGeometry->Intersects(dstGeomtery);
560 template <
class TPrecision,
unsigned int VDimension,
class TValuePrecision>
564 OGRGeometry* dstGeomtery = this->ConvertDataNodeToOGRGeometry(node);
565 OGRGeometry* currentGeometry = this->ConvertDataNodeToOGRGeometry(
this);
568 return currentGeometry->Within(dstGeomtery);