Incorrect indices computation in SARDEMProjection
Indices for the H band, or the SatPos band are incorrectly computed.
The problem is that these numbers are computed incrementally, in a function (GenerateOutputInformation
) that is called several times.
An easy fix is the following
diff --git i/include/otbSARDEMProjectionImageFilter.txx w/include/otbSARDEMProjectionImageFilter.txx
index aadb403..9567a9a 100644
--- i/include/otbSARDEMProjectionImageFilter.txx
+++ w/include/otbSARDEMProjectionImageFilter.txx
@@ -152,22 +153,20 @@ SARDEMProjectionImageFilter< TImageIn, TImageOut >
if (m_withXYZ)
{
m_NbComponents += 3;
- m_indH += 3;
- m_indSatPos += 3;
-
inputKwl.AddKey("support_data.band.XCart", std::to_string(4));
inputKwl.AddKey("support_data.band.YCart", std::to_string(5));
inputKwl.AddKey("support_data.band.ZCart", std::to_string(6));
}
if (m_withH)
{
+ m_indH = m_NbComponents;
m_NbComponents += 1;
- m_indSatPos += 1;
inputKwl.AddKey("support_data.band.H", std::to_string(m_indH));
}
if (m_withSatPos)
{
+ m_indSatPos = m_NbComponents;
m_NbComponents += 3;
inputKwl.AddKey("support_data.band.XSatPos", std::to_string(m_indSatPos));
@@ -258,6 +257,8 @@ SARDEMProjectionImageFilter< TImageIn, TImageOut >
Point3DType satPos;
Point3DType satVel;
+ assert(m_NbComponents ==
+ 4 + (m_withXYZ ? 3 : 0) + (m_withH ? 1 : 0) + (m_withSatPos ? 3 : 0));
ImageOutPixelType pixelOutput;
pixelOutput.Reserve(m_NbComponents);
@@ -310,17 +312,20 @@ SARDEMProjectionImageFilter< TImageIn, TImageOut >
if (m_withXYZ)
{
SarSensorModelAdapter::WorldToCartesian(demGeoPoint, xyzCart);
+ assert(pixelOutput.Size() >= 6);
pixelOutput[4] = xyzCart[0];
pixelOutput[5] = xyzCart[1];
pixelOutput[6] = xyzCart[2];
}
if (m_withH)
{
+ assert(pixelOutput.Size() > m_indH);
pixelOutput[m_indH] = demGeoPoint[2];
}
if (m_withSatPos)
{
m_SarSensorModelAdapter->WorldToSatPositionAndVelocity(demGeoPoint, satPos, satVel);
+ assert(pixelOutput.Size() >= m_indSatPos + 3);
pixelOutput[m_indSatPos] = satPos[0];
pixelOutput[m_indSatPos+1] = satPos[1];
pixelOutput[m_indSatPos+2] = satPos[2];
PS: it would be nice to be able to completely select what we want to produce, and for instance, ignore the first 4 bands when we don't need them.
PPS: delete nulltpr;
is valid.