GDAL

gdal_mdreader.h
1/******************************************************************************
2 *
3 * Project: GDAL Core
4 * Purpose: Read metadata (mainly the remote sensing imagery) from files of
5 * different providers like DigitalGlobe, GeoEye etc.
6 * Author: Dmitry Baryshnikov, polimax@mail.ru
7 *
8 ******************************************************************************
9 * Copyright (c) 2014-2015, NextGIS info@nextgis.ru
10 *
11 * SPDX-License-Identifier: MIT
12 ****************************************************************************/
13
14#ifndef GDAL_MDREADER_H_INCLUDED
15#define GDAL_MDREADER_H_INCLUDED
16
17#include "cpl_port.h"
18#include "gdal_priv.h"
19
20#include <map>
21
22#define MD_DOMAIN_IMD "IMD"
23#define MD_DOMAIN_RPC "RPC"
24#define MD_DOMAIN_IMAGERY "IMAGERY"
25#define MD_DOMAIN_DEFAULT ""
27#define MD_NAME_ACQDATETIME \
28 "ACQUISITIONDATETIME"
30#define MD_NAME_SATELLITE \
31 "SATELLITEID"
32#define MD_NAME_CLOUDCOVER \
33 "CLOUDCOVER"
35#define MD_NAME_MDTYPE \
36 "METADATATYPE"
39#define MD_DATETIMEFORMAT "%Y-%m-%d %H:%M:%S"
40#define MD_CLOUDCOVER_NA "999"
46#define RPC_ERR_BIAS "ERR_BIAS"
47#define RPC_ERR_RAND "ERR_RAND"
48#define RPC_LINE_OFF "LINE_OFF"
49#define RPC_SAMP_OFF "SAMP_OFF"
50#define RPC_LAT_OFF "LAT_OFF"
51#define RPC_LONG_OFF "LONG_OFF"
52#define RPC_HEIGHT_OFF "HEIGHT_OFF"
53#define RPC_LINE_SCALE "LINE_SCALE"
54#define RPC_SAMP_SCALE "SAMP_SCALE"
55#define RPC_LAT_SCALE "LAT_SCALE"
56#define RPC_LONG_SCALE "LONG_SCALE"
57#define RPC_HEIGHT_SCALE "HEIGHT_SCALE"
58#define RPC_LINE_NUM_COEFF "LINE_NUM_COEFF"
59#define RPC_LINE_DEN_COEFF "LINE_DEN_COEFF"
60#define RPC_SAMP_NUM_COEFF "SAMP_NUM_COEFF"
61#define RPC_SAMP_DEN_COEFF "SAMP_DEN_COEFF"
62
63/* Optional */
64#define RPC_MIN_LONG "MIN_LONG"
65#define RPC_MIN_LAT "MIN_LAT"
66#define RPC_MAX_LONG "MAX_LONG"
67#define RPC_MAX_LAT "MAX_LAT"
68
69/* Pleiades Neo nomenclature */
70#define RPC_LAT_NUM_COEFF "LAT_NUM_COEFF"
71#define RPC_LAT_DEN_COEFF "LAT_DEN_COEFF"
72#define RPC_LON_NUM_COEFF "LON_NUM_COEFF"
73#define RPC_LON_DEN_COEFF "LON_DEN_COEFF"
74
79 typedef enum
80{
81 MDR_None = 0x00000000,
82 MDR_DG = 0x00000001,
83 MDR_GE = 0x00000002,
84 MDR_OV = 0x00000004,
85 MDR_PLEIADES = 0x00000008,
86 MDR_SPOT = 0x00000010,
87 MDR_RDK1 = 0x00000020,
88 MDR_LS = 0x00000040,
89 MDR_RE = 0x00000080,
90 MDR_KOMPSAT = 0x00000100,
91 MDR_EROS = 0x00000200,
92 MDR_ALOS = 0x00000400,
93 MDR_ANY = MDR_DG | MDR_GE | MDR_OV | MDR_PLEIADES | MDR_SPOT | MDR_RDK1 |
94 MDR_LS | MDR_RE | MDR_KOMPSAT | MDR_EROS |
95 MDR_ALOS
96} MDReaders;
97
101 class CPL_DLL GDALMDReaderBase
102{
103
104 CPL_DISALLOW_COPY_ASSIGN(GDALMDReaderBase)
105
106 static bool
107 ReadXMLToListFirstPass(const CPLXMLNode *psNode,
108 std::map<std::string, int> &oMapCountKeysFull,
109 const std::string &osPrefixFull, int nDepth);
110
111 char **ReadXMLToList(const CPLXMLNode *psNode, char **papszList,
112 const std::map<std::string, int> &oMapCountKeysFullRef,
113 std::map<std::string, int> &oMapCountKeysFull,
114 std::map<std::string, int> &oMapCountKeys,
115 const std::string &osPrefix,
116 const std::string &osPrefixFull);
117
118 public:
119 GDALMDReaderBase(const char *pszPath, CSLConstList papszSiblingFiles);
120 virtual ~GDALMDReaderBase();
121
127 virtual char **GetMetadataDomain(const char *pszDomain);
133 virtual bool FillMetadata(GDALMultiDomainMetadata *poMDMD);
139 virtual bool HasRequiredFiles() const = 0;
145 virtual char **GetMetadataFiles() const = 0;
146
147 protected:
152 virtual void LoadMetadata();
158 virtual GIntBig GetAcquisitionTimeFromString(const char *pszDateTime);
168 virtual char **ReadXMLToList(CPLXMLNode *psNode, char **papszList,
169 const char *pszName = "");
179 virtual char **AddXMLNameValueToList(char **papszList, const char *pszName,
180 const char *pszValue);
181
182 protected:
184 char **m_papszIMDMD = nullptr;
185 char **m_papszRPCMD = nullptr;
186 char **m_papszIMAGERYMD = nullptr;
187 char **m_papszDEFAULTMD = nullptr;
188 bool m_bIsMetadataLoad = false;
190};
191
197 class CPL_DLL GDALMDReaderManager
198{
199
200 CPL_DISALLOW_COPY_ASSIGN(GDALMDReaderManager)
201
202 public:
203 GDALMDReaderManager();
204 virtual ~GDALMDReaderManager();
205
216 virtual GDALMDReaderBase *GetReader(const char *pszPath,
217 CSLConstList papszSiblingFiles,
218 GUInt32 nType = MDR_ANY);
219
220 protected:
222 GDALMDReaderBase *m_pReader = nullptr;
224};
225
226// misc
227 CPLString CPLStrip(const CPLString &osString, const char cChar);
228 CPLString CPLStripQuotes(const CPLString &osString);
229 char **GDALLoadRPBFile(const CPLString &osFilePath);
230 char CPL_DLL **GDALLoadRPCFile(const CPLString &osFilePath);
231 char **GDALLoadIMDFile(const CPLString &osFilePath);
232 bool GDALCheckFileHeader(const CPLString &soFilePath, const char *pszTestString,
233 int nBufferSize = 256);
234
235 CPLErr GDALWriteRPBFile(const char *pszFilename, char **papszMD);
236 CPLErr CPL_DLL GDALWriteRPCTXTFile(const char *pszFilename, char **papszMD);
237 CPLErr GDALWriteIMDFile(const char *pszFilename, char **papszMD);
238
239#endif // GDAL_MDREADER_H_INCLUDED
CPLString
Convenient string class based on std::string.
Definition cpl_string.h:320
GDALMDReaderBase
The base class for all metadata readers.
Definition gdal_mdreader.h:102
GDALMDReaderBase::GetMetadataFiles
virtual char ** GetMetadataFiles() const =0
Get metadata file names.
GDALMDReaderBase::HasRequiredFiles
virtual bool HasRequiredFiles() const =0
Determine whether the input parameter correspond to the particular provider of remote sensing data co...
GDALMDReaderManager
The metadata reader main class.
Definition gdal_mdreader.h:198
GDALMDReaderManager::GDALMDReaderManager
GDALMDReaderManager()
GDALMDReaderManager()
CPLErr
CPLErr
Error category.
Definition cpl_error.h:37
cpl_port.h
Core portability definitions for CPL.
GUInt32
unsigned int GUInt32
Unsigned int32 type.
Definition cpl_port.h:167
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:936
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:205
gdal_priv.h
This file is legacy since GDAL 3.12, but will be kept at least in the whole GDAL 3....
CPLXMLNode
Document node structure.
Definition cpl_minixml.h:54