GDAL
gdaljp2metadata.h
00001 /******************************************************************************
00002  * $Id: gdaljp2metadata.h 29210 2015-05-19 19:04:28Z 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 #include "cpl_conv.h"
00035 #include "cpl_vsi.h"
00036 #include "gdal.h"
00037 #include "gdal_priv.h"
00038 #include "cpl_minixml.h"
00039 
00040 /************************************************************************/
00041 /*                              GDALJP2Box                              */
00042 /************************************************************************/
00043 
00044 class CPL_DLL GDALJP2Box
00045 {
00046 
00047     VSILFILE   *fpVSIL;
00048 
00049     char        szBoxType[5];
00050 
00051     GIntBig     nBoxOffset;
00052     GIntBig     nBoxLength;
00053 
00054     GIntBig     nDataOffset;
00055 
00056     GByte       abyUUID[16];
00057 
00058     GByte      *pabyData;
00059 
00060 public:
00061                 GDALJP2Box( VSILFILE * = NULL );
00062                 ~GDALJP2Box();
00063 
00064     int         SetOffset( GIntBig nNewOffset );
00065     int         ReadBox();
00066 
00067     int         ReadFirst();
00068     int         ReadNext();
00069 
00070     int         ReadFirstChild( GDALJP2Box *poSuperBox );
00071     int         ReadNextChild( GDALJP2Box *poSuperBox );
00072 
00073     GIntBig     GetBoxOffset() const { return nBoxOffset; }
00074     GIntBig     GetBoxLength() const { return nBoxLength; }
00075 
00076     GIntBig     GetDataOffset() const { return nDataOffset; }
00077     GIntBig     GetDataLength();
00078 
00079     const char *GetType() { return szBoxType; }
00080     
00081     GByte      *ReadBoxData();
00082 
00083     int         IsSuperBox();
00084 
00085     int         DumpReadable( FILE *, int nIndentLevel = 0 );
00086 
00087     VSILFILE   *GetFILE() { return fpVSIL; }
00088 
00089     const GByte *GetUUID() { return abyUUID; }
00090 
00091     // write support
00092     void        SetType( const char * );
00093     void        SetWritableData( int nLength, const GByte *pabyData );
00094     void        AppendWritableData( int nLength, const void *pabyDataIn );
00095     void        AppendUInt32( GUInt32 nVal );
00096     void        AppendUInt16( GUInt16 nVal );
00097     void        AppendUInt8( GByte nVal );
00098     const GByte*GetWritableData() { return pabyData; }
00099 
00100     // factory methods.
00101     static GDALJP2Box *CreateSuperBox( const char* pszType,
00102                                        int nCount, GDALJP2Box **papoBoxes );
00103     static GDALJP2Box *CreateAsocBox( int nCount, GDALJP2Box **papoBoxes );
00104     static GDALJP2Box *CreateLblBox( const char *pszLabel );
00105     static GDALJP2Box *CreateLabelledXMLAssoc( const char *pszLabel,
00106                                                const char *pszXML );
00107     static GDALJP2Box *CreateUUIDBox( const GByte *pabyUUID, 
00108                                       int nDataSize, const GByte *pabyData );
00109 };
00110 
00111 /************************************************************************/
00112 /*                           GDALJP2Metadata                            */
00113 /************************************************************************/
00114 
00115 typedef struct _GDALJP2GeoTIFFBox GDALJP2GeoTIFFBox;
00116 
00117 class CPL_DLL GDALJP2Metadata
00118 
00119 {
00120 private:
00121     void    CollectGMLData( GDALJP2Box * );
00122     int     GMLSRSLookup( const char *pszURN );
00123 
00124     int    nGeoTIFFBoxesCount;
00125     GDALJP2GeoTIFFBox  *pasGeoTIFFBoxes;
00126 
00127     int    nMSIGSize;
00128     GByte  *pabyMSIGData;
00129     
00130     int      GetGMLJP2GeoreferencingInfo( int& nEPSGCode,
00131                                           double adfOrigin[2],
00132                                           double adfXVector[2],
00133                                           double adfYVector[2],
00134                                           const char*& pszComment,
00135                                           CPLString& osDictBox,
00136                                           int& bNeedAxisFlip );
00137     static CPLXMLNode* CreateGDALMultiDomainMetadataXML(
00138                                        GDALDataset* poSrcDS,
00139                                        int bMainMDDomainOnly );
00140 
00141 public:
00142     char  **papszGMLMetadata;
00143     
00144     int     bHaveGeoTransform;
00145     double  adfGeoTransform[6];
00146     int     bPixelIsPoint;
00147 
00148     char   *pszProjection;
00149 
00150     int         nGCPCount;
00151     GDAL_GCP    *pasGCPList;
00152     
00153     char **papszRPCMD;
00154 
00155     char  **papszMetadata; /* TIFFTAG_?RESOLUTION* for now from resd box */
00156     char   *pszXMPMetadata;
00157     char   *pszGDALMultiDomainMetadata; /* as serialized XML */
00158     char   *pszXMLIPR; /* if an IPR box with XML content has been found */
00159 
00160 public:
00161             GDALJP2Metadata();
00162             ~GDALJP2Metadata();
00163 
00164     int     ReadBoxes( VSILFILE * fpVSIL );
00165 
00166     int     ParseJP2GeoTIFF();
00167     int     ParseMSIG();
00168     int     ParseGMLCoverageDesc();
00169 
00170     int     ReadAndParse( VSILFILE * fpVSIL );
00171     int     ReadAndParse( const char *pszFilename );
00172 
00173     // Write oriented. 
00174     void    SetProjection( const char *pszWKT );
00175     void    SetGeoTransform( double * );
00176     void    SetGCPs( int, const GDAL_GCP * );
00177     void    SetRPCMD( char** papszRPCMDIn );
00178     
00179     GDALJP2Box *CreateJP2GeoTIFF();
00180     GDALJP2Box *CreateGMLJP2( int nXSize, int nYSize );
00181     GDALJP2Box *CreateGMLJP2V2( int nXSize, int nYSize,
00182                                 const char* pszDefFilename,
00183                                 GDALDataset* poSrcDS );
00184 
00185     static GDALJP2Box* CreateGDALMultiDomainMetadataXMLBox(
00186                                        GDALDataset* poSrcDS,
00187                                        int bMainMDDomainOnly );
00188     static GDALJP2Box** CreateXMLBoxes( GDALDataset* poSrcDS,
00189                                         int* pnBoxes );
00190     static GDALJP2Box *CreateXMPBox ( GDALDataset* poSrcDS );
00191     static GDALJP2Box *CreateIPRBox ( GDALDataset* poSrcDS );
00192     static int   IsUUID_MSI(const GByte *abyUUID);
00193     static int   IsUUID_XMP(const GByte *abyUUID);
00194 };
00195 
00196 #endif /* ndef GDAL_JP2READER_H_INCLUDED */

Generated for GDAL by doxygen 1.7.6.1.