Skip to content
Snippets Groups Projects
Commit 8f755e1f authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

BUG: #1507: rework the priority order in metadata loading

parent 3726a2fc
No related branches found
No related tags found
1 merge request!13Resolve "Inconsistent behaviour of geom file loading"
...@@ -287,60 +287,15 @@ ReadGeometryFromImage(const std::string& filename, bool checkRpcTag) ...@@ -287,60 +287,15 @@ ReadGeometryFromImage(const std::string& filename, bool checkRpcTag)
} }
/**********************************************************/ /**********************************************************/
/* Third try : look for external geom file and RPC tags */ /* Third try : look for RPC tags */
/**********************************************************/ /**********************************************************/
if (!hasMetaData) if (!hasMetaData && checkRpcTag)
{ {
// If still no metadata, try the ".geom" file // check any RPC tags
  • Reporter

    Good to see that this also results in more code being removed than added ;)

  • Author Owner

    Yes, it was intended for cases where metadata was partially read from geom file, and the RPC coeff were read from TIF.

  • Please register or sign in to reply
ossimFilename ossimGeomFile = ossimFilename(filename).setExtension(".geom"); otb_kwl = ReadGeometryFromRPCTag(filename);
otb_kwl = ReadGeometryFromGEOMFile(ossimGeomFile);
// also check any RPC tags
ImageKeywordlist rpc_kwl;
if (checkRpcTag)
{
rpc_kwl = ReadGeometryFromRPCTag(filename);
}
if (otb_kwl.HasKey("type"))
{
// external geom has a "type" keyword
std::string geomType(otb_kwl.GetMetadataByKey("type"));
ossimProjection *testProj = ossimProjectionFactoryRegistry::instance()
->createProjection(ossimString(geomType));
if (dynamic_cast<ossimSensorModel*>(testProj))
{
// "type" keyword corresponds to a sensor model : don't erase it
if (rpc_kwl.GetSize() > 0)
{
rpc_kwl.ClearMetadataByKey("type");
}
ossimKeywordlist ossim_test_kwl;
otb_kwl.convertToOSSIMKeywordlist(ossim_test_kwl);
testProj = ossimProjectionFactoryRegistry::instance()
->createProjection(ossim_test_kwl);
if (testProj)
{
// external geom contains a valid sensor geometry
hasMetaData = true;
}
}
}
// copy keywords found in RPC tags if the external geom is not valid if (!otb_kwl.Empty())
if (!hasMetaData && rpc_kwl.GetSize() > 0)
{ {
const ImageKeywordlist::KeywordlistMap &kwlMap = rpc_kwl.GetKeywordlist();
for (ImageKeywordlist::KeywordlistMap::const_iterator it = kwlMap.begin();
it != kwlMap.end();
++it)
{
if (it->second != "")
{
otb_kwl.AddKey(it->first , it->second);
}
}
hasMetaData = true; hasMetaData = true;
} }
} }
......
...@@ -398,18 +398,33 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> ...@@ -398,18 +398,33 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
{ {
std::string lFileNameOssimKeywordlist = GetDerivedDatasetSourceFileName(m_FileName); std::string lFileNameOssimKeywordlist = GetDerivedDatasetSourceFileName(m_FileName);
std::string extension = itksys::SystemTools::GetFilenameLastExtension(lFileNameOssimKeywordlist);
std::string attachedGeom = lFileNameOssimKeywordlist.substr(
0,
lFileNameOssimKeywordlist.size() - extension.size()) + std::string(".geom");
// Update otb Keywordlist // Update otb Keywordlist
ImageKeywordlist otb_kwl; ImageKeywordlist otb_kwl;
if (!m_FilenameHelper->ExtGEOMFileNameIsSet())
// Case 1: external geom supplied through extended filename
if (m_FilenameHelper->ExtGEOMFileNameIsSet())
{ {
otb_kwl = ReadGeometryFromImage(lFileNameOssimKeywordlist,!m_FilenameHelper->GetSkipRpcTag()); otb_kwl = ReadGeometryFromGEOMFile(m_FilenameHelper->GetExtGEOMFileName());
otbMsgDevMacro(<< "Loading internal kwl"); otbMsgDevMacro(<< "Loading external kwl");
  • Reporter

    Can you make the MsdDevMacro call more explicit, by including path to geom files or explicit name of the read geom function ?

  • Author Owner

    Done

  • Please register or sign in to reply
} }
// Case 2: attached geom (if present)
else if (itksys::SystemTools::FileExists(attachedGeom))
{
otb_kwl = ReadGeometryFromGEOMFile(attachedGeom);
otbMsgDevMacro(<< "Loading attached kwl");
}
// Case 3: find an ossimPluginProjection
// Case 4: find an ossimProjection
// Case 5: find RPC tags in TIF
else else
{ {
otb_kwl = ReadGeometryFromGEOMFile(m_FilenameHelper->GetExtGEOMFileName()); otb_kwl = ReadGeometryFromImage(lFileNameOssimKeywordlist,!m_FilenameHelper->GetSkipRpcTag());
otbMsgDevMacro(<< "Loading external kwl"); otbMsgDevMacro(<< "Loading internal kwl");
} }
// Don't add an empty ossim keyword list // Don't add an empty ossim keyword list
......
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