GDAL
gdaljp2metadata.h
00001 /******************************************************************************
00002  * $Id: gdaljp2metadata.h 36411 2016-11-21 22:03:48Z rouault $
00003  *
00004  * Project:  GDAL
00005  * Purpose:  JP2 Box Reader (and GMLJP2 Interpreter)
00006  * Author:   Frank Warmerdam, warmerdam@pobox.com
00007  *
00008  ******************************************************************************
00009  * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
00010  * Copyright (c) 2010-2013, Even Rouault <even dot rouault at mines-paris dot org>
00011  *
00012  * Permission is hereby granted, free of charge, to any person obtaining a
00013  * copy of this software and associated documentation files (the "Software"),
00014  * to deal in the Software without restriction, including without limitation
00015  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00016  * and/or sell copies of the Software, and to permit persons to whom the
00017  * Software is furnished to do so, subject to the following conditions:
00018  *
00019  * The above copyright notice and this permission notice shall be included
00020  * in all copies or substantial portions of the Software.
00021  *
00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00023  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00025  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00026  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00027  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00028  * DEALINGS IN THE SOFTWARE.
00029  ****************************************************************************/
00030 
00031 #ifndef GDAL_JP2READER_H_INCLUDED
00032 #define GDAL_JP2READER_H_INCLUDED
00033 
00034 #ifndef DOXYGEN_SKIP
00035 
00036 #include "cpl_conv.h"
00037 #include "cpl_minixml.h"
00038 #include "cpl_vsi.h"
00039 #include "gdal.h"
00040 #include "gdal_priv.h"
00041 
00042 /************************************************************************/
00043 /*                              GDALJP2Box                              */
00044 /************************************************************************/
00045 
00046 class CPL_DLL GDALJP2Box
00047 {
00048 
00049     VSILFILE   *fpVSIL;
00050 
00051     char        szBoxType[5];
00052 
00053     GIntBig     nBoxOffset;
00054     GIntBig     nBoxLength;
00055 
00056     GIntBig     nDataOffset;
00057 
00058     GByte       abyUUID[16];
00059 
00060     GByte      *pabyData;
00061 
00062 public:
00063     explicit    GDALJP2Box( VSILFILE * = NULL );
00064                 ~GDALJP2Box();
00065 
00066     int         SetOffset( GIntBig nNewOffset );
00067     int         ReadBox();
00068 
00069     int         ReadFirst();
00070     int         ReadNext();
00071 
00072     int         ReadFirstChild( GDALJP2Box *poSuperBox );
00073     int         ReadNextChild( GDALJP2Box *poSuperBox );
00074 
00075     GIntBig     GetBoxOffset() const { return nBoxOffset; }
00076     GIntBig     GetBoxLength() const { return nBoxLength; }
00077 
00078     GIntBig     GetDataOffset() const { return nDataOffset; }
00079     GIntBig     GetDataLength();
00080 
00081     const char *GetType() { return szBoxType; }
00082 
00083     GByte      *ReadBoxData();
00084 
00085     int         IsSuperBox();
00086 
00087     int         DumpReadable( FILE *, int nIndentLevel = 0 );
00088 
00089     VSILFILE   *GetFILE() { return fpVSIL; }
00090 
00091     const GByte *GetUUID() { return abyUUID; }
00092 
00093     // write support
00094     void        SetType( const char * );
00095     void        SetWritableData( int nLength, const GByte *pabyData );
00096     void        AppendWritableData( int nLength, const void *pabyDataIn );
00097     void        AppendUInt32( GUInt32 nVal );
00098     void        AppendUInt16( GUInt16 nVal );
00099     void        AppendUInt8( GByte nVal );
00100     const GByte*GetWritableData() { return pabyData; }
00101 
00102     // factory methods.
00103     static GDALJP2Box *CreateSuperBox( const char* pszType,
00104                                        int nCount, GDALJP2Box **papoBoxes );
00105     static GDALJP2Box *CreateAsocBox( int nCount, GDALJP2Box **papoBoxes );
00106     static GDALJP2Box *CreateLblBox( const char *pszLabel );
00107     static GDALJP2Box *CreateLabelledXMLAssoc( const char *pszLabel,
00108                                                const char *pszXML );
00109     static GDALJP2Box *CreateUUIDBox( const GByte *pabyUUID,
00110                                       int nDataSize, const GByte *pabyData );
00111 };
00112 
00113 /************************************************************************/
00114 /*                           GDALJP2Metadata                            */
00115 /************************************************************************/
00116 
00117 typedef struct _GDALJP2GeoTIFFBox GDALJP2GeoTIFFBox;
00118 
00119 class CPL_DLL GDALJP2Metadata
00120 
00121 {
00122 private:
00123     void    CollectGMLData( GDALJP2Box * );
00124     int     GMLSRSLookup( const char *pszURN );
00125 
00126     int    nGeoTIFFBoxesCount;
00127     GDALJP2GeoTIFFBox  *pasGeoTIFFBoxes;
00128 
00129     int    nMSIGSize;
00130     GByte  *pabyMSIGData;
00131 
00132     int      GetGMLJP2GeoreferencingInfo( int& nEPSGCode,
00133                                           double adfOrigin[2],
00134                                           double adfXVector[2],
00135                                           double adfYVector[2],
00136                                           const char*& pszComment,
00137                                           CPLString& osDictBox,
00138                                           int& bNeedAxisFlip );
00139     static CPLXMLNode* CreateGDALMultiDomainMetadataXML(
00140                                        GDALDataset* poSrcDS,
00141                                        int bMainMDDomainOnly );
00142 
00143 public:
00144     char  **papszGMLMetadata;
00145 
00146     bool    bHaveGeoTransform;
00147     double  adfGeoTransform[6];
00148     bool    bPixelIsPoint;
00149 
00150     char   *pszProjection;
00151 
00152     int         nGCPCount;
00153     GDAL_GCP    *pasGCPList;
00154 
00155     char **papszRPCMD;
00156 
00157     char  **papszMetadata; /* TIFFTAG_?RESOLUTION* for now from resd box */
00158     char   *pszXMPMetadata;
00159     char   *pszGDALMultiDomainMetadata; /* as serialized XML */
00160     char   *pszXMLIPR; /* if an IPR box with XML content has been found */
00161 
00162 public:
00163             GDALJP2Metadata();
00164             ~GDALJP2Metadata();
00165 
00166     int     ReadBoxes( VSILFILE * fpVSIL );
00167 
00168     int     ParseJP2GeoTIFF();
00169     int     ParseMSIG();
00170     int     ParseGMLCoverageDesc();
00171 
00172     int     ReadAndParse( VSILFILE * fpVSIL,
00173                           int nGEOJP2Index = 0, int nGMLJP2Index = 1,
00174                           int nMSIGIndex = 2, int *pnIndexUsed = NULL );
00175     int     ReadAndParse( const char *pszFilename, int nGEOJP2Index = 0,
00176                           int nGMLJP2Index = 1, int nMSIGIndex = 2,
00177                           int nWorldFileIndex = 3, int *pnIndexUsed = NULL );
00178 
00179     // Write oriented.
00180     void    SetProjection( const char *pszWKT );
00181     void    SetGeoTransform( double * );
00182     void    SetGCPs( int, const GDAL_GCP * );
00183     void    SetRPCMD( char** papszRPCMDIn );
00184 
00185     GDALJP2Box *CreateJP2GeoTIFF();
00186     GDALJP2Box *CreateGMLJP2( int nXSize, int nYSize );
00187     GDALJP2Box *CreateGMLJP2V2( int nXSize, int nYSize,
00188                                 const char* pszDefFilename,
00189                                 GDALDataset* poSrcDS );
00190 
00191     static GDALJP2Box* CreateGDALMultiDomainMetadataXMLBox(
00192                                        GDALDataset* poSrcDS,
00193                                        int bMainMDDomainOnly );
00194     static GDALJP2Box** CreateXMLBoxes( GDALDataset* poSrcDS,
00195                                         int* pnBoxes );
00196     static GDALJP2Box *CreateXMPBox ( GDALDataset* poSrcDS );
00197     static GDALJP2Box *CreateIPRBox ( GDALDataset* poSrcDS );
00198     static int   IsUUID_MSI(const GByte *abyUUID);
00199     static int   IsUUID_XMP(const GByte *abyUUID);
00200 };
00201 
00202 #endif /* #ifndef DOXYGEN_SKIP */
00203 
00204 #endif /* ndef GDAL_JP2READER_H_INCLUDED */

Generated for GDAL by doxygen 1.7.6.1.