Commit d29183f7 authored by Cédric Traizet's avatar Cédric Traizet
Browse files

Merge branch 'optimize_sarmodel' into 'develop'

Optimize coordinate transformations in SARSensorModel

See merge request !858
parents de58687e d3b6a6f7
Pipeline #8866 passed with stages
in 29 minutes and 47 seconds
......@@ -23,6 +23,7 @@
#include "otbImageMetadata.h"
#include "otbSARMetadata.h"
#include "otbGeocentricTransform.h"
#include "itkPoint.h"
......@@ -191,6 +192,13 @@ private:
const Point2DType & imPt,
std::function<double(double, double)> heightFunction) const;
/** Coordinate transformation from ECEF to geographic */
itk::Point<double, 3> EcefToWorld(const itk::Point<double, 3> & ecefPoint) const;
/** Coordinate transformation from geographic to ECEF */
itk::Point<double, 3> WorldToEcef(const itk::Point<double, 3> & worldPoint) const;
std::string m_ProductType;
Projection::GCPParam m_GCP;
SARParam m_SarParam;
......@@ -206,6 +214,9 @@ private:
// True if the input product is a ground product
bool m_IsGrd;
otb::GeocentricTransform<otb::TransformDirection::INVERSE, double>::Pointer m_EcefToWorldTransform;
otb::GeocentricTransform<otb::TransformDirection::FORWARD, double>::Pointer m_WorldToEcefTransform;
};
}
......
......@@ -20,33 +20,17 @@
#include "otbSarSensorModel.h"
#include "otbGeocentricTransform.h"
#include "otbDEMHandler.h"
#include <numeric>
namespace otb
{
itk::Point<double, 3> EcefToWorld(const itk::Point<double, 3> & ecefPoint)
{
auto transform = otb::GeocentricTransform<otb::TransformDirection::INVERSE, double>::New();
return transform->TransformPoint(ecefPoint);
}
itk::Point<double, 3> WorldToEcef(const itk::Point<double, 3> & worldPoint)
{
auto transform = otb::GeocentricTransform<otb::TransformDirection::FORWARD, double>::New();
return transform->TransformPoint(worldPoint);
}
double DotProduct(const itk::Point<double, 3> & pt1, const itk::Point<double, 3> & pt2)
{
return std::inner_product(pt1.Begin(), pt1.End(), pt2.Begin(), 0.);
}
SarSensorModel::SarSensorModel( const std::string & productType,
const SARParam & sarParam,
const Projection::GCPParam & gcps)
......@@ -54,12 +38,16 @@ SarSensorModel::SarSensorModel( const std::string & productType,
m_GCP(gcps),
m_SarParam(sarParam),
m_AzimuthTimeOffset(MetaData::seconds(0)),
m_RangeTimeOffset(0.)
m_RangeTimeOffset(0.),
m_EcefToWorldTransform(otb::GeocentricTransform<otb::TransformDirection::INVERSE, double>::New()),
m_WorldToEcefTransform(otb::GeocentricTransform<otb::TransformDirection::FORWARD, double>::New())
{
OptimizeTimeOffsetsFromGcps();
const std::vector<std::string> grdProductTypes = {"GRD", "MGD", "GEC", "EEC"};
m_IsGrd = std::find(grdProductTypes.begin(), grdProductTypes.end(), m_ProductType) != grdProductTypes.end();
}
SarSensorModel::SarSensorModel(const ImageMetadata & imd)
......@@ -1164,4 +1152,14 @@ void SarSensorModel::DeburstLineToImageLine(const std::vector<std::pair<unsigned
imageLine += lineOffset;
}
itk::Point<double, 3> SarSensorModel::EcefToWorld(const itk::Point<double, 3> & ecefPoint) const
{
return m_EcefToWorldTransform->TransformPoint(ecefPoint);
}
itk::Point<double, 3> SarSensorModel::WorldToEcef(const itk::Point<double, 3> & worldPoint) const
{
return m_WorldToEcefTransform->TransformPoint(worldPoint);
}
} //namespace otb
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment