Skip to content
Snippets Groups Projects
Commit ecd9e4c9 authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Exporting ossim keywordlist to .geom file

parent 1cdb467f
Branches
Tags
No related merge requests found
......@@ -24,6 +24,16 @@
#include "itkObjectFactoryBase.h"
#include "vnl/vnl_vector.h"
#include "imaging/ossimImageHandlerRegistry.h"
#include "ossim/imaging/ossimImageHandlerSarFactory.h"
#include "imaging/ossimImageHandler.h"
#include "init/ossimInit.h"
#include "base/ossimKeywordlist.h"
#include "itkMetaDataObject.h"
#include "otbImageKeywordlist.h"
#include "otbMetaDataKey.h"
#include "otbMacro.h"
namespace otb
......@@ -76,6 +86,30 @@ ImageFileWriter<TInputImage>
//TODO: Force ImageIO desctructor. Should be fixed once GDALImageIO
//will be refactored.
this->SetImageIO(NULL);
// Write the image keyword list if any
ossimKeywordlist geom_kwl;
ImageKeywordlist otb_kwl;
itk::MetaDataDictionary dict = this->GetInput()->GetMetaDataDictionary();
itk::ExposeMetaData<ImageKeywordlist>(dict, MetaDataKey::OSSIMKeywordlistKey, otb_kwl);
otb_kwl.convertToOSSIMKeywordlist(geom_kwl);
if(geom_kwl.getSize()>0)
{
otbMsgDevMacro(<<"Exporting keywordlist ...");
ossimImageHandlerRegistry::instance()->addFactory(ossimImageHandlerSarFactory::instance());
ossimImageHandler* handler = ossimImageHandlerRegistry::instance()->open(ossimFilename(this->GetFileName()));
if(!handler)
{
otbMsgDevMacro(<<"OSSIM Open Image FAILED !");
}
handler->setImageGeometry(geom_kwl);
handler->saveImageGeometry();
handler->close();
}
}
/**
......
......@@ -26,6 +26,16 @@
#include "itkImageRegionMultidimensionalSplitter.h"
#include "otbImageIOFactory.h"
#include "imaging/ossimImageHandlerRegistry.h"
#include "ossim/imaging/ossimImageHandlerSarFactory.h"
#include "imaging/ossimImageHandler.h"
#include "init/ossimInit.h"
#include "base/ossimKeywordlist.h"
#include "itkMetaDataObject.h"
#include "otbImageKeywordlist.h"
#include "otbMetaDataKey.h"
#include "otbConfigure.h"
namespace otb
......@@ -521,6 +531,29 @@ StreamingImageFileWriter<TInputImage>
this->GetOutput(idx)->DataHasBeenGenerated();
}
}
// Write the image keyword list if any
ossimKeywordlist geom_kwl;
ImageKeywordlist otb_kwl;
itk::MetaDataDictionary dict = this->GetInput()->GetMetaDataDictionary();
itk::ExposeMetaData<ImageKeywordlist>(dict, MetaDataKey::OSSIMKeywordlistKey, otb_kwl);
otb_kwl.convertToOSSIMKeywordlist(geom_kwl);
if(geom_kwl.getSize()>0)
{
otbMsgDevMacro(<<"Exporting keywordlist ...");
ossimImageHandlerRegistry::instance()->addFactory(ossimImageHandlerSarFactory::instance());
ossimImageHandler* handler = ossimImageHandlerRegistry::instance()->open(ossimFilename(this->GetFileName()));
if(!handler)
{
otbMsgDevMacro(<<"OSSIM Open Image FAILED !");
}
handler->setImageGeometry(geom_kwl);
handler->saveImageGeometry();
handler->close();
}
/**
* Release any inputs if marked for release
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment