Skip to content
Snippets Groups Projects
Commit f1e74985 authored by Rashad Kanavath's avatar Rashad Kanavath
Browse files

COMP: add GetSensorID(std::string)

parent de92eb6a
No related branches found
No related tags found
No related merge requests found
......@@ -138,10 +138,16 @@ public:
/** Get the ImageKeywordlist */
ImageKeywordlistType GetImageKeywordlist();
const ImageKeywordlistType GetImageKeywordlist() const;
/** This method is less performant and has extra copy.
Please use bool GetSensorID(std::string& ) **/
std::string const GetSensorID() const;
/** Get the sensor ID from the ossim metadata */
std::string GetSensorID() const;
bool GetSensorID(std::string & sensorId) const;
//otbMetadataGetMacro(SensorID, std::string);
/** Get the number of bands from the ossim metadata */
......
......@@ -321,23 +321,34 @@ ImageMetadataInterfaceBase::GetImageKeywordlist() const
return (imageKeywordlist);
}
std::string
std::string const
ImageMetadataInterfaceBase::GetSensorID() const
{
std::string s;
GetSensorID( s );
return s;
}
bool
ImageMetadataInterfaceBase::GetSensorID(std::string & sensorId) const
{
ImageKeywordlistType imageKeywordlist;
const MetaDataDictionaryType& dict = this->GetMetaDataDictionary();
if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey))
if ( dict.HasKey(MetaDataKey::OSSIMKeywordlistKey) )
{
itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist);
}
if (!imageKeywordlist.HasKey("sensor"))
if ( !imageKeywordlist.HasKey("sensor") )
{
return "";
return false;
}
return imageKeywordlist.GetMetadataByKey("sensor");
sensorId = imageKeywordlist.GetMetadataByKey("sensor");
return true;
}
unsigned int
......@@ -567,7 +578,9 @@ ImageMetadataInterfaceBase
//os << indent << "LowerLeftCorner: " << this->GetLowerLeftCorner( ) << std::endl;
//os << indent << "LowerRightCorner:" << this->GetLowerRightCorner( ) << std::endl;
//os << indent << "ImageKeywordlist:" << this->GetImageKeywordlist( ) << std::endl;
os << indent << "SensorID: " << this->GetSensorID( ) << std::endl;
std::string sensorId;
this->GetSensorID( sensorId );
os << indent << "SensorID: " << sensorId << std::endl;
os << indent << "NumberOfBands: " << this->GetNumberOfBands( ) << std::endl;
std::vector<std::string> bandNameList = this->GetBandName();
......
......@@ -58,7 +58,9 @@ int otbImageMetadataInterfaceBaseTest(int itkNotUsed(argc), char* argv[])
file << "GCPId: " << lImageMetadata->GetGCPId(gcpIdx) << std::endl;
file << "GCPInfo: " << lImageMetadata->GetGCPInfo(gcpIdx) << std::endl;
}
file << "SensorID: " << lImageMetadata->GetSensorID( ) << std::endl;
std::string sensorId;
lImageMetadata->GetSensorID( sensorId );
file << "SensorID: " << sensorId << std::endl;
file << "NumberOfBands: " << lImageMetadata->GetNumberOfBands( ) << std::endl;
file << "XPixelSpacing: " << lImageMetadata->GetXPixelSpacing( ) << std::endl;
file << "YPixelSpacing: " << lImageMetadata->GetYPixelSpacing( ) << std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment