gooderp18绿色标准版
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

209 lines
7.4KB

  1. /******************************************************************************
  2. * $Id: gdaljp2metadata.h e37e476c4cf8f4b0df8995e0d95d5d672fca1a9b 2018-05-05 16:54:18 +0200 Even 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. #ifndef GDAL_JP2READER_H_INCLUDED
  31. #define GDAL_JP2READER_H_INCLUDED
  32. #ifndef DOXYGEN_SKIP
  33. #include "cpl_conv.h"
  34. #include "cpl_minixml.h"
  35. #include "cpl_vsi.h"
  36. #include "gdal.h"
  37. #include "gdal_priv.h"
  38. /************************************************************************/
  39. /* GDALJP2Box */
  40. /************************************************************************/
  41. class CPL_DLL GDALJP2Box
  42. {
  43. VSILFILE *fpVSIL;
  44. char szBoxType[5];
  45. GIntBig nBoxOffset;
  46. GIntBig nBoxLength;
  47. GIntBig nDataOffset;
  48. GByte abyUUID[16];
  49. GByte *pabyData;
  50. CPL_DISALLOW_COPY_ASSIGN(GDALJP2Box)
  51. public:
  52. explicit GDALJP2Box( VSILFILE * = nullptr );
  53. ~GDALJP2Box();
  54. int SetOffset( GIntBig nNewOffset );
  55. int ReadBox();
  56. int ReadFirst();
  57. int ReadNext();
  58. int ReadFirstChild( GDALJP2Box *poSuperBox );
  59. int ReadNextChild( GDALJP2Box *poSuperBox );
  60. GIntBig GetBoxOffset() const { return nBoxOffset; }
  61. GIntBig GetBoxLength() const { return nBoxLength; }
  62. GIntBig GetDataOffset() const { return nDataOffset; }
  63. GIntBig GetDataLength();
  64. const char *GetType() { return szBoxType; }
  65. GByte *ReadBoxData();
  66. int IsSuperBox();
  67. int DumpReadable( FILE *, int nIndentLevel = 0 );
  68. VSILFILE *GetFILE() { return fpVSIL; }
  69. const GByte *GetUUID() { return abyUUID; }
  70. // write support
  71. void SetType( const char * );
  72. void SetWritableData( int nLength, const GByte *pabyData );
  73. void AppendWritableData( int nLength, const void *pabyDataIn );
  74. void AppendUInt32( GUInt32 nVal );
  75. void AppendUInt16( GUInt16 nVal );
  76. void AppendUInt8( GByte nVal );
  77. const GByte*GetWritableData() { return pabyData; }
  78. // factory methods.
  79. static GDALJP2Box *CreateSuperBox( const char* pszType,
  80. int nCount, GDALJP2Box **papoBoxes );
  81. static GDALJP2Box *CreateAsocBox( int nCount, GDALJP2Box **papoBoxes );
  82. static GDALJP2Box *CreateLblBox( const char *pszLabel );
  83. static GDALJP2Box *CreateLabelledXMLAssoc( const char *pszLabel,
  84. const char *pszXML );
  85. static GDALJP2Box *CreateUUIDBox( const GByte *pabyUUID,
  86. int nDataSize, const GByte *pabyData );
  87. };
  88. /************************************************************************/
  89. /* GDALJP2Metadata */
  90. /************************************************************************/
  91. typedef struct _GDALJP2GeoTIFFBox GDALJP2GeoTIFFBox;
  92. class CPL_DLL GDALJP2Metadata
  93. {
  94. private:
  95. void CollectGMLData( GDALJP2Box * );
  96. int GMLSRSLookup( const char *pszURN );
  97. int nGeoTIFFBoxesCount;
  98. GDALJP2GeoTIFFBox *pasGeoTIFFBoxes;
  99. int nMSIGSize;
  100. GByte *pabyMSIGData;
  101. int GetGMLJP2GeoreferencingInfo( int& nEPSGCode,
  102. double adfOrigin[2],
  103. double adfXVector[2],
  104. double adfYVector[2],
  105. const char*& pszComment,
  106. CPLString& osDictBox,
  107. int& bNeedAxisFlip );
  108. static CPLXMLNode* CreateGDALMultiDomainMetadataXML(
  109. GDALDataset* poSrcDS,
  110. int bMainMDDomainOnly );
  111. CPL_DISALLOW_COPY_ASSIGN(GDALJP2Metadata)
  112. public:
  113. char **papszGMLMetadata;
  114. bool bHaveGeoTransform;
  115. double adfGeoTransform[6];
  116. bool bPixelIsPoint;
  117. char *pszProjection;
  118. int nGCPCount;
  119. GDAL_GCP *pasGCPList;
  120. char **papszRPCMD;
  121. char **papszMetadata; /* TIFFTAG_?RESOLUTION* for now from resd box */
  122. char *pszXMPMetadata;
  123. char *pszGDALMultiDomainMetadata; /* as serialized XML */
  124. char *pszXMLIPR; /* if an IPR box with XML content has been found */
  125. public:
  126. GDALJP2Metadata();
  127. ~GDALJP2Metadata();
  128. int ReadBoxes( VSILFILE * fpVSIL );
  129. int ParseJP2GeoTIFF();
  130. int ParseMSIG();
  131. int ParseGMLCoverageDesc();
  132. int ReadAndParse( VSILFILE * fpVSIL,
  133. int nGEOJP2Index = 0, int nGMLJP2Index = 1,
  134. int nMSIGIndex = 2, int *pnIndexUsed = nullptr );
  135. int ReadAndParse( const char *pszFilename, int nGEOJP2Index = 0,
  136. int nGMLJP2Index = 1, int nMSIGIndex = 2,
  137. int nWorldFileIndex = 3, int *pnIndexUsed = nullptr );
  138. // Write oriented.
  139. void SetProjection( const char *pszWKT );
  140. void SetGeoTransform( double * );
  141. void SetGCPs( int, const GDAL_GCP * );
  142. void SetRPCMD( char** papszRPCMDIn );
  143. GDALJP2Box *CreateJP2GeoTIFF();
  144. GDALJP2Box *CreateGMLJP2( int nXSize, int nYSize );
  145. GDALJP2Box *CreateGMLJP2V2( int nXSize, int nYSize,
  146. const char* pszDefFilename,
  147. GDALDataset* poSrcDS );
  148. static GDALJP2Box* CreateGDALMultiDomainMetadataXMLBox(
  149. GDALDataset* poSrcDS,
  150. int bMainMDDomainOnly );
  151. static GDALJP2Box** CreateXMLBoxes( GDALDataset* poSrcDS,
  152. int* pnBoxes );
  153. static GDALJP2Box *CreateXMPBox ( GDALDataset* poSrcDS );
  154. static GDALJP2Box *CreateIPRBox ( GDALDataset* poSrcDS );
  155. static int IsUUID_MSI(const GByte *abyUUID);
  156. static int IsUUID_XMP(const GByte *abyUUID);
  157. };
  158. #endif /* #ifndef DOXYGEN_SKIP */
  159. #endif /* ndef GDAL_JP2READER_H_INCLUDED */
上海开阖软件有限公司 沪ICP备12045867号-1