LCOV - code coverage report
Current view: top level - apps - gdalalg_raster_viewshed.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 3 3 100.0 %
Date: 2025-05-15 18:21:54 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  gdal "raster viewshed" subcommand
       5             :  * Author:   Even Rouault <even dot rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2025, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #ifndef GDALALG_RASTER_VIEWSHED_INCLUDED
      14             : #define GDALALG_RASTER_VIEWSHED_INCLUDED
      15             : 
      16             : #include "gdalalg_raster_pipeline.h"
      17             : 
      18             : //! @cond Doxygen_Suppress
      19             : 
      20             : /************************************************************************/
      21             : /*                   GDALRasterViewshedAlgorithm                       */
      22             : /************************************************************************/
      23             : 
      24             : class GDALRasterViewshedAlgorithm /* non final */
      25             :     : public GDALRasterPipelineNonNativelyStreamingAlgorithm
      26             : {
      27             :   public:
      28             :     static constexpr const char *NAME = "viewshed";
      29             :     static constexpr const char *DESCRIPTION =
      30             :         "Compute the viewshed of a raster dataset.";
      31             :     static constexpr const char *HELP_URL =
      32             :         "/programs/gdal_raster_viewshed.html";
      33             : 
      34             :     explicit GDALRasterViewshedAlgorithm(bool standaloneStep = false);
      35             : 
      36             :   private:
      37             :     bool RunStep(GDALProgressFunc pfnProgress, void *pProgressData) override;
      38             : 
      39             :     std::vector<double> m_observerPos{};
      40             :     double m_targetHeight = 0;
      41             : 
      42             :     std::string m_outputMode = "normal";
      43             : 
      44             :     int m_band = 1;
      45             :     double m_maxDistance = 0;
      46             :     double m_curveCoefficient = 0.85714;
      47             :     int m_observerSpacing = 10;
      48             :     int m_numThreads = 3;
      49             :     int m_dstNoData = -1;
      50             :     int m_visibleVal = 255;
      51             :     int m_invisibleVal = 0;
      52             :     int m_outOfRangeVal = 0;
      53             : 
      54             :     // Work variables
      55             :     std::string m_numThreadsStr{};
      56             : };
      57             : 
      58             : /************************************************************************/
      59             : /*                GDALRasterViewshedAlgorithmStandalone                 */
      60             : /************************************************************************/
      61             : 
      62             : class GDALRasterViewshedAlgorithmStandalone final
      63             :     : public GDALRasterViewshedAlgorithm
      64             : {
      65             :   public:
      66          19 :     GDALRasterViewshedAlgorithmStandalone()
      67          19 :         : GDALRasterViewshedAlgorithm(/* standaloneStep = */ true)
      68             :     {
      69          19 :     }
      70             : };
      71             : 
      72             : //! @endcond
      73             : 
      74             : #endif

Generated by: LCOV version 1.14