Skip to content
Snippets Groups Projects
Commit ffe63041 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ENH : enable writing geom files with streamingImageFileWriter

parent 2efe66c5
Branches
Tags
No related merge requests found
......@@ -169,6 +169,13 @@ public:
/** Type use to define number of divisions */
typedef StreamingMode CalculationDivisionEnumType;
/**
* Enable/disable writing of a .geom file with the ossim keyword list along with the written image
*/
itkSetMacro(WriteGeomFile, bool);
itkGetMacro(WriteGeomFile, bool);
itkBooleanMacro(WriteGeomFile);
protected:
StreamingImageFileWriter();
virtual ~StreamingImageFileWriter();
......@@ -209,8 +216,11 @@ private:
//track whether the region is user specified
bool m_FactorySpecifiedImageIO; //track whether the factory mechanism set the ImageIO
bool m_UseCompression;
bool m_UseInputMetaDataDictionary; // whether to use the MetaDataDictionary from the input or not.
bool m_UseInputMetaDataDictionary; // whether to use the
// MetaDataDictionary from the
// input or not.
bool m_WriteGeomFile; // Write a geom file to store the kwl
};
} // end namespace otb
......
......@@ -46,7 +46,7 @@ namespace otb
*/
template <class TInputImage>
StreamingImageFileWriter<TInputImage>
::StreamingImageFileWriter()
::StreamingImageFileWriter():m_WriteGeomFile(false)
{
m_BufferMemorySize = 0;
m_BufferNumberOfLinesDivisions = 0;
......@@ -624,6 +624,25 @@ StreamingImageFileWriter<TInputImage>
const void* dataPtr = (const void*) input->GetBufferPointer();
m_ImageIO->Write(dataPtr);
if (m_WriteGeomFile)
{
// Write the image keyword list if any
ossimKeywordlist geom_kwl;
ImageKeywordlist otb_kwl;
itk::MetaDataDictionary dict = input->GetMetaDataDictionary();
itk::ExposeMetaData<ImageKeywordlist>(dict, MetaDataKey::OSSIMKeywordlistKey, otb_kwl);
otb_kwl.convertToOSSIMKeywordlist(geom_kwl);
if (geom_kwl.getSize() > 0)
{
otbMsgDevMacro(<< "Exporting keywordlist ...");
ossimFilename geomFileName(this->GetFileName());
geomFileName.setExtension(".geom");
geom_kwl.write(geomFileName.chars());
}
}
}
} // end namespace otb
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment