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 13 : GDALVectorGridInvdistNNAlgorithm::GDALVectorGridInvdistNNAlgorithm( 28 13 : bool standaloneStep) 29 : : GDALVectorGridAbstractAlgorithm(NAME, DESCRIPTION, HELP_URL, 30 13 : standaloneStep) 31 : { 32 13 : AddArg("power", 0, _("Weighting power"), &m_power).SetDefault(m_power); 33 26 : AddArg("smoothing", 0, _("Smoothing parameter"), &m_smoothing) 34 13 : .SetDefault(m_smoothing); 35 : 36 13 : AddRadiusArg(); 37 13 : AddMinPointsArg(); 38 13 : m_maxPoints = 12; 39 13 : AddMaxPointsArg(); 40 13 : AddMinMaxPointsPerQuadrantArg(); 41 13 : AddNodataArg(); 42 13 : } 43 : 44 : /************************************************************************/ 45 : /* GDALVectorGridInvdistNNAlgorithm::RunImpl() */ 46 : /************************************************************************/ 47 : 48 9 : std::string GDALVectorGridInvdistNNAlgorithm::GetGridAlgorithm() const 49 : { 50 : std::string ret = 51 : CPLSPrintf("invdistnn:power=%.17g:smoothing=%.17g:nodata=%.17g", 52 9 : m_power, m_smoothing, m_nodata); 53 9 : ret += CPLSPrintf(":radius=%.17g", m_radius); 54 9 : if (m_minPoints > 0) 55 1 : ret += CPLSPrintf(":min_points=%d", m_minPoints); 56 9 : if (m_maxPoints < std::numeric_limits<int>::max()) 57 9 : ret += CPLSPrintf(":max_points=%d", m_maxPoints); 58 9 : if (m_minPointsPerQuadrant > 0) 59 : ret += 60 1 : CPLSPrintf(":min_points_per_quadrant=%d", m_minPointsPerQuadrant); 61 9 : if (m_maxPointsPerQuadrant < std::numeric_limits<int>::max()) 62 : ret += 63 1 : CPLSPrintf(":max_points_per_quadrant=%d", m_maxPointsPerQuadrant); 64 9 : return ret; 65 : } 66 : 67 : GDALVectorGridInvdistNNAlgorithmStandalone:: 68 : ~GDALVectorGridInvdistNNAlgorithmStandalone() = default; 69 : 70 : //! @endcond