GDAL
gdaljp2metadata.h
1 /******************************************************************************
2  * $Id: gdaljp2metadata.h 33694 2016-03-10 17:54:30Z goatbar $
3  *
4  * Project: GDAL
5  * Purpose: JP2 Box Reader (and GMLJP2 Interpreter)
6  * Author: Frank Warmerdam, warmerdam@pobox.com
7  *
8  ******************************************************************************
9  * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
10  * Copyright (c) 2010-2013, Even Rouault <even dot rouault at mines-paris dot org>
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_JP2READER_H_INCLUDED
32 #define GDAL_JP2READER_H_INCLUDED
33 
34 #include "cpl_conv.h"
35 #include "cpl_minixml.h"
36 #include "cpl_vsi.h"
37 #include "gdal.h"
38 #include "gdal_priv.h"
39 
40 /************************************************************************/
41 /* GDALJP2Box */
42 /************************************************************************/
43 
44 class CPL_DLL GDALJP2Box
45 {
46 
47  VSILFILE *fpVSIL;
48 
49  char szBoxType[5];
50 
51  GIntBig nBoxOffset;
52  GIntBig nBoxLength;
53 
54  GIntBig nDataOffset;
55 
56  GByte abyUUID[16];
57 
58  GByte *pabyData;
59 
60 public:
61  GDALJP2Box( VSILFILE * = NULL );
62  ~GDALJP2Box();
63 
64  int SetOffset( GIntBig nNewOffset );
65  int ReadBox();
66 
67  int ReadFirst();
68  int ReadNext();
69 
70  int ReadFirstChild( GDALJP2Box *poSuperBox );
71  int ReadNextChild( GDALJP2Box *poSuperBox );
72 
73  GIntBig GetBoxOffset() const { return nBoxOffset; }
74  GIntBig GetBoxLength() const { return nBoxLength; }
75 
76  GIntBig GetDataOffset() const { return nDataOffset; }
77  GIntBig GetDataLength();
78 
79  const char *GetType() { return szBoxType; }
80 
81  GByte *ReadBoxData();
82 
83  int IsSuperBox();
84 
85  int DumpReadable( FILE *, int nIndentLevel = 0 );
86 
87  VSILFILE *GetFILE() { return fpVSIL; }
88 
89  const GByte *GetUUID() { return abyUUID; }
90 
91  // write support
92  void SetType( const char * );
93  void SetWritableData( int nLength, const GByte *pabyData );
94  void AppendWritableData( int nLength, const void *pabyDataIn );
95  void AppendUInt32( GUInt32 nVal );
96  void AppendUInt16( GUInt16 nVal );
97  void AppendUInt8( GByte nVal );
98  const GByte*GetWritableData() { return pabyData; }
99 
100  // factory methods.
101  static GDALJP2Box *CreateSuperBox( const char* pszType,
102  int nCount, GDALJP2Box **papoBoxes );
103  static GDALJP2Box *CreateAsocBox( int nCount, GDALJP2Box **papoBoxes );
104  static GDALJP2Box *CreateLblBox( const char *pszLabel );
105  static GDALJP2Box *CreateLabelledXMLAssoc( const char *pszLabel,
106  const char *pszXML );
107  static GDALJP2Box *CreateUUIDBox( const GByte *pabyUUID,
108  int nDataSize, const GByte *pabyData );
109 };
110 
111 /************************************************************************/
112 /* GDALJP2Metadata */
113 /************************************************************************/
114 
115 typedef struct _GDALJP2GeoTIFFBox GDALJP2GeoTIFFBox;
116 
117 class CPL_DLL GDALJP2Metadata
118 
119 {
120 private:
121  void CollectGMLData( GDALJP2Box * );
122  int GMLSRSLookup( const char *pszURN );
123 
124  int nGeoTIFFBoxesCount;
125  GDALJP2GeoTIFFBox *pasGeoTIFFBoxes;
126 
127  int nMSIGSize;
128  GByte *pabyMSIGData;
129 
130  int GetGMLJP2GeoreferencingInfo( int& nEPSGCode,
131  double adfOrigin[2],
132  double adfXVector[2],
133  double adfYVector[2],
134  const char*& pszComment,
135  CPLString& osDictBox,
136  int& bNeedAxisFlip );
137  static CPLXMLNode* CreateGDALMultiDomainMetadataXML(
138  GDALDataset* poSrcDS,
139  int bMainMDDomainOnly );
140 
141 public:
142  char **papszGMLMetadata;
143 
144  int bHaveGeoTransform;
145  double adfGeoTransform[6];
146  int bPixelIsPoint;
147 
148  char *pszProjection;
149 
150  int nGCPCount;
151  GDAL_GCP *pasGCPList;
152 
153  char **papszRPCMD;
154 
155  char **papszMetadata; /* TIFFTAG_?RESOLUTION* for now from resd box */
156  char *pszXMPMetadata;
157  char *pszGDALMultiDomainMetadata; /* as serialized XML */
158  char *pszXMLIPR; /* if an IPR box with XML content has been found */
159 
160 public:
161  GDALJP2Metadata();
162  ~GDALJP2Metadata();
163 
164  int ReadBoxes( VSILFILE * fpVSIL );
165 
166  int ParseJP2GeoTIFF();
167  int ParseMSIG();
168  int ParseGMLCoverageDesc();
169 
170  int ReadAndParse( VSILFILE * fpVSIL );
171  int ReadAndParse( const char *pszFilename );
172 
173  // Write oriented.
174  void SetProjection( const char *pszWKT );
175  void SetGeoTransform( double * );
176  void SetGCPs( int, const GDAL_GCP * );
177  void SetRPCMD( char** papszRPCMDIn );
178 
179  GDALJP2Box *CreateJP2GeoTIFF();
180  GDALJP2Box *CreateGMLJP2( int nXSize, int nYSize );
181  GDALJP2Box *CreateGMLJP2V2( int nXSize, int nYSize,
182  const char* pszDefFilename,
183  GDALDataset* poSrcDS );
184 
185  static GDALJP2Box* CreateGDALMultiDomainMetadataXMLBox(
186  GDALDataset* poSrcDS,
187  int bMainMDDomainOnly );
188  static GDALJP2Box** CreateXMLBoxes( GDALDataset* poSrcDS,
189  int* pnBoxes );
190  static GDALJP2Box *CreateXMPBox ( GDALDataset* poSrcDS );
191  static GDALJP2Box *CreateIPRBox ( GDALDataset* poSrcDS );
192  static int IsUUID_MSI(const GByte *abyUUID);
193  static int IsUUID_XMP(const GByte *abyUUID);
194 };
195 
196 #endif /* ndef GDAL_JP2READER_H_INCLUDED */
Document node structure.
Definition: cpl_minixml.h:65
Standard C Covers.
Definitions for CPL mini XML Parser/Serializer.
C++ GDAL entry points.
Convenient string class based on std::string.
Definition: cpl_string.h:283
Public (C callable) GDAL entry points.
Various convenience functions for CPL.
Definition: gdaljp2metadata.h:117
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:296
Definition: gdaljp2metadata.h:44
Ground Control Point.
Definition: gdal.h:492

Generated for GDAL by doxygen 1.8.13.