Commit 360b8f16 authored by Julien Osman's avatar Julien Osman

ENH: Read AverageBandHeight for Sentinel1 + fix little bug

parent 3ec03180
......@@ -11,6 +11,9 @@ TileHintX 17663
TileHintY 1
DataType 11
OrbitNumber 6447
NumberOfLines 31106
NumberOfColumns 17663
AverageSceneHeight 19
LineSpacing 4.08568
PixelSpacing 3.19483
AcquisitionDate 2015-06-19T19:50:43.223221Z
......
......@@ -134,6 +134,7 @@ enum class MDNum
OrbitNumber,
NumberOfLines,
NumberOfColumns,
AverageSceneHeight,
// optical section
PhysicalGain,
PhysicalBias,
......
......@@ -104,6 +104,8 @@ public:
/* fetch the noise LUTs */
std::vector<OTB_SARNoise> GetNoiseVector(XMLMetadataSupplier) const;
double getBandTerrainHeight(XMLMetadataSupplier) const;
void Parse(const MetadataSupplierInterface *) override;
protected:
......
......@@ -320,6 +320,7 @@ MDNumBmType MDNumNames = bimapGenerator<MDNum>(std::map<MDNum, std::string> {
{MDNum::NoData, "NoData"},
{MDNum::NumberOfLines,"NumberOfLines"},
{MDNum::NumberOfColumns,"NumberOfColumns"},
{MDNum::AverageSceneHeight,"AverageSceneHeight"},
{MDNum::OrbitNumber, "OrbitNumber"},
{MDNum::PhysicalGain,"PhysicalGain"},
{MDNum::PhysicalBias,"PhysicalBias"},
......
......@@ -355,7 +355,7 @@ double Sentinel1ImageMetadataInterface::GetCenterIncidenceAngle() const
std::vector<OTB_azimuthFmRate> Sentinel1ImageMetadataInterface::GetAzimuthFmRate(XMLMetadataSupplier xmlMS) const
{
std::vector<OTB_azimuthFmRate> azimuthFmRateVector;
int listCount = xmlMS.GetAs<double>("product.generalAnnotation.azimuthFmRateList.count");
int listCount = xmlMS.GetAs<int>("product.generalAnnotation.azimuthFmRateList.count");
std::ostringstream oss;
for (int listId = 1 ; listId <= listCount ; ++listId)
{
......@@ -375,7 +375,7 @@ std::vector<OTB_azimuthFmRate> Sentinel1ImageMetadataInterface::GetAzimuthFmRate
std::vector<OTB_dopplerCentroid> Sentinel1ImageMetadataInterface::GetDopplerCentroid(XMLMetadataSupplier xmlMS) const
{
std::vector<OTB_dopplerCentroid> dopplerCentroidVector;
int listCount = xmlMS.GetAs<double>("product.dopplerCentroid.dcEstimateList.count");
int listCount = xmlMS.GetAs<int>("product.dopplerCentroid.dcEstimateList.count");
std::ostringstream oss;
for (int listId = 1 ; listId <= listCount ; ++listId)
{
......@@ -397,7 +397,7 @@ std::vector<OTB_dopplerCentroid> Sentinel1ImageMetadataInterface::GetDopplerCent
std::vector<OTB_Orbit> Sentinel1ImageMetadataInterface::GetOrbits(XMLMetadataSupplier xmlMS) const
{
std::vector<OTB_Orbit> orbitVector;
int listCount = xmlMS.GetAs<double>("product.generalAnnotation.orbitList.count");
int listCount = xmlMS.GetAs<int>("product.generalAnnotation.orbitList.count");
std::ostringstream oss;
for (int listId = 1 ; listId <= listCount ; ++listId)
{
......@@ -406,12 +406,12 @@ std::vector<OTB_Orbit> Sentinel1ImageMetadataInterface::GetOrbits(XMLMetadataSup
std::string path_root = "product.generalAnnotation.orbitList.orbit_" + oss.str();
OTB_Orbit orbit;
std::istringstream(xmlMS.GetAs<std::string>(path_root + ".time")) >> orbit.time;
orbit.posX = xmlMS.GetAs<double>(path_root + "1.position.x");
orbit.posY = xmlMS.GetAs<double>(path_root + "1.position.y");
orbit.posZ = xmlMS.GetAs<double>(path_root + "1.position.z");
orbit.velX = xmlMS.GetAs<double>(path_root + "1.velocity.x");
orbit.velY = xmlMS.GetAs<double>(path_root + "1.velocity.y");
orbit.velZ = xmlMS.GetAs<double>(path_root + "1.velocity.z");
orbit.posX = xmlMS.GetAs<double>(path_root + ".position.x");
orbit.posY = xmlMS.GetAs<double>(path_root + ".position.y");
orbit.posZ = xmlMS.GetAs<double>(path_root + ".position.z");
orbit.velX = xmlMS.GetAs<double>(path_root + ".velocity.x");
orbit.velY = xmlMS.GetAs<double>(path_root + ".velocity.y");
orbit.velZ = xmlMS.GetAs<double>(path_root + ".velocity.z");
orbitVector.push_back(orbit);
}
return orbitVector;
......@@ -420,7 +420,7 @@ std::vector<OTB_Orbit> Sentinel1ImageMetadataInterface::GetOrbits(XMLMetadataSup
std::vector<OTB_calibrationVector> Sentinel1ImageMetadataInterface::GetCalibrationVector(XMLMetadataSupplier xmlMS) const
{
std::vector<OTB_calibrationVector> calibrationVector;
int listCount = xmlMS.GetAs<double>("calibration.calibrationVectorList.count");
int listCount = xmlMS.GetAs<int>("calibration.calibrationVectorList.count");
std::ostringstream oss;
for (int listId = 1 ; listId <= listCount ; ++listId)
{
......@@ -469,7 +469,7 @@ std::vector<OTB_calibrationVector> Sentinel1ImageMetadataInterface::GetCalibrati
std::vector<OTB_SARNoise> Sentinel1ImageMetadataInterface::GetNoiseVector(XMLMetadataSupplier xmlMS) const
{
std::vector<OTB_SARNoise> noiseVector;
int listCount = xmlMS.GetAs<double>("noise.noiseVectorList.count");
int listCount = xmlMS.GetAs<int>("noise.noiseVectorList.count");
std::ostringstream oss;
for (int listId = 1 ; listId <= listCount ; ++listId)
{
......@@ -491,6 +491,21 @@ std::vector<OTB_SARNoise> Sentinel1ImageMetadataInterface::GetNoiseVector(XMLMet
return noiseVector;
}
double Sentinel1ImageMetadataInterface::getBandTerrainHeight(XMLMetadataSupplier xmlMS) const
{
double heightSum = 0.0;
int listCount = xmlMS.GetAs<int>("product.generalAnnotation.terrainHeightList.count");
std::ostringstream oss;
for (int listId = 1 ; listId <= listCount ; ++listId)
{
oss.str("");
oss << listId;
std::string path_root = "product.generalAnnotation.terrainHeightList.terrainHeight_" + oss.str();
heightSum += xmlMS.GetAs<double>((path_root + ".value").c_str());
}
return heightSum / listCount;
}
void Sentinel1ImageMetadataInterface::Parse(const MetadataSupplierInterface *mds)
{
assert(mds);
......@@ -543,6 +558,7 @@ void Sentinel1ImageMetadataInterface::Parse(const MetadataSupplierInterface *mds
sarParam.orbits = this->GetOrbits(AnnotationMS);
m_Imd.Add(MDNum::NumberOfLines, AnnotationMS.GetAs<int>("product.imageAnnotation.imageInformation.numberOfLines"));
m_Imd.Add(MDNum::NumberOfColumns, AnnotationMS.GetAs<int>("product.imageAnnotation.imageInformation.numberOfSamples"));
m_Imd.Add(MDNum::AverageSceneHeight, this->getBandTerrainHeight(AnnotationFilePath));
// Calibration file
std::string CalibrationFilePath = itksys::SystemTools::GetFilenamePath(AnnotationFilePath)
......
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