...
  View open merge request
Commits (2)
......@@ -32,7 +32,7 @@
#include "ossimPluginProjectionFactory.h"
#include "ossimRadarSatModel.h"
#include "ossimEnvisatAsarModel.h"
#include "ossimTerraSarModel.h"
#include "ossimTerraSarXSarSensorModel.h"
#include "ossimRadarSat2Model.h"
#include "ossimErsSarModel.h"
#include "ossimAlosPalsarModel.h"
......@@ -106,11 +106,6 @@ namespace ossimplugins
{
return doUpcastModelToProjectionWhenOCG(model);
}
template <> inline
ossimRefPtr<ossimProjection> doUpcastModelToProjection<ossimTerraSarModel>(ossimRefPtr<ossimTerraSarModel> model)
{
return doUpcastModelToProjectionWhenOCG(model);
}
template <typename ProjectionType>
......@@ -219,10 +214,10 @@ ossimProjection* ossimPluginProjectionFactory::createProjection(
if(traceDebug())
{
ossimNotify(ossimNotifyLevel_DEBUG)
<< MODULE << " DEBUG: testing ossimTerraSarModel" << std::endl;
<< MODULE << " DEBUG: testing ossimTerraSarXSarSensorModel" << std::endl;
}
ossimRefPtr<ossimTerraSarModel> model = new ossimTerraSarModel();
ossimRefPtr<ossimTerraSarXSarSensorModel> model = new ossimTerraSarXSarSensorModel();
if ( model->open(abs_file_name) )
{
......@@ -238,7 +233,7 @@ ossimProjection* ossimPluginProjectionFactory::createProjection(
model = 0;
}
#else
projection = doBuildProjection<ossimTerraSarModel>(abs_file_name);
projection = doBuildProjection<ossimTerraSarXSarSensorModel>(abs_file_name);
#endif
}
......@@ -355,9 +350,9 @@ ossimProjection* ossimPluginProjectionFactory::createProjection(
{
return new ossimRadarSat2Model();
}
else if (name == STATIC_TYPE_NAME(ossimTerraSarModel))
else if (name == STATIC_TYPE_NAME(ossimTerraSarXSarSensorModel))
{
return new ossimTerraSarModel();
return new ossimTerraSarXSarSensorModel();
}
else if (name == STATIC_TYPE_NAME(ossimErsSarModel))
{
......@@ -436,9 +431,9 @@ ossimProjection* ossimPluginProjectionFactory::createProjection(
{
result = new ossimRadarSat2Model();
}
else if (type == "ossimTerraSarModel")
else if (type == "ossimTerraSarXSarSensorModel")
{
result = new ossimTerraSarModel();
result = new ossimTerraSarXSarSensorModel();
}
else if (type == "ossimErsSarModel")
{
......@@ -485,7 +480,6 @@ ossimProjection* ossimPluginProjectionFactory::createProjection(
else if (type == "ossimSarSensorModel")
{
result = new ossimSarSensorModel();
std::cout<<"ossiMSarSensorModel"<<std::endl;
}
//***
......@@ -523,7 +517,7 @@ void ossimPluginProjectionFactory::getTypeNameList(std::vector<ossimString>& typ
{
typeList.push_back(STATIC_TYPE_NAME(ossimRadarSatModel));
typeList.push_back(STATIC_TYPE_NAME(ossimRadarSat2Model));
typeList.push_back(STATIC_TYPE_NAME(ossimTerraSarModel));
typeList.push_back(STATIC_TYPE_NAME(ossimTerraSarXSarSensorModel));
typeList.push_back(STATIC_TYPE_NAME(ossimEnvisatAsarModel));
typeList.push_back(STATIC_TYPE_NAME(ossimErsSarModel));
typeList.push_back(STATIC_TYPE_NAME(ossimAlosPalsarModel));
......
......@@ -26,6 +26,7 @@
#include <ossimTerraSarXSarSensorModel.h>
#include <ossim/base/ossimXmlDocument.h>
#include "ossim/ossimXmlTools.h"
#include "itksys/SystemTools.hxx"
namespace {// Anonymous namespace
......@@ -45,15 +46,18 @@ namespace {// Anonymous namespace
const ossimString attHeight = "height";
}// Anonymous namespace
void ossimplugins::ossimTerraSarXSarSensorModel::readAnnotationFile(const std::string & annotationXml, const std::string & geoXml)
bool ossimplugins::ossimTerraSarXSarSensorModel::readAnnotationFile(const std::string & annotationXml, const std::string & geoXml)
{
ossimRefPtr<ossimXmlDocument> xmlDoc = new ossimXmlDocument(annotationXml);
const ossimXmlNode & xmlRoot = *xmlDoc->getRoot();
//isGRD parse variant?
std::string const& product_type = getTextFromFirstNode(xmlRoot, "productInfo/productVariantInfo/productVariant");
std::string product_type = getTextFromFirstNode(xmlRoot, "productInfo/productVariantInfo/productVariant");
std::cout << "type " << product_type << '\n';
if (product_type == "SSC")
{
product_type = "SLC";
}
theProductType = ProductType(product_type);
......@@ -61,8 +65,6 @@ void ossimplugins::ossimTerraSarXSarSensorModel::readAnnotationFile(const std::s
std::vector<ossimRefPtr<ossimXmlNode> > xnodes;
xmlDoc->findNodes("/level1Product/platform/orbit/stateVec",xnodes);
std::cout << "Number of states " << xnodes.size() << '\n';
for(std::vector<ossimRefPtr<ossimXmlNode> >::iterator itNode = xnodes.begin(); itNode!=xnodes.end();++itNode)
{
OrbitRecordType orbitRecord;
......@@ -81,65 +83,45 @@ void ossimplugins::ossimTerraSarXSarSensorModel::readAnnotationFile(const std::s
orbitRecord.velocity[2] = getDoubleFromFirstNode(**itNode, attVelZ);
//Add one orbits record
std::cout << "Add theOrbitRecords\n";
theOrbitRecords.push_back(orbitRecord);
}
//Parse the near range time (in seconds)
theNearRangeTime = getDoubleFromFirstNode(xmlRoot, "productInfo/sceneInfo/rangeTime/firstPixel");
std::cout << "theNearRangeTime " << theNearRangeTime << '\n';
//Parse the range sampling rate
theRangeSamplingRate = getDoubleFromFirstNode(xmlRoot, "instrument/settings/RSF");
std::cout << "theRangeSamplingRate " << theRangeSamplingRate << '\n';
//Parse the range resolution
theRangeResolution = getDoubleFromFirstNode(xmlRoot, "productSpecific/complexImageInfo/slantRangeResolution");
std::cout << "theRangeResolution " << theRangeResolution << '\n';
//Parse the radar frequency
theRadarFrequency = getDoubleFromFirstNode(xmlRoot, "instrument/settings/settingRecord/PRF");
std::cout << "theRadarFrequency " << theRadarFrequency << '\n';
//Manage only strip map product for now (one burst)
//Parse azimuth time start/stop
const TimeType azimuthTimeStart = getTimeFromFirstNode(xmlRoot, "productInfo/sceneInfo/start/timeUTC");
std::cout << "azimuthTimeStart " << azimuthTimeStart << '\n';
const TimeType azimuthTimeStop = getTimeFromFirstNode(xmlRoot, "productInfo/sceneInfo/stop/timeUTC");
std::cout << "azimuthTimeStop " << azimuthTimeStop << '\n';
const DurationType td = azimuthTimeStop - azimuthTimeStart;
// numberOfRows
unsigned int numberOfRows = xmlRoot.findFirstNode("productInfo/imageDataInfo/imageRaster/numberOfRows")->getText().toUInt16();
std::cout << "numberOfRows " << numberOfRows << '\n';
//Compute azimuth time interval
theAzimuthTimeInterval = td / static_cast<double> (numberOfRows);
std::cout << "theAzimuthTimeInterval " << theAzimuthTimeInterval.total_microseconds() << " and 1/prf: " << (1 / theRadarFrequency) * 1000000 << '\n';
//For Terrasar-X only 1 burst is supported for now
BurstRecordType burstRecord;
burstRecord.startLine = 0;
burstRecord.azimuthStartTime = azimuthTimeStart;
burstRecord.azimuthStopTime = azimuthTimeStop;
burstRecord.endLine = numberOfRows - 1;
theBurstRecords.push_back(burstRecord);
//GRD (detected product)
// GRD (detected product)
if(isGRD())
{
//Retrieve Slant Range to Ground range coeddifcients
......@@ -182,7 +164,7 @@ void ossimplugins::ossimTerraSarXSarSensorModel::readAnnotationFile(const std::s
theSlantRangeToGroundRangeRecords.push_back(coordRecord);
}
//Parse GCPs
// Parse GCPs
ossimRefPtr<ossimXmlDocument> xmlGeo = new ossimXmlDocument(geoXml);
xnodes.clear();
......@@ -219,4 +201,37 @@ void ossimplugins::ossimTerraSarXSarSensorModel::readAnnotationFile(const std::s
}
this->optimizeTimeOffsetsFromGcps();
return true;
}
bool ossimplugins::ossimTerraSarXSarSensorModel::open(const ossimFilename& file)
{
// We expect the filename given here to be the image file (.tif or .cos) found in the IMAGEDATA directory
// Reference: TerraSar-X Ground Segment Level 1b Product Format Specification
// Get the path to the root of the image product
using namespace itksys;
const auto product_root = SystemTools::GetParentDirectory(SystemTools::GetParentDirectory(SystemTools::GetRealPath(file)));
// Get paths to the two xml we need, and check they exist
std::vector<std::string> components;
SystemTools::SplitPath(product_root, components);
std::vector<std::string> components_georef = components;
components_georef.push_back("ANNOTATION");
components_georef.push_back("GEOREF.xml");
const auto georef = SystemTools::JoinPath(components_georef);
std::vector<std::string> components_annotation = components;
components_annotation.push_back(components.back() + std::string(".xml"));
const auto annotation = SystemTools::JoinPath(components_annotation);
if (!SystemTools::FileExists(georef) || !SystemTools::FileExists(annotation))
{
return false;
}
// Try to read annotation file
return readAnnotationFile(annotation, georef);
}
......@@ -49,20 +49,13 @@ public:
virtual ~ossimTerraSarXSarSensorModel() = default;
#endif
//Not implemented yet
/** References
* TerraSAR-X Image Product Guide
* SNAP source code (s1tbx-io/src/main/java/org/esa/s1tbx/io/terrasarx/TerraSarXProductDirectory.java)
*/
void readAnnotationFile(const std::string & annotationXml, const std::string & geoXml);
bool readAnnotationFile(const std::string & annotationXml, const std::string & geoXml);
protected:
/*
std::string theProductType;
std::string theMode;
std::string theSwath;
std::string thePolarisation;
*/
bool open(const ossimFilename& file);
};
} // end namespace
......