GDAL

gdal_mdreader.h
1/******************************************************************************
2 * $Id$
3 *
4 * Project: GDAL Core
5 * Purpose: Read metadata (mainly the remote sensing imagery) from files of
6 * different providers like DigitalGlobe, GeoEye etc.
7 * Author: Dmitry Baryshnikov, polimax@mail.ru
8 *
9 ******************************************************************************
10 * Copyright (c) 2014-2015, NextGIS info@nextgis.ru
11 *
12 * SPDX-License-Identifier: MIT
13 ****************************************************************************/
14
15#ifndef GDAL_MDREADER_H_INCLUDED
16#define GDAL_MDREADER_H_INCLUDED
17
18#include "cpl_port.h"
19#include "gdal_priv.h"
20
21#include <map>
22
23#define MD_DOMAIN_IMD "IMD"
24#define MD_DOMAIN_RPC "RPC"
25#define MD_DOMAIN_IMAGERY "IMAGERY"
26#define MD_DOMAIN_DEFAULT ""
28#define MD_NAME_ACQDATETIME \
29 "ACQUISITIONDATETIME"
31#define MD_NAME_SATELLITE \
32 "SATELLITEID"
33#define MD_NAME_CLOUDCOVER \
34 "CLOUDCOVER"
36#define MD_NAME_MDTYPE \
37 "METADATATYPE"
40#define MD_DATETIMEFORMAT "%Y-%m-%d %H:%M:%S"
41#define MD_CLOUDCOVER_NA "999"
47#define RPC_ERR_BIAS "ERR_BIAS"
48#define RPC_ERR_RAND "ERR_RAND"
49#define RPC_LINE_OFF "LINE_OFF"
50#define RPC_SAMP_OFF "SAMP_OFF"
51#define RPC_LAT_OFF "LAT_OFF"
52#define RPC_LONG_OFF "LONG_OFF"
53#define RPC_HEIGHT_OFF "HEIGHT_OFF"
54#define RPC_LINE_SCALE "LINE_SCALE"
55#define RPC_SAMP_SCALE "SAMP_SCALE"
56#define RPC_LAT_SCALE "LAT_SCALE"
57#define RPC_LONG_SCALE "LONG_SCALE"
58#define RPC_HEIGHT_SCALE "HEIGHT_SCALE"
59#define RPC_LINE_NUM_COEFF "LINE_NUM_COEFF"
60#define RPC_LINE_DEN_COEFF "LINE_DEN_COEFF"
61#define RPC_SAMP_NUM_COEFF "SAMP_NUM_COEFF"
62#define RPC_SAMP_DEN_COEFF "SAMP_DEN_COEFF"
63
64/* Optional */
65#define RPC_MIN_LONG "MIN_LONG"
66#define RPC_MIN_LAT "MIN_LAT"
67#define RPC_MAX_LONG "MAX_LONG"
68#define RPC_MAX_LAT "MAX_LAT"
69
70/* Pleiades Neo nomenclature */
71#define RPC_LAT_NUM_COEFF "LAT_NUM_COEFF"
72#define RPC_LAT_DEN_COEFF "LAT_DEN_COEFF"
73#define RPC_LON_NUM_COEFF "LON_NUM_COEFF"
74#define RPC_LON_DEN_COEFF "LON_DEN_COEFF"
75
80 typedef enum
81{
82 MDR_None = 0x00000000,
83 MDR_DG = 0x00000001,
84 MDR_GE = 0x00000002,
85 MDR_OV = 0x00000004,
86 MDR_PLEIADES = 0x00000008,
87 MDR_SPOT = 0x00000010,
88 MDR_RDK1 = 0x00000020,
89 MDR_LS = 0x00000040,
90 MDR_RE = 0x00000080,
91 MDR_KOMPSAT = 0x00000100,
92 MDR_EROS = 0x00000200,
93 MDR_ALOS = 0x00000400,
94 MDR_ANY = MDR_DG | MDR_GE | MDR_OV | MDR_PLEIADES | MDR_SPOT | MDR_RDK1 |
95 MDR_LS | MDR_RE | MDR_KOMPSAT | MDR_EROS |
96 MDR_ALOS
97} MDReaders;
98
102 class CPL_DLL GDALMDReaderBase
103{
104
105 CPL_DISALLOW_COPY_ASSIGN(GDALMDReaderBase)
106
107 static bool
108 ReadXMLToListFirstPass(const CPLXMLNode *psNode,
109 std::map<std::string, int> &oMapCountKeysFull,
110 const std::string &osPrefixFull, int nDepth);
111
112 char **ReadXMLToList(const CPLXMLNode *psNode, char **papszList,
113 const std::map<std::string, int> &oMapCountKeysFullRef,
114 std::map<std::string, int> &oMapCountKeysFull,
115 std::map<std::string, int> &oMapCountKeys,
116 const std::string &osPrefix,
117 const std::string &osPrefixFull);
118
119 public:
120 GDALMDReaderBase(const char *pszPath, char **papszSiblingFiles);
121 virtual ~GDALMDReaderBase();
122
128 virtual char **GetMetadataDomain(const char *pszDomain);
134 virtual bool FillMetadata(GDALMultiDomainMetadata *poMDMD);
140 virtual bool HasRequiredFiles() const = 0;
146 virtual char **GetMetadataFiles() const = 0;
147
148 protected:
153 virtual void LoadMetadata();
159 virtual GIntBig GetAcquisitionTimeFromString(const char *pszDateTime);
169 virtual char **ReadXMLToList(CPLXMLNode *psNode, char **papszList,
170 const char *pszName = "");
180 virtual char **AddXMLNameValueToList(char **papszList, const char *pszName,
181 const char *pszValue);
182
183 protected:
185 char **m_papszIMDMD = nullptr;
186 char **m_papszRPCMD = nullptr;
187 char **m_papszIMAGERYMD = nullptr;
188 char **m_papszDEFAULTMD = nullptr;
189 bool m_bIsMetadataLoad = false;
191};
192
198 class CPL_DLL GDALMDReaderManager
199{
200
201 CPL_DISALLOW_COPY_ASSIGN(GDALMDReaderManager)
202
203 public:
204 GDALMDReaderManager();
205 virtual ~GDALMDReaderManager();
206
217 virtual GDALMDReaderBase *GetReader(const char *pszPath,
218 char **papszSiblingFiles,
219 GUInt32 nType = MDR_ANY);
220
221 protected:
223 GDALMDReaderBase *m_pReader = nullptr;
225};
226
227// misc
228 CPLString CPLStrip(const CPLString &osString, const char cChar);
229 CPLString CPLStripQuotes(const CPLString &osString);
230 char **GDALLoadRPBFile(const CPLString &osFilePath);
231 char CPL_DLL **GDALLoadRPCFile(const CPLString &osFilePath);
232 char **GDALLoadIMDFile(const CPLString &osFilePath);
233 bool GDALCheckFileHeader(const CPLString &soFilePath, const char *pszTestString,
234 int nBufferSize = 256);
235
236 CPLErr GDALWriteRPBFile(const char *pszFilename, char **papszMD);
237 CPLErr CPL_DLL GDALWriteRPCTXTFile(const char *pszFilename, char **papszMD);
238 CPLErr GDALWriteIMDFile(const char *pszFilename, char **papszMD);
239
240#endif // GDAL_MDREADER_H_INCLUDED
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:307
GDALMDReaderBase
The base class for all metadata readers.
Definition: gdal_mdreader.h:103
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:199
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:161
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:1030
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:199
gdal_priv.h
C++ GDAL entry points.
CPLXMLNode
Document node structure.
Definition: cpl_minixml.h:55