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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #ifndef _JP2READER_H_INCLUDED
00053 #define _JP2READER_H_INCLUDED
00054
00055 #include "cpl_conv.h"
00056 #include "cpl_vsi.h"
00057 #include "gdal.h"
00058
00059
00060
00061
00062
00063 class CPL_DLL GDALJP2Box
00064 {
00065
00066 FILE *fpVSIL;
00067
00068 char szBoxType[5];
00069
00070 GIntBig nBoxOffset;
00071 GIntBig nBoxLength;
00072
00073 GIntBig nDataOffset;
00074
00075 GByte abyUUID[16];
00076
00077 GByte *pabyData;
00078
00079 public:
00080 GDALJP2Box( FILE * = NULL );
00081 ~GDALJP2Box();
00082
00083 int SetOffset( GIntBig nNewOffset );
00084 int ReadBox();
00085
00086 int ReadFirst();
00087 int ReadNext();
00088
00089 int ReadFirstChild( GDALJP2Box *poSuperBox );
00090 int ReadNextChild( GDALJP2Box *poSuperBox );
00091
00092 GIntBig GetDataLength();
00093 const char *GetType() { return szBoxType; }
00094
00095 GByte *ReadBoxData();
00096
00097 int IsSuperBox();
00098
00099 int DumpReadable( FILE * );
00100
00101 FILE *GetFILE() { return fpVSIL; }
00102
00103 const GByte *GetUUID() { return abyUUID; }
00104
00105
00106 void SetType( const char * );
00107 void SetWritableData( int nLength, const GByte *pabyData );
00108 const GByte*GetWritableData() { return pabyData; }
00109
00110
00111 static GDALJP2Box *CreateAsocBox( int nCount, GDALJP2Box **papoBoxes );
00112 static GDALJP2Box *CreateLblBox( const char *pszLabel );
00113 static GDALJP2Box *CreateLabelledXMLAssoc( const char *pszLabel,
00114 const char *pszXML );
00115 static GDALJP2Box *CreateUUIDBox( const GByte *pabyUUID,
00116 int nDataSize, GByte *pabyData );
00117 };
00118
00119
00120
00121
00122
00123 class CPL_DLL GDALJP2Metadata
00124
00125 {
00126 private:
00127 void CollectGMLData( GDALJP2Box * );
00128 int GMLSRSLookup( const char *pszURN );
00129
00130 int nGeoTIFFSize;
00131 GByte *pabyGeoTIFFData;
00132
00133 int nMSIGSize;
00134 GByte *pabyMSIGData;
00135
00136 public:
00137 char **papszGMLMetadata;
00138
00139 int bHaveGeoTransform;
00140 double adfGeoTransform[6];
00141
00142 char *pszProjection;
00143
00144 int nGCPCount;
00145 GDAL_GCP *pasGCPList;
00146
00147 public:
00148 GDALJP2Metadata();
00149 ~GDALJP2Metadata();
00150
00151 int ReadBoxes( FILE * fpVSIL );
00152
00153 int ParseJP2GeoTIFF();
00154 int ParseMSIG();
00155 int ParseGMLCoverageDesc();
00156
00157 int ReadAndParse( const char *pszFilename );
00158
00159
00160 void SetProjection( const char *pszWKT );
00161 void SetGeoTransform( double * );
00162 void SetGCPs( int, const GDAL_GCP * );
00163
00164 GDALJP2Box *CreateJP2GeoTIFF();
00165 GDALJP2Box *CreateGMLJP2( int nXSize, int nYSize );
00166 };
00167
00168
00169
00170 #endif
00171
00172