Commit eefbb7de authored by Julien Osman's avatar Julien Osman
Browse files

Merge branch '2275_sensor-model-missing' into 'develop'

2275 sensor model missing

Closes #2275

See merge request !914
parents 6a79318a 1b47b336
Pipeline #10909 passed with stages
in 88 minutes and 46 seconds
......@@ -98,6 +98,14 @@ otb_test_application(NAME apTvPrOrthorectification_UTM
${BASELINE}/owTvOrthorectifTest_UTM.tif
${TEMP}/apTvPrOrthorectifTest_UTM.tif)
otb_test_application(NAME apTvPrOrthorectification_OTB_Metadata
APP OrthoRectification
OPTIONS -io.in ${INPUTDATA}/QB_TOULOUSE_11_11.tif
-io.out ${TEMP}/apTvPrOrthorectification_OTB_Metadata.tif
VALID --compare-image ${EPSILON_4}
${BASELINE}/apTvPrOrthorectification_OTB_Metadata.tif
${TEMP}/apTvPrOrthorectification_OTB_Metadata.tif)
#otb_test_application(NAME apTvPrOrthorectification_DEMTIF_UTM_OutXML1
#APP OrthoRectification
#OPTIONS -io.in LARGEINPUT{QUICKBIRD/TOULOUSE/000000128955_01_P001_PAN/02APR01105228-P1BS-000000128955_01_P001.TIF}
......
......@@ -247,6 +247,8 @@ protected:
void KeywordlistToMetadata(ImageMetadataBase::Keywordlist, int band=-1);
/** Parses a GDAL Metadata string list to fill a Keywordlist*/
void GDALMetadataToKeywordlist(const char* const* , ImageMetadataBase::Keywordlist &);
/** Parses the RPC from the GDAL Metadata */
void GDALMetadataReadRPC();
void PrintSelf(std::ostream& os, itk::Indent indent) const override;
/** Read all information on the image*/
......
......@@ -874,7 +874,6 @@ void GDALImageIO::InternalReadImageInformation()
for (int cpt = 0; cpt < 6; ++cpt)
{
VadfGeoTransform.push_back(adfGeoTransform[cpt]);
//~ m_Imd.GeoTransform[cpt] = adfGeoTransform[cpt];
}
itk::EncapsulateMetaData<MetaDataKey::VectorType>(dict, MetaDataKey::GeoTransformKey, VadfGeoTransform);
......@@ -1288,7 +1287,6 @@ void GDALImageIO::WriteImageInformation()
void GDALImageIO::InternalWriteImageInformation(const void* buffer)
{
// char ** papszOptions = NULL;
std::string driverShortName;
m_NbBands = this->GetNumberOfComponents();
......@@ -1916,7 +1914,11 @@ void GDALImageIO::ImportMetadata()
ImageMetadataBase::Keywordlist kwl;
GDALMetadataToKeywordlist(m_Dataset->GetDataSet()->GetMetadata(), kwl);
// Decode SAR metadata
// Decode RPC model
if (m_Dataset->GetDataSet()->GetMetadata("RPC"))
GDALMetadataReadRPC();
// Decode SAR model
if (kwl.find("SAR") != kwl.end())
{
try
......@@ -1935,7 +1937,7 @@ void GDALImageIO::ImportMetadata()
}
}
// Decode SAR metadata
// Decode SAR calibration data
if (kwl.find("SARCalib") != kwl.end())
{
try
......@@ -2006,46 +2008,45 @@ void GDALImageIO::GDALMetadataToKeywordlist(const char* const* metadataList, Ima
if((fieldName.size() > 36) && (fieldName.substr(0, 36) == "MDGeomNames[MDGeom::SensorGeometry]."))
{
// Sensor Geometry is imported directly in the ImageMetadata.
// TODO: Keys Starting with: MDGeomNames[MDGeom::SensorGeometry] + '.' should
// be decoded by the (future) SensorModelFactory.
}
else if (fieldName == MetaData::MDGeomNames.left.at(MDGeom::RPC))
else
{
// RPC Models are imported directly in the ImageMetadata.
Projection::RPCParam rpcStruct;
rpcStruct.LineOffset = this->GetAs<double>("RPC/LINE_OFF");
rpcStruct.SampleOffset = this->GetAs<double>("RPC/SAMP_OFF");
rpcStruct.LatOffset = this->GetAs<double>("RPC/LAT_OFF");
rpcStruct.LonOffset = this->GetAs<double>("RPC/LONG_OFF");
rpcStruct.HeightOffset = this->GetAs<double>("RPC/HEIGHT_OFF");
kwl.emplace(fieldName, fieldValue);
}
}
}
void GDALImageIO::GDALMetadataReadRPC()
{
// RPC Models are imported directly in the ImageMetadata.
Projection::RPCParam rpcStruct;
rpcStruct.LineOffset = this->GetAs<double>("RPC/LINE_OFF");
rpcStruct.SampleOffset = this->GetAs<double>("RPC/SAMP_OFF");
rpcStruct.LatOffset = this->GetAs<double>("RPC/LAT_OFF");
rpcStruct.LonOffset = this->GetAs<double>("RPC/LONG_OFF");
rpcStruct.HeightOffset = this->GetAs<double>("RPC/HEIGHT_OFF");
rpcStruct.LineScale = this->GetAs<double>("RPC/LINE_SCALE");
rpcStruct.SampleScale = this->GetAs<double>("RPC/SAMP_SCALE");
rpcStruct.LatScale = this->GetAs<double>("RPC/LAT_SCALE");
rpcStruct.LonScale = this->GetAs<double>("RPC/LONG_SCALE");
rpcStruct.HeightScale = this->GetAs<double>("RPC/HEIGHT_SCALE");
rpcStruct.LineScale = this->GetAs<double>("RPC/LINE_SCALE");
rpcStruct.SampleScale = this->GetAs<double>("RPC/SAMP_SCALE");
rpcStruct.LatScale = this->GetAs<double>("RPC/LAT_SCALE");
rpcStruct.LonScale = this->GetAs<double>("RPC/LONG_SCALE");
rpcStruct.HeightScale = this->GetAs<double>("RPC/HEIGHT_SCALE");
std::vector<double> coeffs(20);
std::vector<double> coeffs(20);
coeffs = this->GetAsVector<double>("RPC/LINE_NUM_COEFF",' ',20);
std::copy(coeffs.begin(), coeffs.end(), rpcStruct.LineNum);
coeffs = this->GetAsVector<double>("RPC/LINE_NUM_COEFF",' ',20);
std::copy(coeffs.begin(), coeffs.end(), rpcStruct.LineNum);
coeffs = this->GetAsVector<double>("RPC/LINE_DEN_COEFF",' ',20);
std::copy(coeffs.begin(), coeffs.end(), rpcStruct.LineDen);
coeffs = this->GetAsVector<double>("RPC/LINE_DEN_COEFF",' ',20);
std::copy(coeffs.begin(), coeffs.end(), rpcStruct.LineDen);
coeffs = this->GetAsVector<double>("RPC/SAMP_NUM_COEFF",' ',20);
std::copy(coeffs.begin(), coeffs.end(), rpcStruct.SampleNum);
coeffs = this->GetAsVector<double>("RPC/SAMP_NUM_COEFF",' ',20);
std::copy(coeffs.begin(), coeffs.end(), rpcStruct.SampleNum);
coeffs = this->GetAsVector<double>("RPC/SAMP_DEN_COEFF",' ',20);
std::copy(coeffs.begin(), coeffs.end(), rpcStruct.SampleDen);
coeffs = this->GetAsVector<double>("RPC/SAMP_DEN_COEFF",' ',20);
std::copy(coeffs.begin(), coeffs.end(), rpcStruct.SampleDen);
m_Imd.Add(MDGeom::RPC, rpcStruct);
}
else
{
kwl.emplace(fieldName, fieldValue);
}
}
m_Imd.Add(MDGeom::RPC, rpcStruct);
}
......
Supports Markdown
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