diff --git a/Code/Common/otbDataNode.h b/Code/Common/otbDataNode.h index 4efa6242f558d6015e5e7141472360d9234fa3f6..62fed30522521bbcde2fed373c2e690fe15d5c5b 100644 --- a/Code/Common/otbDataNode.h +++ b/Code/Common/otbDataNode.h @@ -266,6 +266,17 @@ public: double EuclideanDistance(const DataNode* node); double EuclideanDistance(const PointType point); + + /** + * \return true if the two datanodes intersects + */ + bool Intersects(const DataNode* node); + + /** + * \return true if the two datanodes intersects + */ + bool Within(const DataNode* node); + /** * Clear all fields. */ diff --git a/Code/Common/otbDataNode.txx b/Code/Common/otbDataNode.txx index 38b08d8b58045f6fadf462f07acdc2c63e84ac55..4e73c2fd1274f0f61cb28c68c4fc8a999cc4f860 100644 --- a/Code/Common/otbDataNode.txx +++ b/Code/Common/otbDataNode.txx @@ -636,6 +636,32 @@ DataNode<TPrecision, VDimension, TValuePrecision> return currentGeometry->Distance(&ogrPointSrc); } +template <class TPrecision, unsigned int VDimension, class TValuePrecision> +bool +DataNode<TPrecision, VDimension, TValuePrecision> +::Intersects(const DataNode* node) +{ + // Convert the nodes to OGRGeometries + OGRGeometry * dstGeomtery = this->ConvertDataNodeToOGRGeometry(node); + OGRGeometry * currentGeometry = this->ConvertDataNodeToOGRGeometry(this); + + // + return currentGeometry->Intersects(dstGeomtery); +} + +template <class TPrecision, unsigned int VDimension, class TValuePrecision> +bool +DataNode<TPrecision, VDimension, TValuePrecision> +::Within(const DataNode* node) +{ + // Convert the nodes to OGRGeometries + OGRGeometry * dstGeomtery = this->ConvertDataNodeToOGRGeometry(node); + OGRGeometry * currentGeometry = this->ConvertDataNodeToOGRGeometry(this); + + // + return currentGeometry->Within(dstGeomtery); +} + } // end namespace otb