gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

230 lines
9.2KB

  1. /******************************************************************************
  2. * $Id: memdataset.h 8e5eeb35bf76390e3134a4ea7076dab7d478ea0e 2018-11-14 22:55:13 +0100 Even Rouault $
  3. *
  4. * Project: Memory Array Translator
  5. * Purpose: Declaration of MEMDataset, and MEMRasterBand.
  6. * Author: Frank Warmerdam, warmerdam@pobox.com
  7. *
  8. ******************************************************************************
  9. * Copyright (c) 2000, Frank Warmerdam
  10. *
  11. * Permission is hereby granted, free of charge, to any person obtaining a
  12. * copy of this software and associated documentation files (the "Software"),
  13. * to deal in the Software without restriction, including without limitation
  14. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  15. * and/or sell copies of the Software, and to permit persons to whom the
  16. * Software is furnished to do so, subject to the following conditions:
  17. *
  18. * The above copyright notice and this permission notice shall be included
  19. * in all copies or substantial portions of the Software.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  22. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  24. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  26. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  27. * DEALINGS IN THE SOFTWARE.
  28. ****************************************************************************/
  29. #ifndef MEMDATASET_H_INCLUDED
  30. #define MEMDATASET_H_INCLUDED
  31. #include "gdal_pam.h"
  32. #include "gdal_priv.h"
  33. #include "gdal_rat.h"
  34. #include <memory>
  35. CPL_C_START
  36. /* Caution: if changing this prototype, also change in swig/include/gdal_python.i
  37. where it is redefined */
  38. GDALRasterBandH CPL_DLL MEMCreateRasterBand( GDALDataset *, int, GByte *,
  39. GDALDataType, int, int, int );
  40. GDALRasterBandH CPL_DLL MEMCreateRasterBandEx( GDALDataset *, int, GByte *,
  41. GDALDataType, GSpacing, GSpacing,
  42. int );
  43. CPL_C_END
  44. /************************************************************************/
  45. /* MEMDataset */
  46. /************************************************************************/
  47. class MEMRasterBand;
  48. class CPL_DLL MEMDataset : public GDALDataset
  49. {
  50. CPL_DISALLOW_COPY_ASSIGN(MEMDataset)
  51. friend class MEMRasterBand;
  52. int bGeoTransformSet;
  53. double adfGeoTransform[6];
  54. char *pszProjection;
  55. int m_nGCPCount;
  56. GDAL_GCP *m_pasGCPs;
  57. CPLString osGCPProjection;
  58. int m_nOverviewDSCount;
  59. GDALDataset **m_papoOverviewDS;
  60. #if 0
  61. protected:
  62. virtual int EnterReadWrite(GDALRWFlag eRWFlag);
  63. virtual void LeaveReadWrite();
  64. #endif
  65. public:
  66. MEMDataset();
  67. virtual ~MEMDataset();
  68. const char *_GetProjectionRef(void) override;
  69. CPLErr _SetProjection( const char * ) override;
  70. const OGRSpatialReference* GetSpatialRef() const override {
  71. return GetSpatialRefFromOldGetProjectionRef();
  72. }
  73. CPLErr SetSpatialRef(const OGRSpatialReference* poSRS) override {
  74. return OldSetProjectionFromSetSpatialRef(poSRS);
  75. }
  76. virtual CPLErr GetGeoTransform( double * ) override;
  77. virtual CPLErr SetGeoTransform( double * ) override;
  78. virtual void *GetInternalHandle( const char * ) override;
  79. virtual int GetGCPCount() override;
  80. const char *_GetGCPProjection() override;
  81. const OGRSpatialReference* GetGCPSpatialRef() const override {
  82. return GetGCPSpatialRefFromOldGetGCPProjection();
  83. }
  84. virtual const GDAL_GCP *GetGCPs() override;
  85. CPLErr _SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
  86. const char *pszGCPProjection ) override;
  87. using GDALDataset::SetGCPs;
  88. CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
  89. const OGRSpatialReference* poSRS ) override {
  90. return OldSetGCPsFromNew(nGCPCount, pasGCPList, poSRS);
  91. }
  92. virtual CPLErr AddBand( GDALDataType eType,
  93. char **papszOptions=nullptr ) override;
  94. virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
  95. int nXOff, int nYOff, int nXSize, int nYSize,
  96. void * pData, int nBufXSize, int nBufYSize,
  97. GDALDataType eBufType,
  98. int nBandCount, int *panBandMap,
  99. GSpacing nPixelSpaceBuf,
  100. GSpacing nLineSpaceBuf,
  101. GSpacing nBandSpaceBuf,
  102. GDALRasterIOExtraArg* psExtraArg) override;
  103. virtual CPLErr IBuildOverviews( const char *pszResampling,
  104. int nOverviews, int *panOverviewList,
  105. int nListBands, int *panBandList,
  106. GDALProgressFunc pfnProgress,
  107. void * pProgressData ) override;
  108. virtual CPLErr CreateMaskBand( int nFlagsIn ) override;
  109. static GDALDataset *Open( GDALOpenInfo * );
  110. static GDALDataset *Create( const char * pszFilename,
  111. int nXSize, int nYSize, int nBands,
  112. GDALDataType eType, char ** papszParmList );
  113. };
  114. /************************************************************************/
  115. /* MEMRasterBand */
  116. /************************************************************************/
  117. class CPL_DLL MEMRasterBand : public GDALPamRasterBand
  118. {
  119. private:
  120. MEMRasterBand( GByte *pabyDataIn, GDALDataType eTypeIn,
  121. int nXSizeIn, int nYSizeIn );
  122. CPL_DISALLOW_COPY_ASSIGN(MEMRasterBand)
  123. protected:
  124. friend class MEMDataset;
  125. GByte *pabyData;
  126. GSpacing nPixelOffset;
  127. GSpacing nLineOffset;
  128. int bOwnData;
  129. int bNoDataSet;
  130. double dfNoData;
  131. std::unique_ptr<GDALColorTable> m_poColorTable;
  132. GDALColorInterp eColorInterp;
  133. CPLString m_osUnitType;
  134. CPLStringList m_aosCategoryNames;
  135. double dfOffset;
  136. double dfScale;
  137. CPLXMLNode *psSavedHistograms;
  138. std::unique_ptr<GDALRasterAttributeTable> m_poRAT;
  139. public:
  140. MEMRasterBand( GDALDataset *poDS, int nBand,
  141. GByte *pabyData, GDALDataType eType,
  142. GSpacing nPixelOffset, GSpacing nLineOffset,
  143. int bAssumeOwnership,
  144. const char * pszPixelType = nullptr );
  145. virtual ~MEMRasterBand();
  146. virtual CPLErr IReadBlock( int, int, void * ) override;
  147. virtual CPLErr IWriteBlock( int, int, void * ) override;
  148. virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
  149. int nXOff, int nYOff, int nXSize, int nYSize,
  150. void * pData, int nBufXSize, int nBufYSize,
  151. GDALDataType eBufType,
  152. GSpacing nPixelSpaceBuf,
  153. GSpacing nLineSpaceBuf,
  154. GDALRasterIOExtraArg* psExtraArg ) override;
  155. virtual double GetNoDataValue( int *pbSuccess = nullptr ) override;
  156. virtual CPLErr SetNoDataValue( double ) override;
  157. virtual CPLErr DeleteNoDataValue() override;
  158. virtual GDALColorInterp GetColorInterpretation() override;
  159. virtual GDALColorTable *GetColorTable() override;
  160. virtual CPLErr SetColorTable( GDALColorTable * ) override;
  161. virtual GDALRasterAttributeTable *GetDefaultRAT() override;
  162. virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * poRAT ) override;
  163. virtual CPLErr SetColorInterpretation( GDALColorInterp ) override;
  164. virtual const char *GetUnitType() override;
  165. CPLErr SetUnitType( const char * ) override;
  166. virtual char **GetCategoryNames() override;
  167. virtual CPLErr SetCategoryNames( char ** ) override;
  168. virtual double GetOffset( int *pbSuccess = nullptr ) override;
  169. CPLErr SetOffset( double ) override;
  170. virtual double GetScale( int *pbSuccess = nullptr ) override;
  171. CPLErr SetScale( double ) override;
  172. virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
  173. int nBuckets, GUIntBig *panHistogram ) override;
  174. virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
  175. int *pnBuckets,
  176. GUIntBig ** ppanHistogram,
  177. int bForce,
  178. GDALProgressFunc, void *pProgressData) override;
  179. virtual int GetOverviewCount() override;
  180. virtual GDALRasterBand *GetOverview(int) override;
  181. virtual CPLErr CreateMaskBand( int nFlagsIn ) override;
  182. // Allow access to MEM driver's private internal memory buffer.
  183. GByte *GetData() const { return(pabyData); }
  184. };
  185. #endif /* ndef MEMDATASET_H_INCLUDED */
上海开阖软件有限公司 沪ICP备12045867号-1