diff --git a/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h b/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h index fce0459c83ff12661b6194bcf07f8a594f6dcd98..5bb6d53099d71a0840c565af78656b27458156d4 100644 --- a/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h +++ b/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h @@ -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 diff --git a/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModelPathsAndKeys.h b/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModelPathsAndKeys.h index 49a874addb352d887b0b056b1eaf80a7ea1ddf51..97c5d81de3b376565f2cdefc03b1d8785906fbf3 100644 --- a/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModelPathsAndKeys.h +++ b/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModelPathsAndKeys.h @@ -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 diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp index 61e85f63c090b292f148b0019ddef1ac3ec59689..e1086e7655041a42d15f120da7f3f8a6a17141d2 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp @@ -1166,6 +1166,8 @@ 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 + keyStartSample, burstRecord.startSample); + get(kwl, burstPrefix + keyEndSample, burstRecord.endSample); get(kwl, burstPrefix + keyAzimuthStartTime, burstRecord.azimuthStartTime); get(kwl, burstPrefix + keyAzimuthStopTime, burstRecord.azimuthStopTime); burstRecords.push_back(burstRecord); @@ -1185,6 +1187,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); } diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModelPathsAndKeys.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModelPathsAndKeys.cpp index ad5bcf1efe5d86296a8e1f650e3fff400904059c..efc607357c5fbb608e023f4f56aa40d3a423f14b 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModelPathsAndKeys.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModelPathsAndKeys.cpp @@ -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 diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp index e7eda14a36e168a8be44e143f3b944ecc74df482..213946dd57228f2c615f15e13558361ec3c60c6f 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp @@ -51,6 +51,7 @@ namespace {// Anonymous namespace const ossimString attAdsHeader = "adsHeader"; const ossimString attAzimuthTime = "azimuthTime"; const ossimString attFirstValidSample = "firstValidSample"; + const ossimString attLastValidSample = "lastValidSample"; const ossimString attGr0 = "gr0"; const ossimString attGrsrCoefficients = "grsrCoefficients"; const ossimString attHeight = "height"; @@ -354,10 +355,15 @@ namespace ossimplugins const bool ret2 = safePlatform->getChildTextValue(instrumentId, "safe:number"); if (ret1 && ret2) { - theManifestKwl.add("support_data.", + // theManifestKwl.add("support_data.", + // "instrument", + // "S1" + instrumentId, + // true); + theManifestKwl.add("manifest_data.", "instrument", - "S1" + instrumentId, - true); + "S1" + instrumentId, + true); + return familyName + instrumentId; } throw std::runtime_error("Cannot obtain Sensor ID"); @@ -401,7 +407,8 @@ namespace ossimplugins { static const char MODULE[] = "ossimSentinel1ProductDoc::parseSafe"; - const ossimString prefix = "support_data."; + //const ossimString prefix = "support_data."; + const ossimString prefix = "manifest_data."; const ossimRefPtr<ossimXmlNode> safeProcessing = manifestDoc.getRoot()->findFirstNode("metadataSection/metadataObject/metadataWrap/xmlData/safe:processing"); const ossimRefPtr<ossimXmlNode> facility = safeProcessing->findFirstNode("safe:facility"); @@ -686,6 +693,8 @@ namespace ossimplugins add(theProductKwl, HEADER_PREFIX, "version", thePluginVersion); //RK maybe use this->getManifestPrefix() + add(theProductKwl, SUPPORT_DATA_PREFIX, "first_line_time", getTextFromFirstNode(adsHeader, "startTime").string()); + add(theProductKwl, SUPPORT_DATA_PREFIX, "last_line_time", getTextFromFirstNode(adsHeader, "stopTime").string()); add(theProductKwl, SUPPORT_DATA_PREFIX, "mds1_tx_rx_polar", polarisation); @@ -741,7 +750,10 @@ namespace ossimplugins const ossimXmlNode & downlinkInformation = getExpectedFirstNode(*productRoot, "generalAnnotation/downlinkInformationList/downlinkInformation"); - addOptional(theProductKwl, SUPPORT_DATA_PREFIX, "pulse_repetition_frequency", downlinkInformation, "prf"); + //addOptional(theProductKwl, SUPPORT_DATA_PREFIX, "pulse_repetition_frequency", downlinkInformation, "prf"); + const double azimuthFrequency = getDoubleFromFirstNode(imageInformation, "azimuthFrequency"); + add(theProductKwl, SUPPORT_DATA_PREFIX, "pulse_repetition_frequency", azimuthFrequency); + ossimXmlNode const& swathProcParams = getExpectedFirstNode(*productRoot, "imageAnnotation/processingInformation/swathProcParamsList/swathProcParams"); @@ -753,6 +765,12 @@ namespace ossimplugins addOptional(theProductKwl, SUPPORT_DATA_PREFIX, "range_looks", rangeProcessingNode, "numberOfLooks"); addOptional(theProductKwl, SUPPORT_DATA_PREFIX, "azimuth_looks", azimuthProcessingNode, "numberOfLooks"); + // azimuth steering rate for tops_sar only + if (theTOPSAR) + { + addOptional(theProductKwl, SUPPORT_DATA_PREFIX, "azimuth_steering_rate", productInformation, "azimuthSteeringRate"); + } + if(!theTOPSAR || !theSLC) { addOptional(theProductKwl, SUPPORT_DATA_PREFIX, ossimKeywordNames::NUMBER_SAMPLES_KW, imageInformation, "numberOfSamples"); @@ -782,6 +800,16 @@ namespace ossimplugins addDopplerCentroidCoefficients(*dcEstimateList); } + ossimXmlNodePtr const& aziFmRateList = productRoot->findFirstNode("generalAnnotation/azimuthFmRateList"); + if (!aziFmRateList) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "No azimuth fm rate coefficients available in metadata!!\n"; + } + else + { + addAzimuthFmRateCoefficients(*aziFmRateList); + } + readBurstRecords(*productRoot, imageInformation); readGeoLocationGrid(*productRoot); @@ -935,6 +963,10 @@ namespace ossimplugins burstRecord.azimuthStartTime = add(theProductKwl, BURST_PREFIX, "[0].azimuth_start_time", getTimeFromFirstNode(imageInformation, "productFirstLineUtcTime")); burstRecord.azimuthStopTime = add(theProductKwl, BURST_PREFIX, "[0].azimuth_stop_time", getTimeFromFirstNode(imageInformation, "productLastLineUtcTime")); burstRecord.endLine = add(theProductKwl, BURST_PREFIX, "[0].end_line", getFromFirstNode<unsigned int>(imageInformation, "numberOfLines")-1); + + burstRecord.startSample = add(theProductKwl, BURST_PREFIX, "[0].start_sample", 0); + burstRecord.endSample = add(theProductKwl, BURST_PREFIX, "[0].end_sample", getFromFirstNode<unsigned int>(imageInformation, "numberOfSamples")-1); + theBurstRecords.push_back(burstRecord); } else @@ -942,17 +974,22 @@ namespace ossimplugins char burstPrefix[1024]; const unsigned int linesPerBurst = getFromFirstNode<unsigned int>(productRoot, "swathTiming/linesPerBurst"); + const unsigned int samplesPerBurst = getFromFirstNode<unsigned int>(productRoot, "swathTiming/samplesPerBurst"); + unsigned int burstId(0); for(std::vector<ossimRefPtr<ossimXmlNode> >::iterator itNode = xnodes.begin(); itNode!=xnodes.end();++itNode,++burstId) { BurstRecordType burstRecord; - const TimeType azTime = getTimeFromFirstNode(**itNode, attAzimuthTime); - ossimString const& s = getTextFromFirstNode(**itNode, attFirstValidSample); - ossim_int64 first_valid(0), last_valid(0); + ossim_int64 first_valid(0), last_valid(0); bool begin_found(false), end_found(false); + ossim_int64 first_sample_valid(0), last_sample_valid(samplesPerBurst-1); + const TimeType azTime = getTimeFromFirstNode(**itNode, attAzimuthTime); + + // Scan firstValidSample to define the first valid sample and valid lines + ossimString const& s = getTextFromFirstNode(**itNode, attFirstValidSample); std::vector<ossimString> ssp = s.split(" "); for (std::vector<ossimString>::const_iterator sIt = ssp.begin(), e = ssp.end() @@ -960,6 +997,7 @@ namespace ossimplugins ; ++sIt ) { + // Find valid lines if(!begin_found) { if(*sIt!="-1") @@ -983,11 +1021,43 @@ namespace ossimplugins ++last_valid; } } + + // Find first valid samples + if(*sIt!="-1") + { + int Fvs = atoi((*sIt).c_str()); + 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 (std::vector<ossimString>::const_iterator sIt = sspLast.begin(), e = sspLast.end() + ; sIt != e ; ++sIt) + { + // Last first valid samples + if(*sIt!="-1") + { + int Lvs = atoi((*sIt).c_str()); + if (Lvs < last_sample_valid && Lvs > 0) + { + last_sample_valid = Lvs; + } + } + } + s_printf(burstPrefix, "%s[%d].", BURST_PREFIX.c_str(), burstId); burstRecord.startLine = add(theProductKwl,burstPrefix + keyStartLine, burstId*linesPerBurst + first_valid); burstRecord.endLine = add(theProductKwl,burstPrefix + keyEndLine, burstId*linesPerBurst + last_valid); + + burstRecord.startSample = add(theProductKwl,burstPrefix + keyStartSample, first_sample_valid); + burstRecord.endSample = add(theProductKwl,burstPrefix + keyEndSample, last_sample_valid); + // TODO: check units. burstRecord.azimuthStartTime = add(theProductKwl,burstPrefix + keyAzimuthStartTime, azTime + (first_valid*theAzimuthTimeInterval)); burstRecord.azimuthStopTime = add(theProductKwl,burstPrefix + keyAzimuthStopTime, azTime + (last_valid*theAzimuthTimeInterval)); @@ -995,6 +1065,12 @@ namespace ossimplugins theBurstRecords.push_back(burstRecord); } add(theProductKwl, BURST_NUMBER_KEY, burstId); + + const std::string BURST_NUMBER_LINES_KEY = "support_data.geom.bursts.number_lines_per_burst"; + add(theProductKwl, BURST_NUMBER_LINES_KEY, linesPerBurst); + + const std::string BURST_NUMBER_SAMPLES_KEY = "support_data.geom.bursts.number_samples_per_burst"; + add(theProductKwl, BURST_NUMBER_SAMPLES_KEY, samplesPerBurst); } } @@ -1184,6 +1260,11 @@ namespace ossimplugins ossimString count_str; dcEstimateList.getAttributeValue(count_str, "count"); const int count = count_str.toInt(); + + char prefix_main[256]; + s_printf(prefix_main, "dopplerCentroid.dop_coef_nb_list"); + add(theProductKwl, prefix_main, "", count); + if( count < 1) { ossimNotify(ossimNotifyLevel_DEBUG) << "No doppler centroid coefficients available in metadata!!\n"; @@ -1206,7 +1287,10 @@ namespace ossimplugins assert(dcEstimate.get()); addOptional(theProductKwl, prefix, "dop_coef_time", *dcEstimate, "azimuthTime"); //RK - const double ref_time = getOptionalTextFromFirstNode(*dcEstimate, "t0").toFloat64() * 1e9; // s to ns + //const double ref_time = getOptionalTextFromFirstNode(*dcEstimate, "t0").toFloat64() * 1e9; // s to ns + + const double ref_time = getOptionalTextFromFirstNode(*dcEstimate, "t0").toFloat64(); // remain in s + add(theProductKwl, prefix, keySlantRangeTime, ref_time); ossimString const& ns = getOptionalTextFromFirstNode(*dcEstimate, "ns"); @@ -1228,18 +1312,104 @@ namespace ossimplugins for (int count = 1 ; coeff != result.end() ; ++count, ++coeff) { char coeff_prefix[256]; - s_printf(coeff_prefix, "%s%d.dop_coef", prefix, count); + s_printf(coeff_prefix, "%s%d.geo_dop_coef", prefix, count); add(theProductKwl, coeff_prefix, coeff->string()); } } //if (!coeffStr.empty()) + ossimString const& coeffDopStr = getOptionalTextFromFirstNode(*dcEstimate, "dataDcPolynomial"); + + if (!coeffDopStr.empty()) + { + const ossimString separatorList = " "; + std::vector<ossimString> result; + + coeffDopStr.split(result, separatorList, true); + + std::vector<ossimString>::const_iterator coeff = result.begin(); + + for (int count = 1 ; coeff != result.end() ; ++count, ++coeff) + { + char coeff_prefix[256]; + s_printf(coeff_prefix, "%s%d.dop_coef", prefix, count); + + add(theProductKwl, coeff_prefix, coeff->string()); + } + + } //if (!coeffDopStr.empty()) + } // for each dcEstimate } // else count < 1 } + void ossimSentinel1Model::addAzimuthFmRateCoefficients(ossimXmlNode const& aziFmRateList) + { + ossimString count_str; + aziFmRateList.getAttributeValue(count_str, "count"); + const int count = count_str.toInt(); + + char prefix_main[256]; + s_printf(prefix_main, "azimuthFmRate.azi_fm_rate_coef_nb_list"); + add(theProductKwl, prefix_main, "", count); + + if( count < 1) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "No azimuth fm rate coefficients available in metadata!!\n"; + return; + } + else + { + ossimXmlNode::ChildListType azimuthFmRates; + aziFmRateList.findChildNodes("azimuthFmRate", azimuthFmRates); + + ossimXmlNode::ChildListType::const_iterator it = azimuthFmRates.begin(); + + for (int index = 1 ; it != azimuthFmRates.end() ; ++it, ++index) + { + char prefix[256]; + //azimuthFmRate.azi_fm_rate_coef_list; + s_printf(prefix, "azimuthFmRate.azi_fm_rate_coef_list%d.", index); + + const ossimXmlNodePtr & azimuthFmRate = *it; + assert(azimuthFmRate.get()); + + // AzimuthTime + addOptional(theProductKwl, prefix, "azi_fm_rate_coef_time", *azimuthFmRate, "azimuthTime"); + + // Slant range time + const double ref_time = getOptionalTextFromFirstNode(*azimuthFmRate, "t0").toFloat64(); // remain in s + + add(theProductKwl, prefix, keySlantRangeTime, ref_time); + + // Coefficients + ossimString const& coeffAziFmRateStr = getOptionalTextFromFirstNode(*azimuthFmRate, "azimuthFmRatePolynomial"); + + if (!coeffAziFmRateStr.empty()) + { + const ossimString separatorList = " "; + std::vector<ossimString> result; + + coeffAziFmRateStr.split(result, separatorList, true); + + std::vector<ossimString>::const_iterator coeff = result.begin(); + + for (int count = 1 ; coeff != result.end() ; ++count, ++coeff) + { + char coeff_prefix[256]; + s_printf(coeff_prefix, "%s%d.azi_fm_rate_coef", prefix, count); + + add(theProductKwl, coeff_prefix, coeff->string()); + } + + } //if (!coeffAziFmRateStr.empty()) + + } // for each azimuthFmRate + } + } + bool ossimSentinel1Model::openMetadataFile(ossimXmlDocument& doc, ossimString const& file) const { if ( !doc.openFile( file ) ) diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.h b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.h index 973fe55696450b49894a8e04817172458bf828fb..4eafcbd9367a175d6357fede1a065d2d86fe2a2f 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.h +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.h @@ -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; diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp index 99cdf4b094bd76835696df84bf64452c87f03acd..fbc7ee22e33b714e305e8455a02509fbbbdf573c 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp @@ -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,45 @@ void ossimSentinel1SarSensorModel::readAnnotationFile(const std::string & annota ++last_valid; } } + + // Find first valid samples + if(*sIt!="-1") + { + int Fvs = atoi((*sIt).c_str()); + 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 (std::vector<ossimString>::const_iterator sIt = sspLast.begin(), e = sspLast.end() + ; sIt != e ; ++sIt) + { + // Last first valid samples + if(*sIt!="-1") + { + int Lvs = atoi((*sIt).c_str()); + 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); } }