LCOV - code coverage report
Current view: top level - gcore - gdalallvalidmaskband.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 36 37 97.3 %
Date: 2025-03-25 20:12:57 Functions: 7 7 100.0 %

          Line data    Source code
       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       92392 : GDALAllValidMaskBand::GDALAllValidMaskBand(GDALRasterBand *poParent)
      28       92392 :     : GDALRasterBand(FALSE)
      29             : {
      30       92391 :     poDS = nullptr;
      31       92391 :     nBand = 0;
      32             : 
      33       92391 :     nRasterXSize = poParent->GetXSize();
      34       92391 :     nRasterYSize = poParent->GetYSize();
      35             : 
      36       92391 :     eDataType = GDT_Byte;
      37       92391 :     poParent->GetBlockSize(&nBlockXSize, &nBlockYSize);
      38       92391 : }
      39             : 
      40             : /************************************************************************/
      41             : /*                       ~GDALAllValidMaskBand()                        */
      42             : /************************************************************************/
      43             : 
      44             : GDALAllValidMaskBand::~GDALAllValidMaskBand() = default;
      45             : 
      46             : /************************************************************************/
      47             : /*                             IReadBlock()                             */
      48             : /************************************************************************/
      49             : 
      50           1 : CPLErr GDALAllValidMaskBand::IReadBlock(int /* nXBlockOff */,
      51             :                                         int /* nYBlockOff */, void *pImage)
      52             : {
      53           1 :     memset(pImage, 255, static_cast<size_t>(nBlockXSize) * nBlockYSize);
      54             : 
      55           1 :     return CE_None;
      56             : }
      57             : 
      58             : /************************************************************************/
      59             : /*                             IRasterIO()                              */
      60             : /************************************************************************/
      61             : 
      62       27311 : 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             : {
      69       27311 :     if (eRWFlag != GF_Read)
      70             :     {
      71           0 :         return CE_Failure;
      72             :     }
      73             : 
      74       27311 :     GByte *pabyData = static_cast<GByte *>(pData);
      75       27311 :     GByte byVal = 255;
      76      339111 :     for (int iY = 0; iY < nBufYSize; ++iY)
      77             :     {
      78      311305 :         GDALCopyWords64(&byVal, GDT_Byte, 0, pabyData + iY * nLineSpace,
      79             :                         eBufType, static_cast<int>(nPixelSpace), nBufXSize);
      80             :     }
      81             : 
      82       27806 :     return CE_None;
      83             : }
      84             : 
      85             : /************************************************************************/
      86             : /*                   EmitErrorMessageIfWriteNotSupported()              */
      87             : /************************************************************************/
      88             : 
      89           3 : bool GDALAllValidMaskBand::EmitErrorMessageIfWriteNotSupported(
      90             :     const char *pszCaller) const
      91             : {
      92           3 :     ReportError(CE_Failure, CPLE_NoWriteAccess,
      93             :                 "%s: attempt to write to an all-valid implicit mask band.",
      94             :                 pszCaller);
      95             : 
      96           3 :     return true;
      97             : }
      98             : 
      99             : /************************************************************************/
     100             : /*                            GetMaskBand()                             */
     101             : /************************************************************************/
     102             : 
     103         135 : GDALRasterBand *GDALAllValidMaskBand::GetMaskBand()
     104             : 
     105             : {
     106         135 :     return this;
     107             : }
     108             : 
     109             : /************************************************************************/
     110             : /*                            GetMaskFlags()                            */
     111             : /************************************************************************/
     112             : 
     113           7 : int GDALAllValidMaskBand::GetMaskFlags()
     114             : 
     115             : {
     116           7 :     return GMF_ALL_VALID;
     117             : }
     118             : 
     119             : /************************************************************************/
     120             : /*                           ComputeStatistics()                        */
     121             : /************************************************************************/
     122             : 
     123           1 : CPLErr GDALAllValidMaskBand::ComputeStatistics(
     124             :     int /* bApproxOK */, double *pdfMin, double *pdfMax, double *pdfMean,
     125             :     double *pdfStdDev, GDALProgressFunc, void * /*pProgressData*/)
     126             : {
     127           1 :     if (pdfMin)
     128           1 :         *pdfMin = 255.0;
     129           1 :     if (pdfMax)
     130           1 :         *pdfMax = 255.0;
     131           1 :     if (pdfMean)
     132           1 :         *pdfMean = 255.0;
     133           1 :     if (pdfStdDev)
     134           1 :         *pdfStdDev = 0.0;
     135           1 :     return CE_None;
     136             : }
     137             : 
     138             : //! @endcond

Generated by: LCOV version 1.14