GDAL
gdal_mdreader.h
1 /******************************************************************************
2  * $Id: gdal_mdreader.h 29190 2015-05-13 21:40:30Z bishop $
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 
35 #include "cpl_port.h"
36 #include "gdal_priv.h"
37 
38 #define MD_DOMAIN_IMD "IMD"
39 #define MD_DOMAIN_RPC "RPC"
40 #define MD_DOMAIN_IMAGERY "IMAGERY"
41 #define MD_DOMAIN_DEFAULT ""
43 #define MD_NAME_ACQDATETIME "ACQUISITIONDATETIME"
44 #define MD_NAME_SATELLITE "SATELLITEID"
45 #define MD_NAME_CLOUDCOVER "CLOUDCOVER"
46 #define MD_NAME_MDTYPE "METADATATYPE"
48 #define MD_DATETIMEFORMAT "%Y-%m-%d %H:%M:%S"
49 #define MD_CLOUDCOVER_NA "999"
55 #define RPC_LINE_OFF "LINE_OFF"
56 #define RPC_SAMP_OFF "SAMP_OFF"
57 #define RPC_LAT_OFF "LAT_OFF"
58 #define RPC_LONG_OFF "LONG_OFF"
59 #define RPC_HEIGHT_OFF "HEIGHT_OFF"
60 #define RPC_LINE_SCALE "LINE_SCALE"
61 #define RPC_SAMP_SCALE "SAMP_SCALE"
62 #define RPC_LAT_SCALE "LAT_SCALE"
63 #define RPC_LONG_SCALE "LONG_SCALE"
64 #define RPC_HEIGHT_SCALE "HEIGHT_SCALE"
65 #define RPC_LINE_NUM_COEFF "LINE_NUM_COEFF"
66 #define RPC_LINE_DEN_COEFF "LINE_DEN_COEFF"
67 #define RPC_SAMP_NUM_COEFF "SAMP_NUM_COEFF"
68 #define RPC_SAMP_DEN_COEFF "SAMP_DEN_COEFF"
69 
74 typedef enum {
75  MDR_None = 0x00000000,
76  MDR_DG = 0x00000001,
77  MDR_GE = 0x00000002,
78  MDR_OV = 0x00000004,
79  MDR_PLEIADES = 0x00000008,
80  MDR_SPOT = 0x00000010,
81  MDR_RDK1 = 0x00000020,
82  MDR_LS = 0x00000040,
83  MDR_RE = 0x00000080,
84  MDR_KOMPSAT = 0x00000100,
85  MDR_EROS = 0x00000200,
86  MDR_ALOS = 0x00000400,
87  MDR_ANY = MDR_DG | MDR_GE | MDR_OV | MDR_PLEIADES | MDR_SPOT | MDR_RDK1 |
88  MDR_LS | MDR_RE | MDR_KOMPSAT | MDR_EROS | MDR_ALOS
89 } MDReaders;
90 
91 
96 public:
97  GDALMDReaderBase(const char *pszPath, char **papszSiblingFiles);
98  virtual ~GDALMDReaderBase();
99 
105  virtual char ** GetMetadataDomain(const char *pszDomain);
111  virtual bool FillMetadata(GDALMultiDomainMetadata* poMDMD);
117  virtual const bool HasRequiredFiles() const = 0;
123  virtual char** GetMetadataFiles() const = 0;
124 protected:
129  virtual void LoadMetadata();
135  virtual const time_t GetAcquisitionTimeFromString(const char* pszDateTime);
145  virtual char** ReadXMLToList(CPLXMLNode* psNode, char** papszList,
146  const char* pszName = "");
156  virtual char** AddXMLNameValueToList(char** papszList, const char *pszName,
157  const char *pszValue);
158 protected:
159  char **m_papszIMDMD;
160  char **m_papszRPCMD;
161  char **m_papszIMAGERYMD;
162  char **m_papszDEFAULTMD;
163  bool m_bIsMetadataLoad;
164 };
165 
171 class CPL_DLL GDALMDReaderManager{
172 public:
174  virtual ~GDALMDReaderManager();
175 
186  virtual GDALMDReaderBase* GetReader(const char *pszPath,
187  char **papszSiblingFiles,
188  GUInt32 nType = MDR_ANY);
189 protected:
190  GDALMDReaderBase *m_pReader;
191 };
192 
193 // misc
194 CPLString CPLStrip(const CPLString& osString, const char cChar);
195 CPLString CPLStripQuotes(const CPLString& osString);
196 char** GDALLoadRPBFile( const CPLString& osFilePath );
197 char** GDALLoadRPCFile( const CPLString& osFilePath );
198 char** GDALLoadIMDFile( const CPLString& osFilePath );
199 const bool GDALCheckFileHeader(const CPLString& soFilePath,
200  const char * pszTestString,
201  int nBufferSize = 256);
202 
203 CPLErr GDALWriteRPBFile( const char *pszFilename, char **papszMD );
204 CPLErr GDALWriteRPCTXTFile( const char *pszFilename, char **papszMD );
205 CPLErr GDALWriteIMDFile( const char *pszFilename, char **papszMD );
206 
207 #endif //GDAL_MDREADER_H_INCLUDED
Document node structure.
Definition: cpl_minixml.h:65
Core portability definitions for CPL.
The base class for all metadata readers.
Definition: gdal_mdreader.h:95
Convenient string class based on std::string.
Definition: cpl_string.h:236
virtual char ** AddXMLNameValueToList(char **papszList, const char *pszName, const char *pszValue)
AddXMLNameValueToList Execute from ReadXMLToList to add name and value to list.
Definition: gdal_mdreader.cpp:291
virtual void LoadMetadata()
Load metadata to the correspondent IMD, RPB, IMAGERY and DEFAULT domains.
Definition: gdal_mdreader.cpp:222
virtual const bool HasRequiredFiles() const =0
Determine whether the input parameter correspond to the particular provider of remote sensing data co...
GDALMDReaderBase(const char *pszPath, char **papszSiblingFiles)
GDALMDReaderBase()
Definition: gdal_mdreader.cpp:181
virtual ~GDALMDReaderBase()
~GDALMDReaderBase()
Definition: gdal_mdreader.cpp:194
virtual char ** ReadXMLToList(CPLXMLNode *psNode, char **papszList, const char *pszName="")
ReadXMLToList Transform xml to list of NULL terminated name=value strings.
Definition: gdal_mdreader.cpp:301
virtual const time_t GetAcquisitionTimeFromString(const char *pszDateTime)
Convert string like 2012-02-25T00:25:59.9440000Z to time.
Definition: gdal_mdreader.cpp:232
virtual char ** GetMetadataFiles() const =0
Get metadata file names.
Definition: gdal_priv.h:76
The metadata reader main class.
Definition: gdal_mdreader.h:171
virtual char ** GetMetadataDomain(const char *pszDomain)
Get specified metadata domain.
Definition: gdal_mdreader.cpp:205
virtual bool FillMetadata(GDALMultiDomainMetadata *poMDMD)
Fill provided metatada store class.
Definition: gdal_mdreader.cpp:273

Generated for GDAL by doxygen 1.8.11.