OTB  9.0.0
Orfeo Toolbox
otbImageMetadataInterfaceBase.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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 otbImageMetadataInterfaceBase_h
22 #define otbImageMetadataInterfaceBase_h
23 
24 #include <string>
25 
26 #include "itkMetaDataDictionary.h"
27 #include "otbMetaDataKey.h"
28 #include "itkImageBase.h"
29 #include "otbImageMetadata.h"
31 
32 #include "OTBMetadataExport.h"
33 
34 namespace otb
35 {
36 
44 class OTBMetadata_EXPORT ImageMetadataInterfaceBase : public itk::Object
45 {
46 public:
48  typedef itk::Object Superclass;
49  typedef itk::SmartPointer<Self> Pointer;
50  typedef itk::SmartPointer<const Self> ConstPointer;
51 
53  itkTypeMacro(ImageMetadataInterfaceBase, itk::Object);
54 
55  typedef itk::ImageBase<2> ImageType;
56  typedef itk::MetaDataDictionary MetaDataDictionaryType;
59  typedef unsigned int UnsignedIntType;
60  typedef std::vector<std::string> StringVectorType;
61  typedef std::vector<unsigned int> UIntVectorType;
62 
63 
65  void SetImage(ImageType* image);
66 
68  void SetMetaDataDictionary(const MetaDataDictionaryType& dict);
69 
71  const MetaDataDictionaryType& GetMetaDataDictionary() const;
72 
74  void SetMetadataSupplierInterface(const MetadataSupplierInterface&);
75 
77  std::string GetProjectionRef() const;
78 
80  std::string GetGCPProjection() const;
81  // otbMetadataGetMacro(GCPProjection, std::string);
83 
84  UnsignedIntType GetGCPCount() const;
85  // otbMetadataGetMacro(GCPCount, unsigned int);
86 
87  GCP& GetGCPs(unsigned int GCPnum);
88  // otbMetadataGetGCPnumMacro(GCPs, GCP&, GCPnum, unsigned int);
89 
90  std::string GetGCPId(unsigned int GCPnum) const;
91  // otbMetadataGetGCPnumMacro(GCPId, std::string, GCPnum, unsigned int);
92 
93  std::string GetGCPInfo(unsigned int GCPnum) const;
94  // otbMetadataGetGCPnumMacro(GCPInfo, std::string, GCPnum, unsigned int);
95 
96  double GetGCPRow(unsigned int GCPnum) const;
97  // otbMetadataGetGCPnumMacro(GCPRow, double, GCPnum, unsigned int);
98 
99  double GetGCPCol(unsigned int GCPnum) const;
100  // otbMetadataGetGCPnumMacro(GCPCol, double, GCPnum, unsigned int);
101 
102  double GetGCPX(unsigned int GCPnum) const;
103  // otbMetadataGetGCPnumMacro(GCPX, double, GCPnum, unsigned int);
104 
105  double GetGCPY(unsigned int GCPnum) const;
106  // otbMetadataGetGCPnumMacro(GCPY, double, GCPnum, unsigned int);
107 
108  double GetGCPZ(unsigned int GCPnum) const;
109  // otbMetadataGetGCPnumMacro(GCPZ, double, GCPnum, unsigned int);
110 
113  VectorType GetGeoTransform() const;
114  // otbMetadataGetMacro(GeoTransform, VectorType);
115 
118  VectorType GetUpperLeftCorner() const;
119  // otbMetadataGetMacro(UpperLeftCorner, VectorType);
120 
121  VectorType GetUpperRightCorner() const;
122  // otbMetadataGetMacro(UpperRightCorner, VectorType);
123 
124  VectorType GetLowerLeftCorner() const;
125  // otbMetadataGetMacro(LowerLeftCorner, VectorType);
126 
127  VectorType GetLowerRightCorner() const;
128  // otbMetadataGetMacro(LowerRightCorner, VectorType);
129 
133  virtual void Parse(ImageMetadata &)
134  {
135  otbGenericExceptionMacro(MissingMetadataException,<<"Metadata parsing not implemented")
136  }
137 
138  const std::string& Fetch(MDStr key, ImageMetadata & imd, const char *path, int band=-1);
139  bool CheckFetch(MDStr key, ImageMetadata & imd, const char *path, int band=-1);
140 
141  const double& Fetch(MDNum key, ImageMetadata & imd, const char *path, int band=-1);
142  bool CheckFetch(MDNum key, ImageMetadata & imd, const char *path, int band=-1);
143 
144  const MetaData::TimePoint& Fetch(MDTime key, ImageMetadata & imd, const char *path, int band=-1);
145  bool CheckFetch(MDTime key, ImageMetadata & imd, const char *path, int band=-1);
146 
147  const std::string& Fetch(std::string key, ImageMetadata & imd, const char *path, int band=-1);
148  bool CheckFetch(std::string key, ImageMetadata & imd, const char *path, int band=-1);
149 
150  const boost::any& FetchRPC(ImageMetadata& imd, const double lineOffset = 0.0, const double sampleOffset = 0.0);
151 
152 protected:
153  ImageMetadataInterfaceBase() = default;
154  ~ImageMetadataInterfaceBase() override = default;
155 
156  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
157 
159 
160  const MetadataSupplierInterface * m_MetadataSupplierInterface = nullptr;
161 
162 private:
163  ImageMetadataInterfaceBase(const Self&) = delete;
164  void operator=(const Self&) = delete;
165 
167 };
168 
169 } // end namespace otb
170 
171 #endif
otb::MDStr
MDStr
Definition: otbMetaDataKey.h:168
otb::MDNum
MDNum
Definition: otbMetaDataKey.h:125
otb::ImageMetadataInterfaceBase::m_MetaDataDictionary
MetaDataDictionaryType m_MetaDataDictionary
Definition: otbImageMetadataInterfaceBase.h:158
otb::ImageMetadataInterfaceBase::m_GCP
GCP m_GCP
Definition: otbImageMetadataInterfaceBase.h:166
otb::ImageMetadataInterfaceBase::StringVectorType
std::vector< std::string > StringVectorType
Definition: otbImageMetadataInterfaceBase.h:60
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::MDTime
MDTime
Definition: otbMetaDataKey.h:207
otb::MetaDataKey::VectorType
std::vector< double > VectorType
Definition: otbMetaDataKey.h:119
otb::MetaDataKey::VariableLengthVectorType
itk::VariableLengthVector< double > VariableLengthVectorType
Definition: otbMetaDataKey.h:121
otb::ImageMetadataInterfaceBase::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbImageMetadataInterfaceBase.h:49
otb::ImageMetadataInterfaceBase::Parse
virtual void Parse(ImageMetadata &)
Definition: otbImageMetadataInterfaceBase.h:133
otb::MetadataSupplierInterface
Base class to access metadata information in files/images.
Definition: otbMetadataSupplierInterface.h:40
otb::ImageMetadataInterfaceBase::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbImageMetadataInterfaceBase.h:50
otbGenericExceptionMacro
#define otbGenericExceptionMacro(T, x)
Definition: otbMacro.h:144
otb::ImageMetadataInterfaceBase::VariableLengthVectorType
MetaDataKey::VariableLengthVectorType VariableLengthVectorType
Definition: otbImageMetadataInterfaceBase.h:58
otb::ImageMetadataInterfaceBase::MetaDataDictionaryType
itk::MetaDataDictionary MetaDataDictionaryType
Definition: otbImageMetadataInterfaceBase.h:56
otb::ImageMetadataInterfaceBase::Self
ImageMetadataInterfaceBase Self
Definition: otbImageMetadataInterfaceBase.h:47
otbMetaDataKey.h
otbMetadataSupplierInterface.h
otb::MissingMetadataException
Exception to be used when metadata parsing fails.
Definition: otbMissingMetadataException.h:36
otb::ImageMetadataInterfaceBase::VectorType
MetaDataKey::VectorType VectorType
Definition: otbImageMetadataInterfaceBase.h:57
otb::ImageMetadataInterfaceBase
Base class for captor metadata reading.
Definition: otbImageMetadataInterfaceBase.h:44
otb::ImageMetadata
Generic class containing image metadata used in OTB.
Definition: otbImageMetadata.h:270
otb::MetaData::TimePoint
Represents a point in Time.
Definition: otbDateTime.h:94
otb::ImageMetadataInterfaceBase::UnsignedIntType
unsigned int UnsignedIntType
Definition: otbImageMetadataInterfaceBase.h:59
otbImageMetadata.h
otb::ImageMetadataInterfaceBase::Superclass
itk::Object Superclass
Definition: otbImageMetadataInterfaceBase.h:48
otb::ImageMetadataInterfaceBase::ImageType
itk::ImageBase< 2 > ImageType
Definition: otbImageMetadataInterfaceBase.h:53
otb::GCP
This GCP class is used to manage the GCP parameters in OTB.
Definition: otbGeometryMetadata.h:43
otb::ImageMetadataInterfaceBase::UIntVectorType
std::vector< unsigned int > UIntVectorType
Definition: otbImageMetadataInterfaceBase.h:61