Skip to content
Snippets Groups Projects
Commit e8c6e7de authored by Cédric Traizet's avatar Cédric Traizet
Browse files

BUG: verify that the sensor is CosmoSkyMed before opening hdf5 datasets

parent 0777d9f3
No related branches found
No related tags found
No related merge requests found
......@@ -359,6 +359,29 @@ void CosmoImageMetadataInterface::Parse(const MetadataSupplierInterface & mds)
{
assert(mds.GetNbBands() == this->m_Imd.Bands.size());
// Check Mission Id, acquisition mode and product type
Fetch(MDStr::Mission, mds, "MISSION_ID");
if (m_Imd[MDStr::Mission] != "CSK" )
{
otbGenericExceptionMacro(MissingMetadataException,
<< "Not a CosmoSkyMed product");
}
Fetch(MDStr::Mode, mds, "Acquisition_Mode");
if((m_Imd[MDStr::Mode] != "HIMAGE") &&
(m_Imd[MDStr::Mode] != "SPOTLIGHT") &&
(m_Imd[MDStr::Mode] != "ENHANCED SPOTLIGHT"))
{
itkWarningMacro(<< "Not an expected acquisition mode (only HIMAGE and SPOTLIGHT expected)" << m_Imd[MDStr::Mode] );
}
Fetch(MDStr::ProductType, mds, "Product_Type");
if( (m_Imd[MDStr::ProductType] != "SCS_B") && m_Imd[MDStr::ProductType] != "SCS_U")
{
itkWarningMacro(<< "Not an expected product type (only SCS_B and SCS_U expected) " << m_Imd[MDStr::ProductType] );
}
// Check SubDatasets (For COSMO, we need //S01/SBI dataset)
auto subDsName = "HDF5:" + mds.GetResourceFile() + "://S01/SBI";
auto ds = (GDALDataset *) GDALOpen(subDsName.c_str(), GA_ReadOnly );
......@@ -375,29 +398,6 @@ void CosmoImageMetadataInterface::Parse(const MetadataSupplierInterface & mds)
<< "Cannot find S01/SBI subdataset")
}
// Metadata read by GDAL
Fetch(MDStr::Mission, mds, "MISSION_ID");
Fetch(MDStr::Mode, mds, "Acquisition_Mode");
Fetch(MDStr::ProductType, mds, "Product_Type");
// Check Mission Id, acquisition mode and product type
if(! (m_Imd[MDStr::Mission] == "CSK" ))
{
itkWarningMacro(<< "Not a valid missionId" << m_Imd[MDStr::Mission] );
}
if((m_Imd[MDStr::Mode] != "HIMAGE") &&
(m_Imd[MDStr::Mode] != "SPOTLIGHT") &&
(m_Imd[MDStr::Mode] != "ENHANCED SPOTLIGHT"))
{
itkWarningMacro(<< "Not an expected acquisition mode (only HIMAGE and SPOTLIGHT expected)" << m_Imd[MDStr::Mode] );
}
if( (m_Imd[MDStr::ProductType] != "SCS_B") && m_Imd[MDStr::ProductType] != "SCS_U")
{
itkWarningMacro(<< "Not an expected product type (only SCS_B and SCS_U expected) " << m_Imd[MDStr::ProductType] );
}
m_Imd.Add(MDStr::SensorID, "CSK");
Fetch(MDStr::Instrument, mds, "Satellite_ID");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment