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 : * Permission is hereby granted, free of charge, to any person 11 : * obtaining a copy of this software and associated documentation 12 : * files (the "Software"), to deal in the Software without restriction, 13 : * including without limitation the rights to use, copy, modify, 14 : * merge, publish, distribute, sublicense, and/or sell copies of the 15 : * Software, and to permit persons to whom the Software is furnished 16 : * to do so, subject to the following conditions: 17 : * 18 : * The above copyright notice and this permission notice shall be 19 : * included in all copies or substantial portions of the Software. 20 : * 21 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 : * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 : * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24 : * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 25 : * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 26 : * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 : * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 : * 29 : */ 30 : 31 : #ifndef KEABAND_H 32 : #define KEABAND_H 33 : 34 : #include "gdal_pam.h" 35 : #include "keadataset.h" 36 : 37 : class KEAOverview; 38 : class KEAMaskBand; 39 : 40 : // Provides the implementation of a GDAL raster band 41 : class KEARasterBand CPL_NON_FINAL : public GDALPamRasterBand 42 : { 43 : private: 44 : LockedRefCount *m_pRefCount = nullptr; // reference count of m_pImageIO 45 : 46 : int m_nOverviews = 0; // number of overviews 47 : KEAOverview **m_panOverviewBands = nullptr; // array of overview objects 48 : GDALRasterBand *m_pMaskBand = 49 : nullptr; // pointer to mask band if one exists (and been requested) 50 : bool m_bMaskBandOwned = false; // do we delete it or not? 51 : 52 : GDALRasterAttributeTable *m_pAttributeTable = 53 : nullptr; // pointer to the attribute table 54 : // created on first call to GetDefaultRAT() 55 : GDALColorTable *m_pColorTable = nullptr; // pointer to the color table 56 : // created on first call to GetColorTable() 57 : 58 : int m_nAttributeChunkSize = 0; // for reporting via the metadata 59 : public: 60 : // constructor/destructor 61 : KEARasterBand(KEADataset *pDataset, int nSrcBand, GDALAccess eAccess, 62 : kealib::KEAImageIO *pImageIO, LockedRefCount *pRefCount); 63 : ~KEARasterBand(); 64 : 65 : // virtual methods for overview support 66 : int GetOverviewCount() override; 67 : GDALRasterBand *GetOverview(int nOverview) override; 68 : 69 : // virtual methods for band names (aka description) 70 : void SetDescription(const char *) override; 71 : 72 : // virtual methods for handling the metadata 73 : CPLErr SetMetadataItem(const char *pszName, const char *pszValue, 74 : const char *pszDomain = "") override; 75 : const char *GetMetadataItem(const char *pszName, 76 : const char *pszDomain = "") override; 77 : char **GetMetadata(const char *pszDomain = "") override; 78 : CPLErr SetMetadata(char **papszMetadata, 79 : const char *pszDomain = "") override; 80 : 81 : // virtual methods for the no data value 82 : double GetNoDataValue(int *pbSuccess = nullptr) override; 83 : int64_t GetNoDataValueAsInt64(int *pbSuccess = nullptr) override; 84 : uint64_t GetNoDataValueAsUInt64(int *pbSuccess = nullptr) override; 85 : 86 : CPLErr SetNoDataValue(double dfNoData) override; 87 : CPLErr SetNoDataValueAsInt64(int64_t nNoData) override; 88 : CPLErr SetNoDataValueAsUInt64(uint64_t nNoData) override; 89 : 90 : virtual CPLErr DeleteNoDataValue() override; 91 : 92 : // histogram methods 93 : CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax, int *pnBuckets, 94 : GUIntBig **ppanHistogram, int bForce, 95 : GDALProgressFunc, void *pProgressData) override; 96 : CPLErr SetDefaultHistogram(double dfMin, double dfMax, int nBuckets, 97 : GUIntBig *panHistogram) override; 98 : 99 : // virtual methods for RATs 100 : GDALRasterAttributeTable *GetDefaultRAT() override; 101 : CPLErr SetDefaultRAT(const GDALRasterAttributeTable *poRAT) override; 102 : 103 : // virtual methods for color tables 104 : GDALColorTable *GetColorTable() override; 105 : CPLErr SetColorTable(GDALColorTable *poCT) override; 106 : 107 : // virtual methods for color interpretation 108 : GDALColorInterp GetColorInterpretation() override; 109 : CPLErr SetColorInterpretation(GDALColorInterp gdalinterp) override; 110 : 111 : // Virtual methods for band masks. 112 : CPLErr CreateMaskBand(int nFlags) override; 113 : GDALRasterBand *GetMaskBand() override; 114 : int GetMaskFlags() override; 115 : 116 : // internal methods for overviews 117 : void readExistingOverviews(); 118 : void deleteOverviewObjects(); 119 : void CreateOverviews(int nOverviews, const int *panOverviewList); 120 : 121 1 : KEAOverview **GetOverviewList() 122 : { 123 1 : return m_panOverviewBands; 124 : } 125 : 126 : kealib::KEALayerType getLayerType() const; 127 : void setLayerType(kealib::KEALayerType eLayerType); 128 : 129 : protected: 130 : // methods for accessing data as blocks 131 : virtual CPLErr IReadBlock(int, int, void *) override; 132 : virtual CPLErr IWriteBlock(int, int, void *) override; 133 : 134 : // updates m_papszMetadataList 135 : void UpdateMetadataList(); 136 : 137 : // sets/gets the histogram column from a string (for metadata) 138 : CPLErr SetHistogramFromString(const char *pszString); 139 : char *GetHistogramAsString(); 140 : // So we can return the histogram as a string from GetMetadataItem 141 : char *m_pszHistoBinValues = nullptr; 142 : 143 : kealib::KEAImageIO *m_pImageIO = 144 : nullptr; // our image access pointer - refcounted 145 : char **m_papszMetadataList = nullptr; // CPLStringList of metadata 146 : kealib::KEADataType m_eKEADataType; // data type as KEA enum 147 : CPLMutex *m_hMutex; 148 : }; 149 : 150 : #endif // KEABAND_H