Skip to content
Snippets Groups Projects
Commit 3e5d4614 authored by Manuel Grizonnet's avatar Manuel Grizonnet
Browse files

ENH:add pixel descriptionin viewer in progress

parent 584199bf
No related branches found
No related tags found
No related merge requests found
......@@ -420,6 +420,35 @@ ImageMetadataInterfaceBase::GetBandName( const MetaDataDictionaryType & dict ) c
return outputValues;
}
double ImageMetadataInterfaceBase::GetXPixelSpacing( const MetaDataDictionaryType & dict ) const
{
ImageKeywordlistType ImageKeywordlist;
if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey))
{
itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, ImageKeywordlist);
}
ossimKeywordlist kwl;
ImageKeywordlist.convertToOSSIMKeywordlist(kwl);
std::string key= "support_data.x_pixel_spacing";
ossimString keywordString = kwl.find(key.c_str());
return keywordString.toDouble();
}
double ImageMetadataInterfaceBase::GetYPixelSpacing( const MetaDataDictionaryType & dict ) const
{
ImageKeywordlistType ImageKeywordlist;
if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey))
{
itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, ImageKeywordlist);
}
ossimKeywordlist kwl;
ImageKeywordlist.convertToOSSIMKeywordlist(kwl);
std::string key= "support_data.y_pixel_spacing";
ossimString keywordString = kwl.find(key.c_str());
return keywordString.toDouble();
}
void
ImageMetadataInterfaceBase::PrintSelf(std::ostream& os, itk::Indent indent, const MetaDataDictionaryType & dict) const
......
......@@ -202,6 +202,14 @@ public:
virtual VariableLengthVectorType GetLastWavelengths( const MetaDataDictionaryType & dict ) const =0;
otbMetadataGetMacro(LastWavelengths, VariableLengthVectorType);
/** Get the x resolution */
double GetXPixelSpacing( const MetaDataDictionaryType & dict ) const;
otbMetadataGetMacro(XPixelSpacing, double);
/** Get the y resolution */
double GetYPixelSpacing( const MetaDataDictionaryType & dict ) const;
otbMetadataGetMacro(YPixelSpacing, double);
virtual bool CanRead( const MetaDataDictionaryType & dict ) const =0;
virtual void PrintSelf(std::ostream& os, itk::Indent indent, const MetaDataDictionaryType & dict) const;
......
......@@ -26,6 +26,7 @@
#include "otbImageKeywordlist.h"
// #include "otbCoordinateToName.h"
#include "otbImageMetadataInterfaceBase.h"
namespace otb
{
......@@ -300,6 +301,30 @@ ImageLayer<TImage,TOutputImage>
oss << otbGetTextMacro("Location unknown") << std::endl;
}
}
/** Metadatas typedef */
typedef typename ImageMetadataInterfaceBase ImageMetadataInterfaceType;
typedef typename ImageMetadataInterfaceBase::Pointer ImageMetadataInterfacePointerType;
// Build the metadata interface
ImageMetadataInterfacePointerType lImageMetadata = ImageMetadataInterfaceType::New();
// Check availability
bool mdIsAvailable = lImageMetadata->CanRead(m_Image->GetMetaDataDictionary());
if (mdIsAvailable)
{
double x_spacing = lImageMetadata->GetXPixelSpacing(m_Image->GetMetaDataDictionary());
double y_spacing = lImageMetadata->GetYPixelSpacing(m_Image->GetMetaDataDictionary());
oss<< "x res: " << x_spacing << std::endl;
oss<< "y res: " << y_spacing << std::endl;
}
else
{
oss << otbGetTextMacro("Resolution unknown") << std::endl;
}
return oss.str();
}
......
......@@ -14,7 +14,6 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
// this file defines the otbMultiScaleTest for the test driver
// and all it expects is that you have a function called RegisterTests
#if defined(_MSC_VER)
......
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