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

BUG: don't use DEM height in RPC transform when the altitude is provided by the user

parent c1f2bc01
......@@ -42,10 +42,12 @@ bool RPCTransformBase<TScalarType, NInputDimensions, NOutputDimensions>::SetMeta
{
return false;
}
constexpr bool useDEM = NInputDimensions == 2 ? true : false;
this->m_Transformer = std::make_unique<GDALRPCTransformer>(
m_RPCParam->LineOffset, m_RPCParam->SampleOffset, m_RPCParam->LatOffset, m_RPCParam->LonOffset, m_RPCParam->HeightOffset,
m_RPCParam->LineScale, m_RPCParam->SampleScale, m_RPCParam->LatScale, m_RPCParam->LonScale, m_RPCParam->HeightScale,
m_RPCParam->LineNum, m_RPCParam->LineDen, m_RPCParam->SampleNum, m_RPCParam->SampleDen);
m_RPCParam->LineNum, m_RPCParam->LineDen, m_RPCParam->SampleNum, m_RPCParam->SampleDen, useDEM);
return true;
}
......
......@@ -65,7 +65,7 @@ public:
*/
GDALRPCTransformer(double LineOffset, double SampleOffset, double LatOffset, double LonOffset, double HeightOffset,
double LineScale, double SampleScale, double LatScale, double LonScale, double HeightScale,
const double (&LineNum)[20], const double (&LineDen)[20], const double (&SampleNum)[20], const double (&SampleDen)[20]);
const double (&LineNum)[20], const double (&LineDen)[20], const double (&SampleNum)[20], const double (&SampleDen)[20], bool useDEM);
~GDALRPCTransformer();
/**
......@@ -223,6 +223,9 @@ private:
/** Lock threads when instantiating the GDAL RPC transformer */
std::mutex m_Mutex;
/** Use the DEM singleton in DEM computations */
bool m_UseDEM = true;
};
}
#endif
......@@ -27,7 +27,9 @@ namespace otb
{
GDALRPCTransformer::GDALRPCTransformer(double LineOffset, double SampleOffset, double LatOffset, double LonOffset, double HeightOffset,
double LineScale, double SampleScale, double LatScale, double LonScale, double HeightScale,
const double (&LineNum)[20], const double (&LineDen)[20], const double (&SampleNum)[20], const double (&SampleDen)[20])
const double (&LineNum)[20], const double (&LineDen)[20], const double (&SampleNum)[20], const double (&SampleDen)[20],
bool useDEM)
: m_UseDEM(useDEM)
{
// Offsets
this->m_GDALRPCInfo.dfLINE_OFF = LineOffset;
......@@ -87,22 +89,26 @@ void GDALRPCTransformer::Update()
const std::lock_guard<std::mutex> lock(m_Mutex);
auto & demHandler = otb::DEMHandler::GetInstance();
if (demHandler.GetDEMCount() > 0)
if (m_UseDEM)
{
if (demHandler.GetGeoidFile().empty())
if (demHandler.GetDEMCount() > 0)
{
this->SetOption("RPC_DEM", demHandler.DEM_DATASET_PATH);
if (demHandler.GetGeoidFile().empty())
{
this->SetOption("RPC_DEM", demHandler.DEM_DATASET_PATH);
}
else
{
this->SetOption("RPC_DEM", demHandler.DEM_SHIFTED_DATASET_PATH);
}
this->SetOption("RPC_DEM_MISSING_VALUE", std::to_string(demHandler.GetDefaultHeightAboveEllipsoid()));
}
else
{
this->SetOption("RPC_DEM", demHandler.DEM_SHIFTED_DATASET_PATH);
// RPC height is used as a constant height offset applied to all points in case no DEM is set.
this->SetOption("RPC_HEIGHT", std::to_string(demHandler.GetDefaultHeightAboveEllipsoid()));
}
this->SetOption("RPC_DEM_MISSING_VALUE", std::to_string(demHandler.GetDefaultHeightAboveEllipsoid()));
}
else
{
// RPC height is used as a constant height offset applied to all points in case no DEM is set.
this->SetOption("RPC_HEIGHT", std::to_string(demHandler.GetDefaultHeightAboveEllipsoid()));
}
if(m_TransformArg != nullptr)
......
......@@ -61,7 +61,7 @@ int otbGDALRPCTransformerTest(int itkNotUsed(argc), char* argv[])
otb::GDALRPCTransformer transformer(LineOffset, SampleOffset, LatOffset, LonOffset, HeightOffset,
LineScale, SampleScale, LatScale, LonScale, HeightScale,
line_num_coeff, line_den_coeff, samp_num_coeff, samp_den_coeff);
line_num_coeff, line_den_coeff, samp_num_coeff, samp_den_coeff, true);
// Test ForwardTransform
std::vector<double> x = {20.5, 20.5};
......
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