Commit 0fc441ea authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

ENH: ossim, adding support for SPOT 4

parent abf1d0d3
......@@ -5,10 +5,10 @@
//
// Author: Oscar Kramer (ossim port by D. Burken)
//
// Description:
// Description:
//
// Contains declaration of class ossimSpotDimapSupportData.
//
//
//*****************************************************************************
// $Id: ossimSpotDimapSupportData.h 12101 2007-12-01 19:15:28Z dburken $
#ifndef ossimSpotDimapSupportData_HEADER
......@@ -45,7 +45,7 @@ public:
OSSIM_SPOT_METADATA_VERSION_1_0 = 1,
OSSIM_SPOT_METADATA_VERSION_1_1 = 2
};
ossimSpotDimapSupportData();
......@@ -60,19 +60,20 @@ public:
bool loadXmlFile(const ossimFilename& file,
bool processSwir=false);
ossimString getSensorID() const;
ossimString getMetadataVersionString() const;
ossimString getAcquisitionDate() const;
ossimString getImageID() const;
ossimFilename getMetadataFile() const;
void getSunAzimuth(ossim_float64& az) const;
void getSunElevation(ossim_float64& el) const;
void getImageSize(ossimDpt& sz) const;
void getImageSize(ossimDpt& sz) const;
void getLineSamplingPeriod(ossim_float64& pe) const;
void getIncidenceAngle(ossim_float64& ia) const;
ossim_uint32 getNumberOfBands() const;
bool isStarTrackerUsed() const;
bool isSwirDataUsed() const;
//---
// Image center point:
//---
......@@ -90,7 +91,7 @@ public:
/** Zero based image rectangle, sub image if there is one. */
void getImageRect(ossimDrect& rect)const;
//---
// Sub image offset:
//---
......@@ -104,9 +105,9 @@ public:
void getVelocityEcf(ossim_uint32 sample, ossimEcefPoint& ve) const;
void getVelocityEcf(const ossim_float64& time, ossimEcefPoint& ve) const;
void getEphSampTime(ossim_uint32 sample, ossim_float64& et) const;
ossim_uint32 getNumEphSamples() const;
//---
// Attitude Angles in RADIANS:
//---
......@@ -114,7 +115,7 @@ public:
void getAttitude(const ossim_float64& time, ossimDpt3d& at) const;
void getAttSampTime(ossim_uint32 sample, ossim_float64& at) const;
ossim_uint32 getNumAttSamples() const;
//---
// Pixel Pointing/Mirror tilt Angles in RADIANS:
//---
......@@ -124,7 +125,7 @@ public:
void getPixelLookAngleY (ossim_uint32 sample, ossim_float64& pa) const;
void getPixelLookAngleY (const ossim_float64& sample,
ossim_float64& pa) const;
//---
// Geoposition points provided in the file (most likely just corner points):
//---
......@@ -162,7 +163,7 @@ private:
void getInterpolatedLookAngle(const ossim_float64& p,
const std::vector<ossim_float64>& angles,
ossim_float64& la) const;
ossim_float64 convertTimeStamp(const ossimString& time_stamp) const;
void convertTimeStamp(const ossimString& time_stamp,
......@@ -194,7 +195,7 @@ private:
/**
* Frame points:
*
*
* From xml section:
* /Dimap_Document/Dataset_Frame/
*
......@@ -211,6 +212,7 @@ private:
*/
bool initFramePoints(ossimRefPtr<ossimXmlDocument> xmlDocument);
ossimString theSensorID;
ossimSpotMetadataVersion theMetadataVersion;
ossimString theImageID;
ossimFilename theMetadataFile;
......@@ -220,7 +222,7 @@ private:
* /Dimap_Document/Dataset_Sources/Source_Information/
* Scene_Source
*/
ossim_float64 theSunAzimuth;
ossim_float64 theSunAzimuth;
ossim_float64 theSunElevation;
ossim_float64 theIncidenceAngle;
......@@ -231,7 +233,7 @@ private:
/** Zero based center of frame. */
ossimDpt theRefImagePoint;
ossimDpt theSubImageOffset;
/** relative to full image */
......@@ -239,11 +241,11 @@ private:
/** relative to full image */
ossim_float64 theRefLineTimeLine;
ossim_float64 theLineSamplingPeriod;
/** holds the size of thePixelLookAngleX/Y */
ossim_uint32 theDetectorCount;
ossim_uint32 theDetectorCount;
std::vector<ossim_float64> thePixelLookAngleX;
std::vector<ossim_float64> thePixelLookAngleY;
std::vector<ossimDpt3d> theAttitudeSamples; // x=pitch, y=roll, z=yaw
......@@ -275,7 +277,7 @@ private:
/**
* Private parse methods called by loadXml.
*
*
* These "parse" methods were made simply to split the loadXmlMethod
* into pieces. This was an attempt to troubleshoot what was thought to
* be a compiler issue, which turned out to be changed metadata and bad
......@@ -286,6 +288,7 @@ private:
bool parsePart1(ossimRefPtr<ossimXmlDocument> xmlDocument);
bool parsePart2(ossimRefPtr<ossimXmlDocument> xmlDocument);
bool parsePart3(ossimRefPtr<ossimXmlDocument> xmlDocument);
bool parsePart4(ossimRefPtr<ossimXmlDocument> xmlDocument);
};
#endif /* #ifndef ossimSpotDimapSupportData_HEADER */
......@@ -4,10 +4,10 @@
//
// Author: Oscar Kramer (ossim port by D. Burken)
//
// Description:
// Description:
//
// Contains definition of class ossimSpot5Model.
//
//
//*****************************************************************************
// $Id: ossimSpot5Model.cpp 13976 2009-01-20 16:00:16Z gpotts $
......@@ -74,7 +74,7 @@ ossimSpot5Model::ossimSpot5Model()
theIllumElevation (0.0),
thePositionError (0.0),
theRefImagingTime (0.0),
theRefImagingTimeLine (0.0),
theRefImagingTimeLine (0.0),
theLineSamplingPeriod (0.0),
// theSatToOrbRotation (3, 3),
// theOrbToEcfRotation (3, 3),
......@@ -98,7 +98,7 @@ ossimSpot5Model::ossimSpot5Model(ossimSpotDimapSupportData* sd)
theIllumElevation (0.0),
thePositionError (0.0),
theRefImagingTime (0.0),
theRefImagingTimeLine (0.0),
theRefImagingTimeLine (0.0),
theLineSamplingPeriod (0.0),
// theSatToOrbRotation (3, 3),
// theOrbToEcfRotation (3, 3),
......@@ -133,7 +133,7 @@ ossimSpot5Model::ossimSpot5Model(ossimSpotDimapSupportData* sd)
//*****************************************************************************
// DESTRUCTOR: ~ossimSpot5Model()
//
//
//*****************************************************************************
ossimSpot5Model::~ossimSpot5Model()
{
......@@ -144,7 +144,7 @@ ossimSpot5Model::~ossimSpot5Model()
delete theSupportData;
theSupportData = NULL;
}
if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG DESTRUCTOR: ~ossimSpot5Model(): returning..." << std::endl;
}
......@@ -153,7 +153,7 @@ ossimSpot5Model::ossimSpot5Model(const ossimSpot5Model& rhs)
{
if(theSupportData)
{
delete theSupportData;
theSupportData = 0;
}
......@@ -179,7 +179,7 @@ void ossimSpot5Model::computeSatToOrbRotation(NEWMAT::Matrix& result, ossim_floa
//---
ossimDpt3d att;
theSupportData->getAttitude(t, att);
//---
// Apply the attitude adjustable parameters:
//---
......@@ -187,7 +187,7 @@ void ossimSpot5Model::computeSatToOrbRotation(NEWMAT::Matrix& result, ossim_floa
att.x += thePitchOffset + dt*thePitchRate;
att.y += theRollOffset + dt*theRollRate;
att.z += theYawOffset + dt*theYawRate;
//---
// Compute trig functions to populate rotation matrices: ANGLES IN RADIANS
//---
......@@ -197,7 +197,7 @@ void ossimSpot5Model::computeSatToOrbRotation(NEWMAT::Matrix& result, ossim_floa
double sr = sin(att.y);
double cy = cos(att.z);
double sy = sin(att.z);
//---
// Populate rotation matrix:
//---
......@@ -205,8 +205,8 @@ void ossimSpot5Model::computeSatToOrbRotation(NEWMAT::Matrix& result, ossim_floa
result << (cr*cy) << (-cr*sy) << (-sr)
<< (cp*sy+sp*sr*cy) << (cp*cy-sp*sr*sy) << (sp*cr)
<< (-sp*sy+cp*sr*cy) << (-sp*cy-cp*sr*sy) << cp*cr;
if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::computeSatToOrbRotation(): returning..." << std::endl;
}
......@@ -236,7 +236,7 @@ void ossimSpot5Model::computeSatToOrbRotation(ossim_float64 t)const
att.x += thePitchOffset + dt*thePitchRate;
att.y += theRollOffset + dt*theRollRate;
att.z += theYawOffset + dt*theYawRate;
//---
// Compute trig functions to populate rotation matrices: ANGLES IN RADIANS
//---
......@@ -254,26 +254,26 @@ void ossimSpot5Model::computeSatToOrbRotation(ossim_float64 t)const
theSatToOrbRotation << (cr*cy) << (-cr*sy) << (-sr)
<< (cp*sy+sp*sr*cy) << (cp*cy-sp*sr*sy) << (sp*cr)
<< (-sp*sy+cp*sr*cy) << (-sp*cy-cp*sr*sy) << cp*cr;
if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::computeSatToOrbRotation(): returning..." << std::endl;
}
#endif
//*****************************************************************************
// PUBLIC METHOD: ossimSpot5Model::updateModel()
//
//
// Updates the model parameters given the normalized adjustable parameter
// array.
//
//
//*****************************************************************************
void ossimSpot5Model::updateModel()
{
clearErrorStatus();
try
{
if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::updateModel(): entering..." << std::endl;
if(getNumberOfAdjustableParameters() < 1)
{
theRollOffset = 0;
......@@ -308,8 +308,8 @@ void ossimSpot5Model::updateModel()
urg,
lrg,
llg);
if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::updateModel(): returning..." << std::endl;
if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::updateModel(): returning..." << std::endl;
}
catch(...)
{
......@@ -327,7 +327,7 @@ void ossimSpot5Model::initAdjustableParameters()
//---
resizeAdjustableParameterArray(7);
ossim_uint32 numParams = getNumberOfAdjustableParameters();
//---
// Initialize base-class adjustable parameter array:
//---
......@@ -338,7 +338,7 @@ void ossimSpot5Model::initAdjustableParameters()
setParameterUnit(i,PARAM_UNITS[i]);
setParameterSigma(i, SIGMA[i]);
}
if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::initAdjustableParameters(): returning..." << std::endl;
}
......@@ -357,7 +357,7 @@ void ossimSpot5Model::loadSupportData()
if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::loadSupportData(): returning..." << std::endl;
return;
}
if (theSupportData->getErrorStatus() != ossimErrorCodes::OSSIM_OK)
{
setErrorStatus();
......@@ -370,7 +370,7 @@ void ossimSpot5Model::loadSupportData()
//---
// Initialize some member variables from the support data:
//---
theSensorID = "Spot 5";
theSensorID = theSupportData->getSensorID();
theImageID = theSupportData->getImageID();
theMetaDataFile = theSupportData->getMetadataFile();
......@@ -384,7 +384,7 @@ void ossimSpot5Model::loadSupportData()
theImageSize = sz;
theSupportData->getRefLineTime(theRefImagingTime);
theSupportData->getRefLineTimeLine(theRefImagingTimeLine);
theSupportData->getLineSamplingPeriod(theLineSamplingPeriod);
theSupportData->getSubImageOffset(theSpotSubImageOffset);
......@@ -394,7 +394,7 @@ void ossimSpot5Model::loadSupportData()
//---
theSupportData->getImageRect(theImageClipRect);
theSupportData->getRefImagePoint(theRefImgPt);
ossimGpt p1;
ossimGpt p2;
ossimGpt p3;
......@@ -402,7 +402,7 @@ void ossimSpot5Model::loadSupportData()
// I need to find the nominal scale of the spot 5 dataset
//---
// Position error is a function of whether star tracker information was
// available:
......@@ -444,7 +444,7 @@ void ossimSpot5Model::loadSupportData()
theGSD = ossimDpt((ossimEcefPoint(cgpt) - ossimEcefPoint(hgpt)).magnitude(),
(ossimEcefPoint(cgpt) - ossimEcefPoint(vgpt)).magnitude());
theMeanGSD = (theGSD.x+theGSD.y)/2.0;
if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::loadSupportData(): returning..." << std::endl;
......@@ -486,7 +486,7 @@ std::ostream& ossimSpot5Model::print(std::ostream& out) const
// Set the flags back.
out.flags(f);
return ossimSensorModel::print(out);
}
......@@ -498,12 +498,12 @@ bool ossimSpot5Model::saveState(ossimKeywordlist& kwl,
ossimString supportPrefix = ossimString(prefix) + "support_data.";
theSupportData->saveState(kwl, supportPrefix);
}
else
else
{
return false;
}
return ossimSensorModel::saveState(kwl, prefix);
}
......@@ -511,12 +511,12 @@ bool ossimSpot5Model::loadState(const ossimKeywordlist& kwl,
const char* prefix)
{
ossimString supportPrefix = ossimString(prefix) + "support_data.";
if(!theSupportData)
{
theSupportData = new ossimSpotDimapSupportData;
}
if(theSupportData->loadState(kwl, supportPrefix))
{
if(!ossimSensorModel::loadState(kwl, prefix))
......@@ -528,10 +528,10 @@ bool ossimSpot5Model::loadState(const ossimKeywordlist& kwl,
{
return false;
}
loadSupportData();
updateModel();
return (getErrorStatus()==ossimErrorCodes::OSSIM_OK);
}
......@@ -571,7 +571,7 @@ void ossimSpot5Model::imagingRay(const ossimDpt& image_point,
<< "DEBUG:\n\tP_ecf = " << P_ecf
<< "\n\t V_ecf = " << V_ecf << std::endl;
}
//
// 3. Establish the look direction in Vehicle LSR space (S_sat).
// ANGLES IN RADIANS
......@@ -599,7 +599,7 @@ void ossimSpot5Model::imagingRay(const ossimDpt& image_point,
// (S_orb):
//
computeSatToOrbRotation(satToOrbit, t_line);
ossimColumnVector3d u_orb = (satToOrbit*u_sat).unit();
if (traceDebug() || runtime_dbflag)
{
......@@ -629,8 +629,8 @@ void ossimSpot5Model::imagingRay(const ossimDpt& image_point,
orbToEcfRotation << X_orb[0] << Y_orb[0] << Z_orb[0]
<< X_orb[1] << Y_orb[1] << Z_orb[1]
<< X_orb[2] << Y_orb[2] << Z_orb[2];
ossimColumnVector3d u_ecf = (orbToEcfRotation*u_orb);
if (traceDebug() || runtime_dbflag)
{
......@@ -638,12 +638,12 @@ void ossimSpot5Model::imagingRay(const ossimDpt& image_point,
<< "DEBUG:\n\t orbToEcfRotation = " << orbToEcfRotation
<< "\n\t u_ecf = " << u_ecf << endl;
}
//
// Establish the imaging ray given direction and origin:
//
image_ray = ossimEcefRay(P_ecf, ossimEcefVector(u_ecf[0], u_ecf[1], u_ecf[2]));
if (traceExec())
{
ossimNotify(ossimNotifyLevel_DEBUG)
......@@ -668,7 +668,7 @@ void ossimSpot5Model::lineSampleHeightToWorld(const ossimDpt& image_point,
if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::lineSampleHeightToWorld(): returning..." << std::endl;
return;
}
//***
// First establish imaging ray from image point:
//***
......@@ -689,7 +689,7 @@ void ossimSpot5Model::lineSampleHeightToWorld(const ossimDpt& image_point,
// ossimDpt tempGpt = gp;
// ossimDpt dest;
// theGroundToImageMap.map(tempGpt, dest);
// return dest;
// }
......@@ -702,7 +702,7 @@ void ossimSpot5Model::lineSampleHeightToWorld(const ossimDpt& image_point,
// ossimDpt dest;
// theImageToGroundMap.map(ip, dest);
// return ossimGpt(dest.lat, dest.lon, ossim::nan(), origin().datum());
// }
......@@ -714,7 +714,7 @@ ossimSpot5Model::setupOptimizer(const ossimString& init_file)
ossimFilename geomFile = init_file;
geomFile = geomFile.setExtension("geom");
bool tryKwl = false;
if(!spot5Test.exists())
{
spot5Test = geomFile.path();
......
......@@ -169,6 +169,7 @@ ossimObject* ossimSpotDimapSupportData::dup()const
void ossimSpotDimapSupportData::clearFields()
{
clearErrorStatus();
theSensorID="Spot 5";
theMetadataVersion = OSSIM_SPOT_METADATA_VERSION_UNKNOWN;
theImageID = "";
theMetadataFile = "";
......@@ -849,6 +850,11 @@ void ossimSpotDimapSupportData::printInfo(ostream& os) const
<< "\n " << std::endl;
}
ossimString ossimSpotDimapSupportData::getSensorID() const
{
return theSensorID;
}
ossimString ossimSpotDimapSupportData::getMetadataVersionString() const
{
if (theMetadataVersion == OSSIM_SPOT_METADATA_VERSION_1_1)
......@@ -2088,6 +2094,31 @@ bool ossimSpotDimapSupportData::parsePart3(
return true;
}
bool ossimSpotDimapSupportData::parsePart4(
ossimRefPtr<ossimXmlDocument> xmlDocument)
{
ossimString xpath;
std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes;
std::vector<ossimRefPtr<ossimXmlNode> > sub_nodes;
std::vector<ossimRefPtr<ossimXmlNode> >::iterator node;
//---
// Fetch the mission index (Spot 4 or 5):
//---
xml_nodes.clear();
xpath = "/Dimap_Document/Dataset_Sources/Source_Information/Scene_Source/MISSION_INDEX";
xmlDocument->findNodes(xpath, xml_nodes);
if (xml_nodes.size() != 0)
{
if (xml_nodes[0]->getText() == "4")
theSensorID = "Spot 4";
if (xml_nodes[0]->getText() == "4")
theSensorID = "Spot 5";
}
return true;
}
bool ossimSpotDimapSupportData::initMetadataVersion(ossimRefPtr<ossimXmlDocument> xmlDocument)
{
......
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