Skip to content
Snippets Groups Projects
Commit 51948828 authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

ENH: correct transmission of the depth parameter from the io to the kwl

parent 8f75c347
Branches
Tags
No related merge requests found
......@@ -17,6 +17,7 @@
=========================================================================*/
#ifndef __otbImageFileReader_txx
#define __otbImageFileReader_txx
#include "otbImageFileReader.h"
#include "itkMetaDataObject.h"
......@@ -28,6 +29,7 @@
#include "otbMetaDataKey.h"
#include "otbGDALImageIO.h" //FIXME find a better way
#include "otbTileMapImageIO.h"
#include <itksys/SystemTools.hxx>
#include <fstream>
......@@ -364,8 +366,18 @@ ImageFileReader<TOutputImage>
// Update otb Keywordlist
ImageKeywordlist otb_kwl = ReadGeometry(lFileNameOssimKeywordlist);
// Update itk MetaData Dictionary
// Pass the depth parameter from the tilemap around
if (strcmp(this->m_ImageIO->GetNameOfClass(), "TileMapImageIO") == 0)
{
typename TileMapImageIO::Pointer imageIO = dynamic_cast<TileMapImageIO*>(this->GetImageIO());
std::ostringstream depth;
depth << imageIO->GetDepth();
otb_kwl.AddKey("depth", depth.str());
}
otbMsgDevMacro(<< otb_kwl);
// Update itk MetaData Dictionary
itk::MetaDataDictionary& dict = this->m_ImageIO->GetMetaDataDictionary();
// Don't add an empty ossim keyword list
......
......@@ -94,6 +94,13 @@ ClearMetadataByKey(const std::string& key)
m_Keywordlist[key] = "";
}
void
ImageKeywordlist::
AddKey(const std::string& key, const std::string& value)
{
m_Keywordlist[key] = value;
}
void
ImageKeywordlist::
convertToOSSIMKeywordlist(ossimKeywordlist& kwl) const
......@@ -156,6 +163,7 @@ ReadGeometry(const std::string& filename)
else
{
otbMsgDevMacro(<< "OSSIM Instantiate projection SUCCESS ! ");
hasMetaData = projection->saveState(geom_kwl);
// Free memory
......@@ -182,20 +190,6 @@ ReadGeometry(const std::string& filename)
if (projection)
{
// FIXME Temporarily deactivated
/* if (projection->getClassName() == "ossimTileMapModel")
{
//we need to pass the depth information which in on the IO to the projection
//to be handle throught the kwl
TileMapImageIO::Pointer imageIO = TileMapImageIO::New();
imageIO->SetFileName(filename);
// if we are here, we instanciated an ossimTileMapModel, so we should
// be able to create a TileMapImageIO
assert(!imageIO->CanReadFile(filename.c_str()));
imageIO->ReadImageInformation();
int depth = imageIO->GetDepth();
dynamic_cast<ossimplugins::ossimTileMapModel*>(projection)->setDepth(depth);
}*/
hasMetaData = projection->saveState(geom_kwl);
}
}
......
......@@ -77,6 +77,8 @@ public:
/** Clear a given field of the keyword list */
virtual void ClearMetadataByKey(const std::string& key);
virtual void AddKey(const std::string& key, const std::string& value);
virtual void convertToOSSIMKeywordlist(ossimKeywordlist& kwl) const;
virtual void Print(std::ostream& os, itk::Indent indent = 0) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment