Line data Source code
1 : /* 2 : * $Id$ 3 : * keaband.h 4 : * 5 : * Created by Pete Bunting on 01/08/2012. 6 : * Copyright 2012 LibKEA. All rights reserved. 7 : * 8 : * This file is part of LibKEA. 9 : * 10 : * SPDX-License-Identifier: MIT 11 : * 12 : */ 13 : 14 : #ifndef KEABAND_H 15 : #define KEABAND_H 16 : 17 : #include "gdal_priv.h" 18 : #include "keadataset.h" 19 : 20 : class KEAOverview; 21 : class KEAMaskBand; 22 : 23 : // Provides the implementation of a GDAL raster band 24 : class KEARasterBand CPL_NON_FINAL : public GDALRasterBand 25 : { 26 : private: 27 : LockedRefCount *m_pRefCount = nullptr; // reference count of m_pImageIO 28 : 29 : int m_nOverviews = 0; // number of overviews 30 : KEAOverview **m_panOverviewBands = nullptr; // array of overview objects 31 : GDALRasterBand *m_pMaskBand = 32 : nullptr; // pointer to mask band if one exists (and been requested) 33 : bool m_bMaskBandOwned = false; // do we delete it or not? 34 : 35 : GDALRasterAttributeTable *m_pAttributeTable = 36 : nullptr; // pointer to the attribute table 37 : // created on first call to GetDefaultRAT() 38 : GDALColorTable *m_pColorTable = nullptr; // pointer to the color table 39 : // created on first call to GetColorTable() 40 : 41 : int m_nAttributeChunkSize = 0; // for reporting via the metadata 42 : public: 43 : // constructor/destructor 44 : KEARasterBand(KEADataset *pDataset, int nSrcBand, GDALAccess eAccess, 45 : kealib::KEAImageIO *pImageIO, LockedRefCount *pRefCount); 46 : ~KEARasterBand(); 47 : 48 : // virtual methods for overview support 49 : int GetOverviewCount() override; 50 : GDALRasterBand *GetOverview(int nOverview) override; 51 : 52 : // virtual methods for band names (aka description) 53 : void SetDescription(const char *) override; 54 : 55 : // virtual methods for handling the metadata 56 : CPLErr SetMetadataItem(const char *pszName, const char *pszValue, 57 : const char *pszDomain = "") override; 58 : const char *GetMetadataItem(const char *pszName, 59 : const char *pszDomain = "") override; 60 : char **GetMetadata(const char *pszDomain = "") override; 61 : CPLErr SetMetadata(char **papszMetadata, 62 : const char *pszDomain = "") override; 63 : 64 : // virtual methods for the no data value 65 : double GetNoDataValue(int *pbSuccess = nullptr) override; 66 : int64_t GetNoDataValueAsInt64(int *pbSuccess = nullptr) override; 67 : uint64_t GetNoDataValueAsUInt64(int *pbSuccess = nullptr) override; 68 : 69 : CPLErr SetNoDataValue(double dfNoData) override; 70 : CPLErr SetNoDataValueAsInt64(int64_t nNoData) override; 71 : CPLErr SetNoDataValueAsUInt64(uint64_t nNoData) override; 72 : 73 : virtual CPLErr DeleteNoDataValue() override; 74 : 75 : // histogram methods 76 : CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax, int *pnBuckets, 77 : GUIntBig **ppanHistogram, int bForce, 78 : GDALProgressFunc, void *pProgressData) override; 79 : CPLErr SetDefaultHistogram(double dfMin, double dfMax, int nBuckets, 80 : GUIntBig *panHistogram) override; 81 : 82 : // virtual methods for RATs 83 : GDALRasterAttributeTable *GetDefaultRAT() override; 84 : CPLErr SetDefaultRAT(const GDALRasterAttributeTable *poRAT) override; 85 : 86 : // virtual methods for color tables 87 : GDALColorTable *GetColorTable() override; 88 : CPLErr SetColorTable(GDALColorTable *poCT) override; 89 : 90 : // virtual methods for color interpretation 91 : GDALColorInterp GetColorInterpretation() override; 92 : CPLErr SetColorInterpretation(GDALColorInterp gdalinterp) override; 93 : 94 : // Virtual methods for band masks. 95 : CPLErr CreateMaskBand(int nFlags) override; 96 : GDALRasterBand *GetMaskBand() override; 97 : int GetMaskFlags() override; 98 : 99 : // internal methods for overviews 100 : void readExistingOverviews(); 101 : void deleteOverviewObjects(); 102 : void CreateOverviews(int nOverviews, const int *panOverviewList); 103 : 104 1 : KEAOverview **GetOverviewList() 105 : { 106 1 : return m_panOverviewBands; 107 : } 108 : 109 : kealib::KEALayerType getLayerType() const; 110 : void setLayerType(kealib::KEALayerType eLayerType); 111 : 112 : protected: 113 : // methods for accessing data as blocks 114 : virtual CPLErr IReadBlock(int, int, void *) override; 115 : virtual CPLErr IWriteBlock(int, int, void *) override; 116 : 117 : // updates m_papszMetadataList 118 : void UpdateMetadataList(); 119 : 120 : // sets/gets the histogram column from a string (for metadata) 121 : CPLErr SetHistogramFromString(const char *pszString); 122 : char *GetHistogramAsString(); 123 : // So we can return the histogram as a string from GetMetadataItem 124 : char *m_pszHistoBinValues = nullptr; 125 : 126 : kealib::KEAImageIO *m_pImageIO = 127 : nullptr; // our image access pointer - refcounted 128 : char **m_papszMetadataList = nullptr; // CPLStringList of metadata 129 : kealib::KEADataType m_eKEADataType; // data type as KEA enum 130 : CPLMutex *m_hMutex; 131 : }; 132 : 133 : #endif // KEABAND_H