Commit f90184f0 authored by Guillaume Pasero's avatar Guillaume Pasero

REFAC: add the signature of future functions (implementation is TODO)

parent 001a87a4
Pipeline #4025 passed with stages
in 27 minutes and 7 seconds
......@@ -138,6 +138,14 @@ public:
bool operator==(const Self&) const;
inline bool operator!=(const Self&) const;
/** Read an ImageKeywordlist from a geom file
* without calling ossim */
bool ReadGeometry(const std::string & path);
/** Write an ImageKeywordlist to a geom file
* without calling ossim */
void WriteGeometry(const std::string& filename) const;
protected:
/** Methods invoked by Print() to print information about the object
* Typically not called by the user (use Print()
......@@ -163,6 +171,8 @@ OTBOSSIMAdapters_EXPORT ImageKeywordlist ReadGeometryFromGEOMFile(const std::str
OTBOSSIMAdapters_EXPORT ImageKeywordlist ReadGeometryFromRPCTag(const std::string& filename);
/** Write the content of the ImageKeywordlist into a geom file
* \deprecated : use ImageKeywordlist::WriteGeomtry instead */
OTBOSSIMAdapters_EXPORT void WriteGeometry(const ImageKeywordlist& otb_kwl, const std::string& filename);
inline bool ImageKeywordlist::operator!=(const Self& p) const
......
......@@ -443,5 +443,23 @@ void WriteGeometry(const ImageKeywordlist& otb_kwl, const std::string& filename)
}
}
bool ImageKeywordlist::ReadGeometry(const std::string & path)
{
// The geom files used in OTB are simpler than what OSSIM actually supports
// It is basically a list of 'key: value' lines
// if the value contains special character like \n, \r, or if it has whitespaces
// at the beginning or at the end, the value is enclosed in triple double-quotes
// ("""value""")
// TODO
return false;
}
void ImageKeywordlist::WriteGeometry(const std::string& filename) const
{
// Write the image keyword list if any (without using ossimKeywordlist)
// values in the keywordlist matching the regex '\n|\r| $|^ ' must be
// encapsulated with triple double-quotes (""")
// TODO
}
} // namespace otb
......@@ -209,6 +209,10 @@ public:
void ToKeywordlist(Keywordlist&) const;
std::string ToJSON(bool multiline=false) const;
/** Import metadata from a string keywordlist (will skip
* MDGeom::SensorGeometry) */
bool FromKeywordlist(const Keywordlist&);
};
......
......@@ -211,6 +211,8 @@ void ImageMetadataBase::ToKeywordlist(Keywordlist& kwl) const
{
kwl.clear();
// TODO : Geometry
// The key MDGeom::SensorGeometry should be exported as "<typeinfo>" where
// typeinfo is boost::any::type().name()
for (const auto& kv : StringKeys)
{
kwl.emplace(MetaData::MDStrNames[kv.first], kv.second);
......@@ -258,6 +260,13 @@ std::string ImageMetadataBase::ToJSON(bool multiline) const
return oss.str();
}
bool ImageMetadataBase::FromKeywordlist(const Keywordlist&)
{
// TODO
// skip MDGeom::SensorGeometry (they will be decoded by future SensorModelFactory)
return false;
}
// ----------------------- [ImageMetadata] ------------------------------
......
......@@ -1468,7 +1468,7 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer)
/* -------------------------------------------------------------------- */
if (m_Imd.Has(MDGeom::ProjectionWKT))
{
std::string projectionRef( boost::any_cast<std::string>(m_Imd[MDGeom::ProjectionWKT]));
std::string projectionRef( m_Imd.GetProjectionWKT() );
dataset->SetProjection(projectionRef.c_str());
}
/* -------------------------------------------------------------------- */
......@@ -1809,7 +1809,11 @@ void GDALImageIO::ExportMetadata()
SetMetadataValue("METADATATYPE", "OTB");
SetMetadataValue("OTB_VERSION", OTB_VERSION_STRING );
// TODO: finish implementation
// TODO: finish implementation: filter the keys MDGeom::SensorGeometry that
// will be exported as '<typename>' (boost::any). The (future) SensorModelFactory should
// be used to detect and export properly the field MDGeom::SensorGeometry into a string
// keywordlist. Note that the keys generated for this sensor geometry should
// be prefixed by: MDGeomNames[MDGeom::SensorGeometry] + '.'
ImageMetadataBase::Keywordlist kwl;
m_Imd.ToKeywordlist(kwl);
for (const auto& kv : kwl)
......@@ -1836,8 +1840,11 @@ void GDALImageIO::ExportMetadata()
void GDALImageIO::ImportMetadata()
{
// TODO
// Check special value METADATATYPE=OTB before continue processing
// Keys Starting with: MDGeomNames[MDGeom::SensorGeometry] + '.' should
// be decoded by the (future) SensorModelFactory.
// Use ImageMetadataBase::FromKeywordlist to ingest the metadata
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment