otbImageKeywordlist.h 4.26 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.


13
14
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
16
17
18
19
20
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __otbImageKeywordlist_h
#define __otbImageKeywordlist_h

21
#include <iostream>
22
#include <map>
23

24
25
#include "gdal.h"

26
#include "itkObject.h"
27
#include "itkObjectFactory.h"
28
29
30

//forward declaration
class ossimKeywordlist;
31
32
33
34

namespace otb
{

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
namespace internal
{
  /**
   * Converts index coordinates from OTB into OSSIM. It is intended for sensor
   * images where the centre of the top-left pixel is expected to be :
   *   [0.5,0.5] in OTB physical space
   *   [ 0 , 0 ] in OSSIM
   * \param[in] val  coordinate value to modify (along X or Y)
   */
  inline double ConvertToOSSIMFrame(double val)
    {
    return (val - 0.5);
    }

  /**
   * Converts index coordinates from OSSIM into OTB. It is intended for sensor
   * images where the centre of the top-left pixel is expected to be :
   *   [0.5,0.5] in OTB physical space
   *   [ 0 , 0 ] in OSSIM
    * \param[in] val  coordinate value to modify (along X or Y)
   */
  inline double ConvertFromOSSIMFrame(double val)
    {
    return (val + 0.5);
    }

} // namespace internal

63
/** \class ImageKeywordlist
64
 * \brief Storage and conversion for OSSIM metadata
65
66
67
 *
 * \sa ImageSeriesReader
 * \sa ImageIOBase
68
 *
69
70
 * \ingroup Projections
 *
71
72
 *
 * \ingroup OTBOSSIMAdapters
73
 */
74
class ITK_EXPORT ImageKeywordlist
75
76
77
{
public:
  /** Standard class typedefs. */
78
  typedef ImageKeywordlist Self;
79

80
  //virtual const char *GetNameOfClass() const
OTB Bot's avatar
STYLE    
OTB Bot committed
81
  //{return "ImageKeywordlist"; }
Emmanuel Christophe's avatar
Emmanuel Christophe committed
82

83
  typedef std::map<std::string, std::string> KeywordlistMap;
84

85
86
87
  /** Run-time type information (and related methods). */
  itkTypeMacro(ImageKeywordlist, ImageKeywordlist);

88
  /** Get the internal map container */
OTB Bot's avatar
STYLE    
OTB Bot committed
89
  const KeywordlistMap& GetKeywordlist() const
90
91
92
  {
    return m_Keywordlist;
  }
OTB Bot's avatar
STYLE    
OTB Bot committed
93

94
  void SetKeywordlist(const ossimKeywordlist& kwl);
95
96

  void Clear(void)
97
  {
98
    m_Keywordlist.clear();
99
  }
100

101
102
103
104
  unsigned int GetSize(void) const
  {
    return m_Keywordlist.size();
  }
OTB Bot's avatar
STYLE    
OTB Bot committed
105

106
  /** Get the Data object descriptor corresponding to the given key */
107
  const std::string& GetMetadataByKey(const std::string& key) const;
OTB Bot's avatar
STYLE    
OTB Bot committed
108

109
110
111
  /** return true if the key is in the dictionary */
  bool HasKey(const std::string& key) const;

112
113
114
  /** Clear a given field of the keyword list */
  virtual void ClearMetadataByKey(const std::string& key);

115
116
  virtual void AddKey(const std::string& key, const std::string& value);

117
  virtual void convertToOSSIMKeywordlist(ossimKeywordlist& kwl) const;
118
119
120
121
  
  /** try to convert the image keywordlist into a GDALRpcInfo structure
   *  return true if successful, false otherwise */
  virtual bool convertToGDALRPC(GDALRPCInfo &rpc) const;
122

OTB Bot's avatar
STYLE    
OTB Bot committed
123
  virtual void Print(std::ostream& os, itk::Indent indent = 0) const;
124

Emmanuel Christophe's avatar
Emmanuel Christophe committed
125
126
  ImageKeywordlist();
  virtual ~ImageKeywordlist();
127

OTB Bot's avatar
STYLE    
OTB Bot committed
128
129
  ImageKeywordlist(const Self &);
  void operator =(const Self&);
130
  bool operator ==(const Self&);
131

132
133
134
135
136
137
138
protected:
  /** Methods invoked by Print() to print information about the object
   * Typically not called by the user (use Print()
   * instead) but used in the hierarchical print process to combine the
   * output of several classes.  */
  virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;

139
140
141
private:
  /** Geo informations are in this map */
  KeywordlistMap m_Keywordlist;
142

143
144
145
//  char m_Delimiter;

//  void operator=(const Self&); //purposely not implemented
146

147
148
};

149
std::ostream & operator <<(std::ostream& os, const ImageKeywordlist& kwl);
150

151
// Free function to handle the keywordlist <-> files
152
ImageKeywordlist ReadGeometryFromImage(const std::string& filename, bool checkRpcTag=true);
153
ImageKeywordlist ReadGeometryFromGEOMFile(const std::string& filename);
154
ImageKeywordlist ReadGeometryFromRPCTag(const std::string& filename);
155
156
void WriteGeometry(const ImageKeywordlist& otb_kwl, const std::string& filename);

157
158
159
} //namespace otb

#endif // __otbImageKeywordlist_h