GDAL

- Main Page
- Related Pages
- Classes
- Files
- Download
- Issue Tracker

- File List
- File Members

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