LCOV - code coverage report
Current view: top level - apps - gdalalg_vector_grid_invdistnn.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 24 24 100.0 %
Date: 2025-04-16 00:42:22 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  gdal "vector grid invdistnn" 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             : #include "gdalalg_vector_grid_invdistnn.h"
      14             : 
      15             : #include <limits>
      16             : 
      17             : //! @cond Doxygen_Suppress
      18             : 
      19             : #ifndef _
      20             : #define _(x) (x)
      21             : #endif
      22             : 
      23             : /************************************************************************/
      24             : /* GDALVectorGridInvdistNNAlgorithm::GDALVectorGridInvdistNNAlgorithm() */
      25             : /************************************************************************/
      26             : 
      27          10 : GDALVectorGridInvdistNNAlgorithm::GDALVectorGridInvdistNNAlgorithm()
      28          10 :     : GDALVectorGridAbstractAlgorithm(NAME, DESCRIPTION, HELP_URL)
      29             : {
      30          10 :     AddArg("power", 0, _("Weighting power"), &m_power).SetDefault(m_power);
      31          20 :     AddArg("smoothing", 0, _("Smoothing parameter"), &m_smoothing)
      32          10 :         .SetDefault(m_smoothing);
      33             : 
      34          10 :     AddRadiusArg();
      35          10 :     AddMinPointsArg();
      36          10 :     m_maxPoints = 12;
      37          10 :     AddMaxPointsArg();
      38          10 :     AddMinMaxPointsPerQuadrantArg();
      39          10 :     AddNodataArg();
      40          10 : }
      41             : 
      42             : /************************************************************************/
      43             : /*             GDALVectorGridInvdistNNAlgorithm::RunImpl()              */
      44             : /************************************************************************/
      45             : 
      46           9 : std::string GDALVectorGridInvdistNNAlgorithm::GetGridAlgorithm() const
      47             : {
      48             :     std::string ret =
      49             :         CPLSPrintf("invdistnn:power=%.17g:smoothing=%.17g:nodata=%.17g",
      50           9 :                    m_power, m_smoothing, m_nodata);
      51           9 :     ret += CPLSPrintf(":radius=%.17g", m_radius);
      52           9 :     if (m_minPoints > 0)
      53           1 :         ret += CPLSPrintf(":min_points=%d", m_minPoints);
      54           9 :     if (m_maxPoints < std::numeric_limits<int>::max())
      55           9 :         ret += CPLSPrintf(":max_points=%d", m_maxPoints);
      56           9 :     if (m_minPointsPerQuadrant > 0)
      57             :         ret +=
      58           1 :             CPLSPrintf(":min_points_per_quadrant=%d", m_minPointsPerQuadrant);
      59           9 :     if (m_maxPointsPerQuadrant < std::numeric_limits<int>::max())
      60             :         ret +=
      61           1 :             CPLSPrintf(":max_points_per_quadrant=%d", m_maxPointsPerQuadrant);
      62           9 :     return ret;
      63             : }
      64             : 
      65             : //! @endcond

Generated by: LCOV version 1.14