diff --git a/Code/IO/otbStreamingImageFileWriter.h b/Code/IO/otbStreamingImageFileWriter.h index 72e493ee315e6803f014f82f01a0b610378bc373..88b9d473225565f15742bb9d7b282360eae169a6 100644 --- a/Code/IO/otbStreamingImageFileWriter.h +++ b/Code/IO/otbStreamingImageFileWriter.h @@ -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 diff --git a/Code/IO/otbStreamingImageFileWriter.txx b/Code/IO/otbStreamingImageFileWriter.txx index 8c1c6ae5af73285157c96dcb59120e16525f6abb..3fa74288fcb90685168e5fd9138e33d17d0cc1f8 100644 --- a/Code/IO/otbStreamingImageFileWriter.txx +++ b/Code/IO/otbStreamingImageFileWriter.txx @@ -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