GDAL

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

- File List
- File Members

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

Generated for GDAL by 1.8.9.1.