/src/gdal/gcore/gdalallvalidmaskband.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: GDAL Core |
4 | | * Purpose: Implementation of GDALAllValidMaskBand, a class implementing all |
5 | | * a default 'all valid' band mask. |
6 | | * Author: Frank Warmerdam, warmerdam@pobox.com |
7 | | * |
8 | | ****************************************************************************** |
9 | | * Copyright (c) 2007, Frank Warmerdam |
10 | | * |
11 | | * SPDX-License-Identifier: MIT |
12 | | ****************************************************************************/ |
13 | | |
14 | | #include "cpl_port.h" |
15 | | #include "gdal_priv.h" |
16 | | |
17 | | #include <cstring> |
18 | | |
19 | | #include "gdal.h" |
20 | | #include "cpl_error.h" |
21 | | |
22 | | //! @cond Doxygen_Suppress |
23 | | /************************************************************************/ |
24 | | /* GDALAllValidMaskBand() */ |
25 | | /************************************************************************/ |
26 | | |
27 | | GDALAllValidMaskBand::GDALAllValidMaskBand(GDALRasterBand *poParent) |
28 | 0 | : GDALRasterBand(FALSE) |
29 | 0 | { |
30 | 0 | poDS = nullptr; |
31 | 0 | nBand = 0; |
32 | |
|
33 | 0 | nRasterXSize = poParent->GetXSize(); |
34 | 0 | nRasterYSize = poParent->GetYSize(); |
35 | |
|
36 | 0 | eDataType = GDT_Byte; |
37 | 0 | poParent->GetBlockSize(&nBlockXSize, &nBlockYSize); |
38 | 0 | } |
39 | | |
40 | | /************************************************************************/ |
41 | | /* ~GDALAllValidMaskBand() */ |
42 | | /************************************************************************/ |
43 | | |
44 | 0 | GDALAllValidMaskBand::~GDALAllValidMaskBand() = default; |
45 | | |
46 | | /************************************************************************/ |
47 | | /* IReadBlock() */ |
48 | | /************************************************************************/ |
49 | | |
50 | | CPLErr GDALAllValidMaskBand::IReadBlock(int /* nXBlockOff */, |
51 | | int /* nYBlockOff */, void *pImage) |
52 | 0 | { |
53 | 0 | memset(pImage, 255, static_cast<size_t>(nBlockXSize) * nBlockYSize); |
54 | |
|
55 | 0 | return CE_None; |
56 | 0 | } |
57 | | |
58 | | /************************************************************************/ |
59 | | /* IRasterIO() */ |
60 | | /************************************************************************/ |
61 | | |
62 | | CPLErr GDALAllValidMaskBand::IRasterIO(GDALRWFlag eRWFlag, int, int, int, int, |
63 | | void *pData, int nBufXSize, |
64 | | int nBufYSize, GDALDataType eBufType, |
65 | | GSpacing nPixelSpace, |
66 | | GSpacing nLineSpace, |
67 | | GDALRasterIOExtraArg *) |
68 | 0 | { |
69 | 0 | if (eRWFlag != GF_Read) |
70 | 0 | { |
71 | 0 | return CE_Failure; |
72 | 0 | } |
73 | | |
74 | 0 | GByte *pabyData = static_cast<GByte *>(pData); |
75 | 0 | GByte byVal = 255; |
76 | 0 | for (int iY = 0; iY < nBufYSize; ++iY) |
77 | 0 | { |
78 | 0 | GDALCopyWords64(&byVal, GDT_Byte, 0, pabyData + iY * nLineSpace, |
79 | 0 | eBufType, static_cast<int>(nPixelSpace), nBufXSize); |
80 | 0 | } |
81 | |
|
82 | 0 | return CE_None; |
83 | 0 | } |
84 | | |
85 | | /************************************************************************/ |
86 | | /* EmitErrorMessageIfWriteNotSupported() */ |
87 | | /************************************************************************/ |
88 | | |
89 | | bool GDALAllValidMaskBand::EmitErrorMessageIfWriteNotSupported( |
90 | | const char *pszCaller) const |
91 | 0 | { |
92 | 0 | ReportError(CE_Failure, CPLE_NoWriteAccess, |
93 | 0 | "%s: attempt to write to an all-valid implicit mask band.", |
94 | 0 | pszCaller); |
95 | |
|
96 | 0 | return true; |
97 | 0 | } |
98 | | |
99 | | /************************************************************************/ |
100 | | /* GetMaskBand() */ |
101 | | /************************************************************************/ |
102 | | |
103 | | GDALRasterBand *GDALAllValidMaskBand::GetMaskBand() |
104 | | |
105 | 0 | { |
106 | 0 | return this; |
107 | 0 | } |
108 | | |
109 | | /************************************************************************/ |
110 | | /* GetMaskFlags() */ |
111 | | /************************************************************************/ |
112 | | |
113 | | int GDALAllValidMaskBand::GetMaskFlags() |
114 | | |
115 | 0 | { |
116 | 0 | return GMF_ALL_VALID; |
117 | 0 | } |
118 | | |
119 | | /************************************************************************/ |
120 | | /* ComputeStatistics() */ |
121 | | /************************************************************************/ |
122 | | |
123 | | CPLErr GDALAllValidMaskBand::ComputeStatistics( |
124 | | int /* bApproxOK */, double *pdfMin, double *pdfMax, double *pdfMean, |
125 | | double *pdfStdDev, GDALProgressFunc, void * /*pProgressData*/) |
126 | 0 | { |
127 | 0 | if (pdfMin) |
128 | 0 | *pdfMin = 255.0; |
129 | 0 | if (pdfMax) |
130 | 0 | *pdfMax = 255.0; |
131 | 0 | if (pdfMean) |
132 | 0 | *pdfMean = 255.0; |
133 | 0 | if (pdfStdDev) |
134 | 0 | *pdfStdDev = 0.0; |
135 | 0 | return CE_None; |
136 | 0 | } |
137 | | |
138 | | //! @endcond |