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 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
29 ****************************************************************************/
30
31 #ifndef GDAL_MDREADER_H_INCLUDED
32 #define GDAL_MDREADER_H_INCLUDED
33
34 #include "cpl_port.h"
35 #include "gdal_priv.h"
36
37 #include <map>
38
39 #define MD_DOMAIN_IMD "IMD"
40 #define MD_DOMAIN_RPC "RPC"
41 #define MD_DOMAIN_IMAGERY "IMAGERY"
42 #define MD_DOMAIN_DEFAULT ""
44 #define MD_NAME_ACQDATETIME "ACQUISITIONDATETIME"
45 #define MD_NAME_SATELLITE "SATELLITEID"
46 #define MD_NAME_CLOUDCOVER "CLOUDCOVER"
47 #define MD_NAME_MDTYPE "METADATATYPE"
49 #define MD_DATETIMEFORMAT "%Y-%m-%d %H:%M:%S"
50 #define MD_CLOUDCOVER_NA "999"
56 #define RPC_ERR_BIAS "ERR_BIAS"
57 #define RPC_ERR_RAND "ERR_RAND"
58 #define RPC_LINE_OFF "LINE_OFF"
59 #define RPC_SAMP_OFF "SAMP_OFF"
60 #define RPC_LAT_OFF "LAT_OFF"
61 #define RPC_LONG_OFF "LONG_OFF"
62 #define RPC_HEIGHT_OFF "HEIGHT_OFF"
63 #define RPC_LINE_SCALE "LINE_SCALE"
64 #define RPC_SAMP_SCALE "SAMP_SCALE"
65 #define RPC_LAT_SCALE "LAT_SCALE"
66 #define RPC_LONG_SCALE "LONG_SCALE"
67 #define RPC_HEIGHT_SCALE "HEIGHT_SCALE"
68 #define RPC_LINE_NUM_COEFF "LINE_NUM_COEFF"
69 #define RPC_LINE_DEN_COEFF "LINE_DEN_COEFF"
70 #define RPC_SAMP_NUM_COEFF "SAMP_NUM_COEFF"
71 #define RPC_SAMP_DEN_COEFF "SAMP_DEN_COEFF"
72
73 /* Optional */
74 #define RPC_MIN_LONG "MIN_LONG"
75 #define RPC_MIN_LAT "MIN_LAT"
76 #define RPC_MAX_LONG "MAX_LONG"
77 #define RPC_MAX_LAT "MAX_LAT"
78
79 /* Pleiades Neo nomenclature */
80 #define RPC_LAT_NUM_COEFF "LAT_NUM_COEFF"
81 #define RPC_LAT_DEN_COEFF "LAT_DEN_COEFF"
82 #define RPC_LON_NUM_COEFF "LON_NUM_COEFF"
83 #define RPC_LON_DEN_COEFF "LON_DEN_COEFF"
84
89 typedef enum {
90 MDR_None = 0x00000000,
91 MDR_DG = 0x00000001,
92 MDR_GE = 0x00000002,
93 MDR_OV = 0x00000004,
94 MDR_PLEIADES = 0x00000008,
95 MDR_SPOT = 0x00000010,
96 MDR_RDK1 = 0x00000020,
97 MDR_LS = 0x00000040,
98 MDR_RE = 0x00000080,
99 MDR_KOMPSAT = 0x00000100,
100 MDR_EROS = 0x00000200,
101 MDR_ALOS = 0x00000400,
102 MDR_ANY = MDR_DG | MDR_GE | MDR_OV | MDR_PLEIADES | MDR_SPOT | MDR_RDK1 |
103 MDR_LS | MDR_RE | MDR_KOMPSAT | MDR_EROS | MDR_ALOS
104 } MDReaders;
105
109 class CPL_DLL GDALMDReaderBase{
110
111 CPL_DISALLOW_COPY_ASSIGN(GDALMDReaderBase)
112
113 void ReadXMLToListFirstPass(const CPLXMLNode* psNode,
114 std::map<std::string, int>& oMapCountKeysFull,
115 const std::string& osPrefixFull);
116
117 char** ReadXMLToList(const CPLXMLNode* psNode,
118 char** papszList,
119 const std::map<std::string, int>& oMapCountKeysFullRef,
120 std::map<std::string, int>& oMapCountKeysFull,
121 std::map<std::string, int>& oMapCountKeys,
122 const std::string& osPrefix,
123 const std::string& osPrefixFull);
124
125 public:
126 GDALMDReaderBase(const char *pszPath, char **papszSiblingFiles);
127 virtual ~GDALMDReaderBase();
128
134 virtual char ** GetMetadataDomain(const char *pszDomain);
140 virtual bool FillMetadata(GDALMultiDomainMetadata* poMDMD);
146 virtual bool HasRequiredFiles() const = 0;
152 virtual char** GetMetadataFiles() const = 0;
153 protected:
158 virtual void LoadMetadata();
164 virtual GIntBig GetAcquisitionTimeFromString(const char* pszDateTime);
174 virtual char** ReadXMLToList(CPLXMLNode* psNode, char** papszList,
175 const char* pszName = "");
185 virtual char** AddXMLNameValueToList(char** papszList, const char *pszName,
186 const char *pszValue);
187 protected:
189 char **m_papszIMDMD = nullptr;
190 char **m_papszRPCMD = nullptr;
191 char **m_papszIMAGERYMD = nullptr;
192 char **m_papszDEFAULTMD = nullptr;
193 bool m_bIsMetadataLoad = false;
195 };
196
202 class CPL_DLL GDALMDReaderManager{
203
204 CPL_DISALLOW_COPY_ASSIGN(GDALMDReaderManager)
205
206 public:
207 GDALMDReaderManager();
208 virtual ~GDALMDReaderManager();
209
220 virtual GDALMDReaderBase* GetReader(const char *pszPath,
221 char **papszSiblingFiles,
222 GUInt32 nType = MDR_ANY);
223 protected:
225 GDALMDReaderBase *m_pReader = nullptr;
227 };
228
229 // misc
230 CPLString CPLStrip(const CPLString& osString, const char cChar);
231 CPLString CPLStripQuotes(const CPLString& osString);
232 char** GDALLoadRPBFile( const CPLString& osFilePath );
233 char** GDALLoadRPCFile( const CPLString& osFilePath );
234 char** GDALLoadIMDFile( const CPLString& osFilePath );
235 bool GDALCheckFileHeader(const CPLString& soFilePath,
236 const char * pszTestString,
237 int nBufferSize = 256);
238
239 CPLErr GDALWriteRPBFile( const char *pszFilename, char **papszMD );
240 CPLErr GDALWriteRPCTXTFile( const char *pszFilename, char **papszMD );
241 CPLErr GDALWriteIMDFile( const char *pszFilename, char **papszMD );
242
243 #endif //GDAL_MDREADER_H_INCLUDED
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:320
CPLXMLNode
Document node structure.
Definition: cpl_minixml.h:69
gdal_priv.h
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:230
cpl_port.h
CPLErr
CPLErr
Error category.
Definition: cpl_error.h:52
GDALMDReaderBase
The base class for all metadata readers.
Definition: gdal_mdreader.h:109
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:930
GDALMDReaderManager
The metadata reader main class.
Definition: gdal_mdreader.h:202
GUInt32
unsigned int GUInt32
Unsigned int32 type.
Definition: cpl_port.h:195