Coverage Report

Created: 2026-02-14 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/apps/gdalalg_vector_grid_average.cpp
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Project:  GDAL
4
 * Purpose:  gdal "vector grid average" 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_average.h"
14
15
#include <limits>
16
17
//! @cond Doxygen_Suppress
18
19
/************************************************************************/
20
/*   GDALVectorGridAverageAlgorithm::GDALVectorGridAverageAlgorithm()   */
21
/************************************************************************/
22
23
GDALVectorGridAverageAlgorithm::GDALVectorGridAverageAlgorithm(
24
    bool standaloneStep)
25
0
    : GDALVectorGridAbstractAlgorithm(NAME, DESCRIPTION, HELP_URL,
26
0
                                      standaloneStep)
27
0
{
28
0
    AddRadiusArg();
29
0
    AddRadius1AndRadius2Arg();
30
0
    AddAngleArg();
31
0
    AddMinPointsArg();
32
0
    AddMaxPointsArg();
33
0
    AddMinMaxPointsPerQuadrantArg();
34
0
    AddNodataArg();
35
36
0
    AddValidationAction(
37
0
        [this]()
38
0
        {
39
0
            bool ret = true;
40
0
            if (m_maxPoints < std::numeric_limits<int>::max() &&
41
0
                m_minPointsPerQuadrant == 0 &&
42
0
                m_maxPointsPerQuadrant == std::numeric_limits<int>::max())
43
0
            {
44
0
                ReportError(CE_Failure, CPLE_AppDefined,
45
0
                            "'min-points-per-quadrant' and/or "
46
0
                            "'max-points-per-quadrant' should be defined when "
47
0
                            "'max-points' is.");
48
0
                ret = false;
49
0
            }
50
0
            return ret;
51
0
        });
52
0
}
53
54
/************************************************************************/
55
/*              GDALVectorGridAverageAlgorithm::RunImpl()               */
56
/************************************************************************/
57
58
std::string GDALVectorGridAverageAlgorithm::GetGridAlgorithm() const
59
0
{
60
0
    std::string ret =
61
0
        CPLSPrintf("average:angle=%.17g:nodata=%.17g", m_angle, m_nodata);
62
0
    if (m_radius > 0)
63
0
    {
64
0
        ret += CPLSPrintf(":radius=%.17g", m_radius);
65
0
    }
66
0
    else
67
0
    {
68
0
        if (m_radius1 > 0)
69
0
            ret += CPLSPrintf(":radius1=%.17g", m_radius1);
70
0
        if (m_radius2 > 0)
71
0
            ret += CPLSPrintf(":radius2=%.17g", m_radius2);
72
0
    }
73
0
    if (m_minPoints > 0)
74
0
        ret += CPLSPrintf(":min_points=%d", m_minPoints);
75
0
    if (m_maxPoints < std::numeric_limits<int>::max())
76
0
        ret += CPLSPrintf(":max_points=%d", m_maxPoints);
77
0
    if (m_minPointsPerQuadrant > 0)
78
0
        ret +=
79
0
            CPLSPrintf(":min_points_per_quadrant=%d", m_minPointsPerQuadrant);
80
0
    if (m_maxPointsPerQuadrant < std::numeric_limits<int>::max())
81
0
        ret +=
82
0
            CPLSPrintf(":max_points_per_quadrant=%d", m_maxPointsPerQuadrant);
83
0
    return ret;
84
0
}
85
86
GDALVectorGridAverageAlgorithmStandalone::
87
0
    ~GDALVectorGridAverageAlgorithmStandalone() = default;
88
89
//! @endcond