Skip to content
Snippets Groups Projects
Commit 57325eb7 authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

ENH: ossim, retrieve more information from Ikonos

parent a6c93bb7
Branches
Tags
No related merge requests found
......@@ -59,6 +59,7 @@ public:
ossim_float64 theSunAzimuth;
ossim_float64 theSunElevation;
ossim_uint32 theNumBands;
ossimString theBandName;
ossimString theProductionDate;
......
......@@ -882,6 +882,36 @@ bool ossimIkonosRpcModel::parseTiffFile(const ossimFilename& filename)
theSupportData = new ossimIkonosMetaData(filename);
//NB: Parsing the metadata file at this level is useful to
// retrieve the sensor name.
//retrieve information from the metadata file
//if the ikonos tif is po_2619900_pan_0000000.tif
//the metadata file will be po_2619900_metadata.txt
std::cout << "Parsing metadata..." << std::endl;
ossimString separator("_");
ossimString filenamebase = filename.noExtension();
std::vector< ossimString > filenameparts = filenamebase.split(separator);
if(filenameparts.size() < 2)
{
ossimNotify(ossimNotifyLevel_DEBUG)
<< "DEBUG ossimIkonosRpcModel parseTiffFile: Ikonos filename non standard" << std::endl;
}
ossimFilename metadatafile = filenameparts[0];
metadatafile += "_";
metadatafile += filenameparts[1];
metadatafile += "_metadata.txt";
parseMetaData (metadatafile);
if (getErrorStatus()) //check for errors in parsing metadata file
{
ossimNotify(ossimNotifyLevel_DEBUG)
<< "DEBUG ossimIkonosRpcModel parseTiffFile: errors parsing metadata" << std::endl;
//failed to read metadata, but don't abord here.
}
//convert file to rpc filename and hdr filename so we can get some info
......
......@@ -29,6 +29,7 @@ ossimIkonosMetaData::ossimIkonosMetaData()
:
theSunAzimuth(0.0),
theSunElevation(0.0),
theNumBands(0),
theBandName("Unknown"),
theProductionDate("Unknown")
{
......@@ -38,6 +39,7 @@ ossimIkonosMetaData::ossimIkonosMetaData(const ossimFilename& imageFilename)
:
theSunAzimuth(0.0),
theSunElevation(0.0),
theNumBands(0),
theBandName ("Unknown"),
theProductionDate("Unknown")
{
......@@ -89,7 +91,9 @@ ossimIkonosMetaData::ossimIkonosMetaData(const ossimFilename& metadataFile, cons
:
theSunAzimuth(0.0),
theSunElevation(0.0),
theBandName ("Unknown")
theNumBands(0),
theBandName("Unknown"),
theProductionDate("Unknown")
{
parseMetaData(metadataFile);
parseHdrData(hdrFile);
......@@ -105,7 +109,9 @@ void ossimIkonosMetaData::clearFields()
clearErrorStatus();
theSunAzimuth = 0.0;
theSunElevation = 0.0;
theNumBands = 0;
theBandName = "Unknown";
theProductionDate = "Unknown";
}
void ossimIkonosMetaData::printInfo(ostream& os) const
......@@ -115,6 +121,9 @@ void ossimIkonosMetaData::printInfo(ostream& os) const
<< "\n "
<< "\n Sun Azimuth: " << theSunAzimuth
<< "\n Sun Elevation: " << theSunElevation
<< "\n Number of bands: " << theNumBands
<< "\n Band name: " << theBandName
<< "\n Production date: " << theProductionDate
<< "\n"
<< "\n---------------------------------------------------------"
<< "\n " << std::endl;
......@@ -139,6 +148,11 @@ bool ossimIkonosMetaData::saveState(ossimKeywordlist& kwl,
theSunElevation,
true);
kwl.add(prefix,
ossimKeywordNames::NUMBER_BANDS_KW,
theNumBands,
true);
kwl.add(prefix,
"band_name",
theBandName,
......@@ -164,8 +178,11 @@ bool ossimIkonosMetaData::loadState(const ossimKeywordlist& kwl,
return false;
}
theSunAzimuth = ossimString(kwl.find(prefix, ossimKeywordNames::AZIMUTH_ANGLE_KW)).toDouble();
theSunElevation = ossimString(kwl.find(prefix, ossimKeywordNames::ELEVATION_ANGLE_KW)).toDouble();
theSunAzimuth = ossimString(kwl.find(prefix, ossimKeywordNames::AZIMUTH_ANGLE_KW)).toDouble();
theSunElevation = ossimString(kwl.find(prefix, ossimKeywordNames::ELEVATION_ANGLE_KW)).toDouble();
theNumBands = ossimString(kwl.find(prefix, ossimKeywordNames::NUMBER_BANDS_KW)).toUInt32();
theBandName = ossimString(kwl.find(prefix, "band_name")).toDouble();
theProductionDate = ossimString(kwl.find(prefix, "production_date")).toDouble();
return true;
}
......@@ -315,6 +332,7 @@ bool ossimIkonosMetaData::parseHdrData(const ossimFilename& data_file)
// char linebuf[80];
char dummy[80];
char name[80];
int value=0;
//***
// Read the file into a buffer:
......@@ -343,6 +361,26 @@ bool ossimIkonosMetaData::parseHdrData(const ossimFilename& data_file)
sscanf(strptr, "%6c %s", dummy, name);
theBandName = name;
//***
// Number of Bands:
//***
strptr = strstr(filebuf, "\nNumber of Bands:");
if (!strptr)
{
if(traceDebug())
{
ossimNotify(ossimNotifyLevel_WARN)
<< "ossimIkonosRpcModel::parseHdrData(data_file):"
<< "\n\tAborting construction. Error encountered parsing "
<< "presumed hdr file." << endl;
}
return false;
}
sscanf(strptr, "%17c %d", dummy, &value);
theNumBands = value;
if (traceExec())
{
ossimNotify(ossimNotifyLevel_DEBUG)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment