Commit 80305ee9 authored by Julie Brossard's avatar Julie Brossard Committed by Cédric Traizet

[ENH] Add HasSARSensorMetadata function

parent 7f711a8f
......@@ -309,6 +309,8 @@ extern OTBMetadata_EXPORT std::ostream& operator<<(std::ostream& os, const otb::
extern OTBMetadata_EXPORT std::ostream& operator<<(std::ostream& os, const otb::ImageMetadata& imd);
OTBMetadata_EXPORT bool HasOpticalSensorMetadata(const ImageMetadata & imd);
OTBMetadata_EXPORT bool HasSARSensorMetadata(const ImageMetadata & imd);
} // end namespace otb
......
......@@ -679,4 +679,22 @@ bool HasOpticalSensorMetadata(const ImageMetadata & imd)
&& hasBandMetadataLut(MDL1D::SpectralSensitivity);
}
bool HasSARSensorMetadata(const ImageMetadata & imd)
{
auto hasBandMetadataStr = [&imd](MDStr key)
{return std::all_of(imd.Bands.begin(),
imd.Bands.end(),
[key](ImageMetadataBase band){return band.Has(key);});};
return imd.Has(MDStr::SensorID)
&& imd.Has(MDStr::Mission)
&& imd.Has(MDStr::ProductType)
&& imd.Has(MDNum::RadarFrequency)
&& imd.Has(MDNum::PRF)
&& imd.Has(MDTime::AcquisitionStartTime)
&& imd.Has(MDStr::OrbitDirection)
&& (hasBandMetadataStr(MDStr::Polarization) || imd.Has(MDStr::Polarization));
}
}
......@@ -30,6 +30,7 @@
#include "otbMetaDataKey.h"
#include "otbTestTools.h"
#include "otbOpticalImageMetadataInterface.h"
#include "otbSarImageMetadataInterface.h"
int otbImageMetadataInterfaceTest(int itkNotUsed(argc), char* argv[])
{
......@@ -64,6 +65,18 @@ int otbImageMetadataInterfaceTest(int itkNotUsed(argc), char* argv[])
return EXIT_FAILURE;
}
}
else if (dynamic_cast<otb::SarImageMetadataInterface*>(imi.GetPointer()))
{
if (!otb::HasSARSensorMetadata(imi->GetImageMetadata()))
{
std::cout << "Input image does not contains all required sar image metadata" << std::endl;
return EXIT_FAILURE;
}
}
else
{
std::cout << "Unknown interface" ;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
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