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.

349 line
13KB

  1. /******************************************************************************
  2. * $Id: gdal_pam.h 8e5eeb35bf76390e3134a4ea7076dab7d478ea0e 2018-11-14 22:55:13 +0100 Even Rouault $
  3. *
  4. * Project: GDAL Core
  5. * Purpose: Declaration for Peristable Auxiliary Metadata classes.
  6. * Author: Frank Warmerdam, warmerdam@pobox.com
  7. *
  8. ******************************************************************************
  9. * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
  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 GDAL_PAM_H_INCLUDED
  30. #define GDAL_PAM_H_INCLUDED
  31. //! @cond Doxygen_Suppress
  32. #include "gdal_priv.h"
  33. class GDALPamRasterBand;
  34. /* Clone Info Flags */
  35. #define GCIF_GEOTRANSFORM 0x01
  36. #define GCIF_PROJECTION 0x02
  37. #define GCIF_METADATA 0x04
  38. #define GCIF_GCPS 0x08
  39. #define GCIF_NODATA 0x001000
  40. #define GCIF_CATEGORYNAMES 0x002000
  41. #define GCIF_MINMAX 0x004000
  42. #define GCIF_SCALEOFFSET 0x008000
  43. #define GCIF_UNITTYPE 0x010000
  44. #define GCIF_COLORTABLE 0x020000
  45. #define GCIF_COLORINTERP 0x020000
  46. #define GCIF_BAND_METADATA 0x040000
  47. #define GCIF_RAT 0x080000
  48. #define GCIF_MASK 0x100000
  49. #define GCIF_BAND_DESCRIPTION 0x200000
  50. #define GCIF_ONLY_IF_MISSING 0x10000000
  51. #define GCIF_PROCESS_BANDS 0x20000000
  52. #define GCIF_PAM_DEFAULT (GCIF_GEOTRANSFORM | GCIF_PROJECTION | \
  53. GCIF_METADATA | GCIF_GCPS | \
  54. GCIF_NODATA | GCIF_CATEGORYNAMES | \
  55. GCIF_MINMAX | GCIF_SCALEOFFSET | \
  56. GCIF_UNITTYPE | GCIF_COLORTABLE | \
  57. GCIF_COLORINTERP | GCIF_BAND_METADATA | \
  58. GCIF_RAT | GCIF_MASK | \
  59. GCIF_ONLY_IF_MISSING | GCIF_PROCESS_BANDS|\
  60. GCIF_BAND_DESCRIPTION)
  61. /* GDAL PAM Flags */
  62. /* ERO 2011/04/13 : GPF_AUXMODE seems to be unimplemented */
  63. #define GPF_DIRTY 0x01 // .pam file needs to be written on close
  64. #define GPF_TRIED_READ_FAILED 0x02 // no need to keep trying to read .pam.
  65. #define GPF_DISABLED 0x04 // do not try any PAM stuff.
  66. #define GPF_AUXMODE 0x08 // store info in .aux (HFA) file.
  67. #define GPF_NOSAVE 0x10 // do not try to save pam info.
  68. /* ==================================================================== */
  69. /* GDALDatasetPamInfo */
  70. /* */
  71. /* We make these things a separate structure of information */
  72. /* primarily so we can modify it without altering the size of */
  73. /* the GDALPamDataset. It is an effort to reduce ABI churn for */
  74. /* driver plugins. */
  75. /* ==================================================================== */
  76. class GDALDatasetPamInfo
  77. {
  78. public:
  79. char *pszPamFilename = nullptr;
  80. OGRSpatialReference* poSRS = nullptr;
  81. int bHaveGeoTransform = false;
  82. double adfGeoTransform[6]{0,0,0,0,0,0};
  83. int nGCPCount = 0;
  84. GDAL_GCP *pasGCPList = nullptr;
  85. OGRSpatialReference* poGCP_SRS = nullptr;
  86. CPLString osPhysicalFilename{};
  87. CPLString osSubdatasetName{};
  88. CPLString osAuxFilename{};
  89. int bHasMetadata = false;
  90. };
  91. //! @endcond
  92. /* ******************************************************************** */
  93. /* GDALPamDataset */
  94. /* ******************************************************************** */
  95. /** PAM dataset */
  96. class CPL_DLL GDALPamDataset : public GDALDataset
  97. {
  98. friend class GDALPamRasterBand;
  99. private:
  100. int IsPamFilenameAPotentialSiblingFile();
  101. protected:
  102. GDALPamDataset(void);
  103. //! @cond Doxygen_Suppress
  104. int nPamFlags = 0;
  105. GDALDatasetPamInfo *psPam = nullptr;
  106. virtual const char *_GetProjectionRef() override;
  107. virtual const char *_GetGCPProjection() override;
  108. virtual CPLErr _SetProjection( const char * pszProjection ) override;
  109. virtual CPLErr _SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
  110. const char *pszGCPProjection ) override;
  111. virtual CPLXMLNode *SerializeToXML( const char *);
  112. virtual CPLErr XMLInit( CPLXMLNode *, const char * );
  113. virtual CPLErr TryLoadXML(char **papszSiblingFiles = nullptr);
  114. virtual CPLErr TrySaveXML();
  115. CPLErr TryLoadAux(char **papszSiblingFiles = nullptr);
  116. CPLErr TrySaveAux();
  117. virtual const char *BuildPamFilename();
  118. void PamInitialize();
  119. void PamClear();
  120. void SetPhysicalFilename( const char * );
  121. const char *GetPhysicalFilename();
  122. void SetSubdatasetName( const char *);
  123. const char *GetSubdatasetName();
  124. //! @endcond
  125. public:
  126. ~GDALPamDataset() override;
  127. void FlushCache(void) override;
  128. const OGRSpatialReference* GetSpatialRef() const override;
  129. CPLErr SetSpatialRef(const OGRSpatialReference* poSRS) override;
  130. CPLErr GetGeoTransform( double * ) override;
  131. CPLErr SetGeoTransform( double * ) override;
  132. int GetGCPCount() override;
  133. const OGRSpatialReference* GetGCPSpatialRef() const override;
  134. const GDAL_GCP *GetGCPs() override;
  135. using GDALDataset::SetGCPs;
  136. CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
  137. const OGRSpatialReference* poSRS ) override;
  138. CPLErr SetMetadata( char ** papszMetadata,
  139. const char * pszDomain = "" ) override;
  140. CPLErr SetMetadataItem( const char * pszName,
  141. const char * pszValue,
  142. const char * pszDomain = "" ) override;
  143. char **GetMetadata( const char * pszDomain = "" ) override;
  144. const char *GetMetadataItem( const char * pszName,
  145. const char * pszDomain = "" ) override;
  146. char **GetFileList(void) override;
  147. //! @cond Doxygen_Suppress
  148. virtual CPLErr CloneInfo( GDALDataset *poSrcDS, int nCloneInfoFlags );
  149. CPLErr IBuildOverviews( const char *pszResampling,
  150. int nOverviews, int *panOverviewList,
  151. int nListBands, int *panBandList,
  152. GDALProgressFunc pfnProgress,
  153. void * pProgressData ) override;
  154. // "semi private" methods.
  155. void MarkPamDirty() { nPamFlags |= GPF_DIRTY; }
  156. GDALDatasetPamInfo *GetPamInfo() { return psPam; }
  157. int GetPamFlags() { return nPamFlags; }
  158. void SetPamFlags(int nValue ) { nPamFlags = nValue; }
  159. //! @endcond
  160. private:
  161. CPL_DISALLOW_COPY_ASSIGN(GDALPamDataset)
  162. };
  163. //! @cond Doxygen_Suppress
  164. /* ==================================================================== */
  165. /* GDALRasterBandPamInfo */
  166. /* */
  167. /* We make these things a separate structure of information */
  168. /* primarily so we can modify it without altering the size of */
  169. /* the GDALPamDataset. It is an effort to reduce ABI churn for */
  170. /* driver plugins. */
  171. /* ==================================================================== */
  172. typedef struct {
  173. GDALPamDataset *poParentDS;
  174. int bNoDataValueSet;
  175. double dfNoDataValue;
  176. GDALColorTable *poColorTable;
  177. GDALColorInterp eColorInterp;
  178. char *pszUnitType;
  179. char **papszCategoryNames;
  180. double dfOffset;
  181. double dfScale;
  182. int bHaveMinMax;
  183. double dfMin;
  184. double dfMax;
  185. int bHaveStats;
  186. double dfMean;
  187. double dfStdDev;
  188. CPLXMLNode *psSavedHistograms;
  189. GDALRasterAttributeTable *poDefaultRAT;
  190. } GDALRasterBandPamInfo;
  191. //! @endcond
  192. /* ******************************************************************** */
  193. /* GDALPamRasterBand */
  194. /* ******************************************************************** */
  195. /** PAM raster band */
  196. class CPL_DLL GDALPamRasterBand : public GDALRasterBand
  197. {
  198. friend class GDALPamDataset;
  199. protected:
  200. //! @cond Doxygen_Suppress
  201. virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
  202. virtual CPLErr XMLInit( CPLXMLNode *, const char * );
  203. void PamInitialize();
  204. void PamClear();
  205. GDALRasterBandPamInfo *psPam = nullptr;
  206. //! @endcond
  207. public:
  208. GDALPamRasterBand();
  209. //! @cond Doxygen_Suppress
  210. explicit GDALPamRasterBand(int bForceCachedIO);
  211. //! @endcond
  212. ~GDALPamRasterBand() override;
  213. void SetDescription( const char * ) override;
  214. CPLErr SetNoDataValue( double ) override;
  215. double GetNoDataValue( int *pbSuccess = nullptr ) override;
  216. CPLErr DeleteNoDataValue() override;
  217. CPLErr SetColorTable( GDALColorTable * ) override;
  218. GDALColorTable *GetColorTable() override;
  219. CPLErr SetColorInterpretation( GDALColorInterp ) override;
  220. GDALColorInterp GetColorInterpretation() override;
  221. const char *GetUnitType() override;
  222. CPLErr SetUnitType( const char * ) override;
  223. char **GetCategoryNames() override;
  224. CPLErr SetCategoryNames( char ** ) override;
  225. double GetOffset( int *pbSuccess = nullptr ) override;
  226. CPLErr SetOffset( double ) override;
  227. double GetScale( int *pbSuccess = nullptr ) override;
  228. CPLErr SetScale( double ) override;
  229. CPLErr GetHistogram( double dfMin, double dfMax,
  230. int nBuckets, GUIntBig * panHistogram,
  231. int bIncludeOutOfRange, int bApproxOK,
  232. GDALProgressFunc, void *pProgressData ) override;
  233. CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
  234. int *pnBuckets, GUIntBig ** ppanHistogram,
  235. int bForce,
  236. GDALProgressFunc, void *pProgressData) override;
  237. CPLErr SetDefaultHistogram( double dfMin, double dfMax,
  238. int nBuckets, GUIntBig *panHistogram ) override;
  239. CPLErr SetMetadata( char ** papszMetadata,
  240. const char * pszDomain = "" ) override;
  241. CPLErr SetMetadataItem( const char * pszName,
  242. const char * pszValue,
  243. const char * pszDomain = "" ) override;
  244. GDALRasterAttributeTable *GetDefaultRAT() override;
  245. CPLErr SetDefaultRAT( const GDALRasterAttributeTable * ) override;
  246. //! @cond Doxygen_Suppress
  247. // new in GDALPamRasterBand.
  248. virtual CPLErr CloneInfo( GDALRasterBand *poSrcBand, int nCloneInfoFlags );
  249. // "semi private" methods.
  250. GDALRasterBandPamInfo *GetPamInfo() { return psPam; }
  251. //! @endcond
  252. private:
  253. CPL_DISALLOW_COPY_ASSIGN(GDALPamRasterBand)
  254. };
  255. //! @cond Doxygen_Suppress
  256. // These are mainly helper functions for internal use.
  257. int CPL_DLL PamParseHistogram( CPLXMLNode *psHistItem,
  258. double *pdfMin, double *pdfMax,
  259. int *pnBuckets, GUIntBig **ppanHistogram,
  260. int *pbIncludeOutOfRange, int *pbApproxOK );
  261. CPLXMLNode CPL_DLL *
  262. PamFindMatchingHistogram( CPLXMLNode *psSavedHistograms,
  263. double dfMin, double dfMax, int nBuckets,
  264. int bIncludeOutOfRange, int bApproxOK );
  265. CPLXMLNode CPL_DLL *
  266. PamHistogramToXMLTree( double dfMin, double dfMax,
  267. int nBuckets, GUIntBig * panHistogram,
  268. int bIncludeOutOfRange, int bApprox );
  269. // For managing the proxy file database.
  270. const char CPL_DLL * PamGetProxy( const char * );
  271. const char CPL_DLL * PamAllocateProxy( const char * );
  272. const char CPL_DLL * PamDeallocateProxy( const char * );
  273. void CPL_DLL PamCleanProxyDB( void );
  274. //! @endcond
  275. #endif /* ndef GDAL_PAM_H_INCLUDED */
上海开阖软件有限公司 沪ICP备12045867号-1