00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef GDAL_JP2READER_H_INCLUDED
00031 #define GDAL_JP2READER_H_INCLUDED
00032
00033 #include "cpl_conv.h"
00034 #include "cpl_vsi.h"
00035 #include "gdal.h"
00036
00037
00038
00039
00040
00041 class CPL_DLL GDALJP2Box
00042 {
00043
00044 FILE *fpVSIL;
00045
00046 char szBoxType[5];
00047
00048 GIntBig nBoxOffset;
00049 GIntBig nBoxLength;
00050
00051 GIntBig nDataOffset;
00052
00053 GByte abyUUID[16];
00054
00055 GByte *pabyData;
00056
00057 public:
00058 GDALJP2Box( FILE * = NULL );
00059 ~GDALJP2Box();
00060
00061 int SetOffset( GIntBig nNewOffset );
00062 int ReadBox();
00063
00064 int ReadFirst();
00065 int ReadNext();
00066
00067 int ReadFirstChild( GDALJP2Box *poSuperBox );
00068 int ReadNextChild( GDALJP2Box *poSuperBox );
00069
00070 GIntBig GetDataLength();
00071 const char *GetType() { return szBoxType; }
00072
00073 GByte *ReadBoxData();
00074
00075 int IsSuperBox();
00076
00077 int DumpReadable( FILE * );
00078
00079 FILE *GetFILE() { return fpVSIL; }
00080
00081 const GByte *GetUUID() { return abyUUID; }
00082
00083
00084 void SetType( const char * );
00085 void SetWritableData( int nLength, const GByte *pabyData );
00086 const GByte*GetWritableData() { return pabyData; }
00087
00088
00089 static GDALJP2Box *CreateAsocBox( int nCount, GDALJP2Box **papoBoxes );
00090 static GDALJP2Box *CreateLblBox( const char *pszLabel );
00091 static GDALJP2Box *CreateLabelledXMLAssoc( const char *pszLabel,
00092 const char *pszXML );
00093 static GDALJP2Box *CreateUUIDBox( const GByte *pabyUUID,
00094 int nDataSize, GByte *pabyData );
00095 };
00096
00097
00098
00099
00100
00101 class CPL_DLL GDALJP2Metadata
00102
00103 {
00104 private:
00105 void CollectGMLData( GDALJP2Box * );
00106 int GMLSRSLookup( const char *pszURN );
00107
00108 int nGeoTIFFSize;
00109 GByte *pabyGeoTIFFData;
00110
00111 int nMSIGSize;
00112 GByte *pabyMSIGData;
00113
00114 public:
00115 char **papszGMLMetadata;
00116
00117 int bHaveGeoTransform;
00118 double adfGeoTransform[6];
00119
00120 char *pszProjection;
00121
00122 int nGCPCount;
00123 GDAL_GCP *pasGCPList;
00124
00125 public:
00126 GDALJP2Metadata();
00127 ~GDALJP2Metadata();
00128
00129 int ReadBoxes( FILE * fpVSIL );
00130
00131 int ParseJP2GeoTIFF();
00132 int ParseMSIG();
00133 int ParseGMLCoverageDesc();
00134
00135 int ReadAndParse( const char *pszFilename );
00136
00137
00138 void SetProjection( const char *pszWKT );
00139 void SetGeoTransform( double * );
00140 void SetGCPs( int, const GDAL_GCP * );
00141
00142 GDALJP2Box *CreateJP2GeoTIFF();
00143 GDALJP2Box *CreateGMLJP2( int nXSize, int nYSize );
00144 };
00145
00146 #endif