LCOV - code coverage report
Current view: top level - alg/viewshed - viewshed.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 3 3 100.0 %
Date: 2024-11-21 22:18:42 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  Viewshed Generation
       4             :  * Purpose:  Core algorithm implementation for viewshed generation.
       5             :  * Author:   Tamas Szekeres, szekerest@gmail.com
       6             :  *
       7             :  * (c) 2024 info@hobu.co
       8             :  *
       9             :  ******************************************************************************
      10             :  *
      11             :  * SPDX-License-Identifier: MIT
      12             :  ****************************************************************************/
      13             : 
      14             : #ifndef VIEWSHED_H_INCLUDED
      15             : #define VIEWSHED_H_INCLUDED
      16             : 
      17             : #include <algorithm>
      18             : #include <array>
      19             : #include <cstdint>
      20             : #include <functional>
      21             : #include <limits>
      22             : #include <memory>
      23             : #include <mutex>
      24             : #include <queue>
      25             : #include <string>
      26             : 
      27             : #include "cpl_progress.h"
      28             : #include "gdal_priv.h"
      29             : #include "viewshed_types.h"
      30             : 
      31             : namespace gdal
      32             : {
      33             : namespace viewshed
      34             : {
      35             : 
      36             : /**
      37             :  * Class to support viewshed raster generation.
      38             :  */
      39          37 : class Viewshed
      40             : {
      41             :   public:
      42             :     /**
      43             :      * Constructor.
      44             :      *
      45             :      * @param opts Options to use when calculating viewshed.
      46             :     */
      47             :     CPL_DLL explicit Viewshed(const Options &opts);
      48             : 
      49             :     /** Destructor */
      50             :     CPL_DLL ~Viewshed();
      51             : 
      52             :     CPL_DLL bool run(GDALRasterBandH hBand,
      53             :                      GDALProgressFunc pfnProgress = GDALDummyProgress,
      54             :                      void *pProgressArg = nullptr);
      55             : 
      56             :     /**
      57             :      * Fetch a pointer to the created raster band.
      58             :      *
      59             :      * @return  Unique pointer to the viewshed dataset.
      60             :     */
      61          37 :     CPL_DLL DatasetPtr output()
      62             :     {
      63          37 :         return std::move(poDstDS);
      64             :     }
      65             : 
      66             :   private:
      67             :     Options oOpts;
      68             :     Window oOutExtent{};
      69             :     Window oCurExtent{};
      70             :     DatasetPtr poDstDS{};
      71             :     GDALRasterBand *pSrcBand = nullptr;
      72             : 
      73             :     DatasetPtr execute(int nX, int nY, const std::string &outFilename);
      74             :     void setOutput(double &dfResult, double &dfCellVal, double dfZ);
      75             :     double calcHeight(double dfZ, double dfZ2);
      76             :     bool readLine(int nLine, double *data);
      77             :     std::pair<int, int> adjustHeight(int iLine, int nX,
      78             :                                      std::vector<double> &thisLineVal);
      79             :     bool calcExtents(int nX, int nY,
      80             :                      const std::array<double, 6> &adfInvTransform);
      81             : 
      82             :     Viewshed(const Viewshed &) = delete;
      83             :     Viewshed &operator=(const Viewshed &) = delete;
      84             : };
      85             : 
      86             : }  // namespace viewshed
      87             : }  // namespace gdal
      88             : 
      89             : #endif

Generated by: LCOV version 1.14