Commit 33f5066a authored by Victor Poughon's avatar Victor Poughon

Merge branch 'addMetadata_ossimSentinel1' into 'develop'

ENH : Add metadata to Sentinel 1 Model

See merge request !298
parents 74290a13 34ae0984
......@@ -157,6 +157,8 @@ public:
unsigned long startLine;
TimeType azimuthStopTime;
unsigned long endLine;
unsigned long startSample;
unsigned long endSample;
friend std::ostream & operator<<(std::ostream & os, const BurstRecordType & v)
{
return os << "{ azimuthStartTime: " << v.azimuthStartTime
......@@ -454,6 +456,7 @@ protected:
static const double C;
static const unsigned int thePluginVersion; // version of the SarSensorModel plugin
static const unsigned int thePluginVersionMin; // minimal version required of the SarSensorModel plugin
private:
/** Disabled assignment operator. */
......
......@@ -61,6 +61,8 @@ namespace ossimplugins {
extern const std::string keyVelZ ;
extern const std::string keyStartLine ;
extern const std::string keyEndLine ;
extern const std::string keyStartSample ;
extern const std::string keyEndSample ;
extern const std::string keyAzimuthStartTime ;
extern const std::string keyAzimuthStopTime ;
} // ossimplugins namespace
......
......@@ -107,7 +107,8 @@ namespace ossimplugins
const double ossimSarSensorModel::C = 299792458;
const unsigned int ossimSarSensorModel::thePluginVersion = 2;
const unsigned int ossimSarSensorModel::thePluginVersion = 3;
const unsigned int ossimSarSensorModel::thePluginVersionMin = 2;
ossimSarSensorModel::ProductType::ProductType(string_view const& s)
{
......@@ -1166,7 +1167,22 @@ bool ossimSarSensorModel::worldToAzimuthRangeTime(const ossimGpt& worldPt, TimeT
ossimSarSensorModel::BurstRecordType burstRecord;
get(kwl, burstPrefix + keyStartLine, burstRecord.startLine);
get(kwl, burstPrefix + keyEndLine, burstRecord.endLine);
get(kwl, burstPrefix + keyAzimuthStartTime, burstRecord.azimuthStartTime);
try {
unsigned int version;
get(kwl, HEADER_PREFIX, "version", version);
// startSample and endSample since version 3
if (version >= 3)
{
get(kwl, burstPrefix + keyStartSample, burstRecord.startSample);
get(kwl, burstPrefix + keyEndSample, burstRecord.endSample);
}
}
catch (...) {
throw std::runtime_error("Geom file generated with previous version of ossim plugins");
}
get(kwl, burstPrefix + keyAzimuthStartTime, burstRecord.azimuthStartTime);
get(kwl, burstPrefix + keyAzimuthStopTime, burstRecord.azimuthStopTime);
burstRecords.push_back(burstRecord);
}
......@@ -1185,6 +1201,8 @@ bool ossimSarSensorModel::worldToAzimuthRangeTime(const ossimGpt& worldPt, TimeT
add(kwl, burstPrefix + keyStartLine, (ossim_uint32) burstRecords[burstId].startLine);
add(kwl, burstPrefix + keyEndLine, (ossim_uint32) burstRecords[burstId].endLine);
add(kwl, burstPrefix + keyStartSample, (ossim_uint32) burstRecords[burstId].startSample);
add(kwl, burstPrefix + keyEndSample, (ossim_uint32) burstRecords[burstId].endSample);
add(kwl, burstPrefix + keyAzimuthStartTime, burstRecords[burstId].azimuthStartTime);
add(kwl, burstPrefix + keyAzimuthStopTime, burstRecords[burstId].azimuthStopTime);
}
......@@ -1389,7 +1407,7 @@ bool ossimSarSensorModel::worldToAzimuthRangeTime(const ossimGpt& worldPt, TimeT
try {
unsigned int version;
get(kwl, HEADER_PREFIX, "version", version);
if (version < thePluginVersion) {
if (version < thePluginVersionMin) {
throw std::runtime_error("Geom file generated with previous version of ossim plugins");
}
} catch (...) {
......
......@@ -26,39 +26,41 @@
#include "ossim/ossimSarSensorModelPathsAndKeys.h"
namespace ossimplugins {
const std::string HEADER_PREFIX = "header.";
const std::string SUPPORT_DATA_PREFIX = "support_data.";
const std::string GEOM_PREFIX = "support_data.geom";
const std::string SRD_PREFIX = "support_data.geom.srd";
const std::string SR_PREFIX = "support_data.geom.srd.coords.sr";
const std::string GR_PREFIX = "support_data.geom.srd.coords.gr";
const std::string BURST_PREFIX = "support_data.geom.bursts.burst";
const std::string BURST_NUMBER_KEY = "support_data.geom.bursts.number";
const std::string ORBIT_PREFIX = "orbitList.orbit";
const std::string ORBIT_NUMBER_KEY = "orbitList.nb_orbits";
const std::string GCP_PREFIX = "support_data.geom.gcp";
const std::string GCP_NUMBER_KEY = "support_data.geom.gcp.number";
const std::string NUMBER_KEY = "number";
const std::string HEADER_PREFIX = "header.";
const std::string SUPPORT_DATA_PREFIX = "support_data.";
const std::string GEOM_PREFIX = "support_data.geom";
const std::string SRD_PREFIX = "support_data.geom.srd";
const std::string SR_PREFIX = "support_data.geom.srd.coords.sr";
const std::string GR_PREFIX = "support_data.geom.srd.coords.gr";
const std::string BURST_PREFIX = "support_data.geom.bursts.burst";
const std::string BURST_NUMBER_KEY = "support_data.geom.bursts.number";
const std::string ORBIT_PREFIX = "orbitList.orbit";
const std::string ORBIT_NUMBER_KEY = "orbitList.nb_orbits";
const std::string GCP_PREFIX = "support_data.geom.gcp";
const std::string GCP_NUMBER_KEY = "support_data.geom.gcp.number";
const std::string NUMBER_KEY = "number";
const std::string keySr0 = "sr0";
const std::string keyGr0 = "gr0";
const std::string keyAzimuthTime = "azimuthTime";
const std::string keySlantRangeTime = "slant_range_time";
const std::string keyImPtX = "im_pt.x";
const std::string keyImPtY = "im_pt.y";
const std::string keyWorldPtLat = "world_pt.lat";
const std::string keyWorldPtLon = "world_pt.lon";
const std::string keyWorldPtHgt = "world_pt.hgt";
const std::string keyTime = "time";
const std::string keyPosX = "x_pos";
const std::string keyPosY = "y_pos";
const std::string keyPosZ = "z_pos";
const std::string keyVelX = "x_vel";
const std::string keyVelY = "y_vel";
const std::string keyVelZ = "z_vel";
const std::string keyStartLine = "start_line";
const std::string keyEndLine = "end_line";
const std::string keyAzimuthStartTime = "azimuth_start_time";
const std::string keyAzimuthStopTime = "azimuth_stop_time";
const std::string keySr0 = "sr0";
const std::string keyGr0 = "gr0";
const std::string keyAzimuthTime = "azimuthTime";
const std::string keySlantRangeTime = "slant_range_time";
const std::string keyImPtX = "im_pt.x";
const std::string keyImPtY = "im_pt.y";
const std::string keyWorldPtLat = "world_pt.lat";
const std::string keyWorldPtLon = "world_pt.lon";
const std::string keyWorldPtHgt = "world_pt.hgt";
const std::string keyTime = "time";
const std::string keyPosX = "x_pos";
const std::string keyPosY = "y_pos";
const std::string keyPosZ = "z_pos";
const std::string keyVelX = "x_vel";
const std::string keyVelY = "y_vel";
const std::string keyVelZ = "z_vel";
const std::string keyStartLine = "start_line";
const std::string keyEndLine = "end_line";
const std::string keyStartSample = "start_sample";
const std::string keyEndSample = "end_sample";
const std::string keyAzimuthStartTime = "azimuth_start_time";
const std::string keyAzimuthStopTime = "azimuth_stop_time";
} // ossimplugins namespace
......@@ -163,6 +163,7 @@ namespace ossimplugins
void readGeoLocationGrid(ossimXmlNode const& productRoot);
void addOrbitStateVectors(ossimXmlNode const& orbitList);
void addDopplerCentroidCoefficients(ossimXmlNode const& dcEstimateList);
void addAzimuthFmRateCoefficients(ossimXmlNode const& aziFmRateList);
bool openMetadataFile(ossimXmlDocument& doc, ossimString const& file) const;
ossimFilename theManifestDirectory;
......
......@@ -30,6 +30,7 @@
namespace {// Anonymous namespace
const ossimString attAzimuthTime = "azimuthTime";
const ossimString attFirstValidSample = "firstValidSample";
const ossimString attLastValidSample = "lastValidSample";
const ossimString attGr0 = "gr0";
const ossimString attGrsrCoefficients = "grsrCoefficients";
const ossimString attHeight = "height";
......@@ -175,11 +176,16 @@ void ossimSentinel1SarSensorModel::readAnnotationFile(const std::string & annota
burstRecord.azimuthStopTime = getTimeFromFirstNode(xmlRoot,"imageAnnotation/imageInformation/productLastLineUtcTime");
burstRecord.endLine = getTextFromFirstNode(xmlRoot, "imageAnnotation/imageInformation/numberOfLines").toUInt16()-1;
burstRecord.startSample = 0;
burstRecord.endSample = getTextFromFirstNode(xmlRoot, "imageAnnotation/imageInformation/numberOfSamples").toUInt16()-1;;
theBurstRecords.push_back(burstRecord);
}
else
{
const unsigned int linesPerBurst = xmlRoot.findFirstNode("swathTiming/linesPerBurst")->getText().toUInt16();
const unsigned int samplesPerBurst = xmlRoot.findFirstNode("swathTiming/samplesPerBurst")->getText().toUInt16();
unsigned int burstId(0);
for(std::vector<ossimRefPtr<ossimXmlNode> >::iterator itNode = xnodes.begin(); itNode!=xnodes.end();++itNode,++burstId)
......@@ -188,10 +194,12 @@ void ossimSentinel1SarSensorModel::readAnnotationFile(const std::string & annota
const ossimSarSensorModel::TimeType azTime = getTimeFromFirstNode(**itNode, attAzimuthTime);
// Scan firstValidSample to define the first valid sample and valid lines
ossimString const& s = getTextFromFirstNode(**itNode, attFirstValidSample);
long first_valid(0), last_valid(0);
bool begin_found(false), end_found(false);
long first_sample_valid(0), last_sample_valid(samplesPerBurst-1);
std::vector<ossimString> ssp = s.split(" ");
......@@ -200,6 +208,7 @@ void ossimSentinel1SarSensorModel::readAnnotationFile(const std::string & annota
; ++sIt
)
{
// Find valid lines
if(!begin_found)
{
if(*sIt!="-1")
......@@ -224,14 +233,63 @@ void ossimSentinel1SarSensorModel::readAnnotationFile(const std::string & annota
++last_valid;
}
}
// Find first valid samples
if(*sIt!="-1")
{
int Fvs = samplesPerBurst;
try
{
Fvs = std::stoi(*sIt);
}
catch( ... )
{
// Throw an execption
throw std::runtime_error("Failed to convert firstValidSample value.");
}
if (Fvs > first_sample_valid && Fvs < samplesPerBurst)
{
first_sample_valid = Fvs;
}
}
}
// Scan lastValidSample to define the last valid sample
ossimString const& sLast = getTextFromFirstNode(**itNode, attLastValidSample);
std::vector<ossimString> sspLast = sLast.split(" ");
for (auto const& token : sspLast)
{
// Last first valid samples
if(token != "-1")
{
int Lvs = 0;
try
{
Lvs = std::stoi(token);
}
catch( ... )
{
// Throw an execption
throw std::runtime_error("Failed to convert lastValidSample value.");
}
if (Lvs < last_sample_valid && Lvs > 0)
{
last_sample_valid = Lvs;
}
}
}
burstRecord.startLine = burstId*linesPerBurst + first_valid;
burstRecord.endLine = burstId*linesPerBurst + last_valid;
burstRecord.azimuthStartTime = azTime + (first_valid*theAzimuthTimeInterval);
burstRecord.azimuthStopTime = azTime + (last_valid*theAzimuthTimeInterval);
burstRecord.startSample = first_sample_valid;
burstRecord.endSample = last_sample_valid;
theBurstRecords.push_back(burstRecord);
}
}
......
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