From ad38ca26330df583abd33a85e339e8b57bac03d7 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 30 Jan 2018 14:56:08 +0100 Subject: [PATCH] ENH: Expose new methods in SarSensorModelAdapter --- .../include/otbSarSensorModelAdapter.h | 12 +++++ .../src/otbSarSensorModelAdapter.cxx | 52 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h index 692c1574fc..33939b1610 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h @@ -24,6 +24,7 @@ #include <memory> #include "otbDEMHandler.h" +#include "itkPoint.h" namespace ossimplugins { @@ -62,6 +63,9 @@ public: typedef std::auto_ptr<ossimplugins::ossimSarSensorModel> InternalModelPointer; + using Point2DType = itk::Point<double,2>; + using Point3DType = itk::Point<double,3>; + /** Method for creation through the object factory. */ itkNewMacro(Self); @@ -80,6 +84,14 @@ public: /** Deburst metadata if possible and return lines to keep in image file */ bool Deburst(std::vector<std::pair<unsigned long, unsigned long> > & lines); + /** Transform world point (lat,lon,hgt) to input image point + (col,row) and YZ frame */ + bool WorldToLineSampleYZ(const Point3DType & inGeoPoint, Point2DType & cr, Point2DType yz) const; + + /** Transform world point (lat,lon,hgt) to input image point + (col,row) */ + bool WorldToLineSample(const Point3DType & inGEoPOint, Point2DType & cr) const; + static bool ImageLineToDeburstLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long imageLine, unsigned long & deburstLine); static void DeburstLineToImageLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long deburstLine, unsigned long & imageLine); diff --git a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx index 62d5203af5..d81fbc2b16 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx @@ -109,6 +109,58 @@ void SarSensorModelAdapter::DeburstLineToImageLine(const std::vector<std::pair<u ossimplugins::ossimSarSensorModel::deburstLineToImageLine(lines,deburstLine,imageLine); } +bool SarSensorModelAdapter::WorldToLineSampleYZ(const Point3DType & inGeoPoint, Point2DType & cr, Point2DType yz) const +{ + if(m_SensorModel.get() == ITK_NULLPTR) + { + return false; + } + + ossimGpt inGpt; + inGpt.lat = inGeoPoint[0]; + inGpt.lon = inGeoPoint[1]; + inGpt.hgt = inGeoPoint[2]; + + ossimDpt outDpt; + + double y(0.),z(0.); + m_SensorModel->worldToLineSampleYZ(inGpt,outDpt,y,z); + + if(outDpt.isNan()) + return false; + + cr[0]=outDpt.x; + cr[1]=outDpt.y; + yz[0]=y; + yz[1]=z; + + return true; +} + +bool SarSensorModelAdapter::WorldToLineSample(const Point3DType & inGeoPoint, Point2DType & cr) const +{ + if(m_SensorModel.get() == ITK_NULLPTR) + { + return false; + } + + ossimGpt inGpt; + inGpt.lat = inGeoPoint[0]; + inGpt.lon = inGeoPoint[1]; + inGpt.hgt = inGeoPoint[2]; + + ossimDpt outDpt; + + m_SensorModel->worldToLineSample(inGpt,outDpt); + + if(outDpt.isNan()) + return false; + + cr[0]=outDpt.x; + cr[1]=outDpt.y; + + return true; +} -- GitLab