1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
/*
* Copyright (C) 2005-2020 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef otbImageKeywordlist_h
#define otbImageKeywordlist_h
#include <map>
#include "gdal.h"
#include "itkObject.h"
#include "itkObjectFactory.h"
#include "OTBOSSIMAdaptersExport.h"
// forward declaration
class ossimKeywordlist;
namespace otb
{
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
/** \class ImageKeywordlist
* \brief Storage and conversion for OSSIM metadata
*
* \sa ImageSeriesReader
* \sa ImageIOBase
*
* \ingroup Projections
*
*
* \ingroup OTBOSSIMAdapters
*/
class OTBOSSIMAdapters_EXPORT ImageKeywordlist
{
public:
/** Standard class typedefs. */
typedef ImageKeywordlist Self;
// virtual const char *GetNameOfClass() const
//{return "ImageKeywordlist"; }
typedef std::map<std::string, std::string> KeywordlistMap;
typedef KeywordlistMap::size_type KeywordlistMapSizeType;
/** Get the internal map container */
const KeywordlistMap& GetKeywordlist() const
{
return m_Keywordlist;
}
void SetKeywordlist(const ossimKeywordlist& kwl);
void Clear(void)
{
m_Keywordlist.clear();
}
KeywordlistMapSizeType Empty() const
{
return m_Keywordlist.empty();
}
KeywordlistMapSizeType GetSize(void) const
{
return m_Keywordlist.size();
}
/** Get the Data object descriptor corresponding to the given key */
const std::string& GetMetadataByKey(const std::string& key) const;
/** return true if the key is in the dictionary */
bool HasKey(const std::string& key) const;
/** Clear a given field of the keyword list */
virtual void ClearMetadataByKey(const std::string& key);
virtual void AddKey(const std::string& key, const std::string& value);
virtual void convertToOSSIMKeywordlist(ossimKeywordlist& kwl) const;
/** try to convert the image keywordlist into a GDALRpcInfo structure
* return true if successful, false otherwise */
virtual bool convertToGDALRPC(GDALRPCInfo& rpc) const;
virtual void Print(std::ostream& os, itk::Indent indent = 0) const;
ImageKeywordlist();
virtual ~ImageKeywordlist();
ImageKeywordlist(const Self&);
void operator=(const Self&);
bool operator==(const Self&) const;
inline bool operator!=(const Self&) const;
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;
private:
/** Geo information are in this map */
KeywordlistMap m_Keywordlist;
// char m_Delimiter;
// void operator=(const Self&) = delete;
};
OTBOSSIMAdapters_EXPORT std::ostream& operator<<(std::ostream& os, const ImageKeywordlist& kwl);
// Free function to handle the keywordlist <-> files
OTBOSSIMAdapters_EXPORT ImageKeywordlist ReadGeometryFromImage(const std::string& filename, bool checkRpcTag = true);
OTBOSSIMAdapters_EXPORT ImageKeywordlist ReadGeometryFromGEOMFile(const std::string& filename);
OTBOSSIMAdapters_EXPORT ImageKeywordlist ReadGeometryFromRPCTag(const std::string& filename);
OTBOSSIMAdapters_EXPORT void WriteGeometry(const ImageKeywordlist& otb_kwl, const std::string& filename);
inline bool ImageKeywordlist::operator!=(const Self& p) const
{
return !this->operator==(p);
}
} // namespace otb
#endif // otbImageKeywordlist_h
|