OTB  7.2.0
Orfeo Toolbox
otbImageKeywordlist.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2020 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbImageKeywordlist_h
22 #define otbImageKeywordlist_h
23 
24 #include <map>
25 
26 #include "gdal.h"
27 
28 #include "itkObject.h"
29 #include "itkObjectFactory.h"
30 
31 #include "OTBOSSIMAdaptersExport.h"
32 
33 // forward declaration
34 class ossimKeywordlist;
35 
36 namespace otb
37 {
38 
39 namespace internal
40 {
48 inline double ConvertToOSSIMFrame(double val)
49 {
50  return (val - 0.5);
51 }
52 
60 inline double ConvertFromOSSIMFrame(double val)
61 {
62  return (val + 0.5);
63 }
64 
65 } // namespace internal
66 
78 class OTBOSSIMAdapters_EXPORT ImageKeywordlist
79 {
80 public:
83 
84  // virtual const char *GetNameOfClass() const
85  //{return "ImageKeywordlist"; }
86 
87  typedef std::map<std::string, std::string> KeywordlistMap;
88  typedef KeywordlistMap::size_type KeywordlistMapSizeType;
89 
91  const KeywordlistMap& GetKeywordlist() const
92  {
93  return m_Keywordlist;
94  }
95 
96  void SetKeywordlist(const ossimKeywordlist& kwl);
97 
98  void Clear(void)
99  {
100  m_Keywordlist.clear();
101  }
102 
103  KeywordlistMapSizeType Empty() const
104  {
105  return m_Keywordlist.empty();
106  }
107 
108  KeywordlistMapSizeType GetSize(void) const
109  {
110  return m_Keywordlist.size();
111  }
112 
114  const std::string& GetMetadataByKey(const std::string& key) const;
115 
117  bool HasKey(const std::string& key) const;
118 
120  virtual void ClearMetadataByKey(const std::string& key);
121 
122  virtual void AddKey(const std::string& key, const std::string& value);
123 
124  virtual void convertToOSSIMKeywordlist(ossimKeywordlist& kwl) const;
125 
128  virtual bool convertToGDALRPC(GDALRPCInfo& rpc) const;
129 
130  virtual void Print(std::ostream& os, itk::Indent indent = 0) const;
131 
133  virtual ~ImageKeywordlist();
134 
135  ImageKeywordlist(const Self&);
136  void operator=(const Self&);
137 
138  bool operator==(const Self&) const;
139  inline bool operator!=(const Self&) const;
140 
141 protected:
146  virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
147 
148 private:
150  KeywordlistMap m_Keywordlist;
151 
152  // char m_Delimiter;
153 
154  // void operator=(const Self&) = delete;
155 };
156 
157 OTBOSSIMAdapters_EXPORT std::ostream& operator<<(std::ostream& os, const ImageKeywordlist& kwl);
158 
159 // Free function to handle the keywordlist <-> files
160 OTBOSSIMAdapters_EXPORT ImageKeywordlist ReadGeometryFromImage(const std::string& filename, bool checkRpcTag = true);
161 
162 OTBOSSIMAdapters_EXPORT ImageKeywordlist ReadGeometryFromGEOMFile(const std::string& filename);
163 
164 OTBOSSIMAdapters_EXPORT ImageKeywordlist ReadGeometryFromRPCTag(const std::string& filename);
165 
166 OTBOSSIMAdapters_EXPORT void WriteGeometry(const ImageKeywordlist& otb_kwl, const std::string& filename);
167 
168 inline bool ImageKeywordlist::operator!=(const Self& p) const
169 {
170  return !this->operator==(p);
171 }
172 
173 } // namespace otb
174 
175 #endif // otbImageKeywordlist_h
OTBCommon_EXPORT std::ostream & operator<<(std::ostream &os, const otb::StringToHTML &str)
Storage and conversion for OSSIM metadata.
OTBGdalAdapters_EXPORT bool operator==(const CoordinateTransformation &ct1, const CoordinateTransformation &ct2) noexcept
equal operator
double ConvertFromOSSIMFrame(double val)
OTBOSSIMAdapters_EXPORT ImageKeywordlist ReadGeometryFromImage(const std::string &filename, bool checkRpcTag=true)
const KeywordlistMap & GetKeywordlist() const
bool operator!=(const Self &) const
OTBOSSIMAdapters_EXPORT ImageKeywordlist ReadGeometryFromRPCTag(const std::string &filename)
KeywordlistMapSizeType GetSize(void) const
double ConvertToOSSIMFrame(double val)
KeywordlistMap::size_type KeywordlistMapSizeType
KeywordlistMapSizeType Empty() const
OTBGdalAdapters_EXPORT bool operator!=(const CoordinateTransformation &ct1, const CoordinateTransformation &ct2) noexcept
different operator
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
std::map< std::string, std::string > KeywordlistMap
static constexpr GLenum value() noexcept
OTBOSSIMAdapters_EXPORT ImageKeywordlist ReadGeometryFromGEOMFile(const std::string &filename)
OTBOSSIMAdapters_EXPORT void WriteGeometry(const ImageKeywordlist &otb_kwl, const std::string &filename)