Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: gdal "vector grid minimum/maximum/range/count/average-distance/average-distance-pts" 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_VECTOR_GRID_DATA_METRICS_INCLUDED 14 : #define GDALALG_VECTOR_GRID_DATA_METRICS_INCLUDED 15 : 16 : #include "gdalalg_vector_grid.h" 17 : 18 : //! @cond Doxygen_Suppress 19 : 20 : /************************************************************************/ 21 : /* GDALVectorGridDataMetricsAbstractAlgorithm */ 22 : /************************************************************************/ 23 : 24 36 : class GDALVectorGridDataMetricsAbstractAlgorithm /* non final */ 25 : : public GDALVectorGridAbstractAlgorithm 26 : { 27 : public: 28 : static constexpr const char *HELP_URL = "/programs/gdal_vector_grid.html"; 29 : 30 : protected: 31 : GDALVectorGridDataMetricsAbstractAlgorithm(const std::string &name, 32 : const std::string &description, 33 : const std::string &helpURL, 34 : const std::string &method, 35 : bool standaloneStep); 36 : 37 : ~GDALVectorGridDataMetricsAbstractAlgorithm() override; 38 : 39 : std::string GetGridAlgorithm() const override; 40 : 41 : private: 42 : std::string m_method{}; 43 : }; 44 : 45 : /************************************************************************/ 46 : /* GDALVectorGridMinimumAlgorithm */ 47 : /************************************************************************/ 48 : 49 13 : class GDALVectorGridMinimumAlgorithm /* non final */ 50 : : public GDALVectorGridDataMetricsAbstractAlgorithm 51 : { 52 : public: 53 : static constexpr const char *NAME = "minimum"; 54 : static constexpr const char *DESCRIPTION = 55 : "Create a regular grid from scattered points using the minimum value " 56 : "in the search ellipse."; 57 : 58 11 : explicit GDALVectorGridMinimumAlgorithm(bool standaloneStep = false) 59 11 : : GDALVectorGridDataMetricsAbstractAlgorithm( 60 11 : NAME, DESCRIPTION, HELP_URL, "minimum", standaloneStep) 61 : { 62 11 : } 63 : 64 : ~GDALVectorGridMinimumAlgorithm() override; 65 : }; 66 : 67 : /************************************************************************/ 68 : /* GDALVectorGridMinimumAlgorithmStandalone */ 69 : /************************************************************************/ 70 : 71 18 : class GDALVectorGridMinimumAlgorithmStandalone final 72 : : public GDALVectorGridMinimumAlgorithm 73 : { 74 : public: 75 9 : GDALVectorGridMinimumAlgorithmStandalone() 76 9 : : GDALVectorGridMinimumAlgorithm(/* standaloneStep = */ true) 77 : { 78 9 : } 79 : 80 : ~GDALVectorGridMinimumAlgorithmStandalone() override; 81 : }; 82 : 83 : /************************************************************************/ 84 : /* GDALVectorGridMaximumAlgorithm */ 85 : /************************************************************************/ 86 : 87 7 : class GDALVectorGridMaximumAlgorithm /* non final */ 88 : : public GDALVectorGridDataMetricsAbstractAlgorithm 89 : { 90 : public: 91 : static constexpr const char *NAME = "maximum"; 92 : static constexpr const char *DESCRIPTION = 93 : "Create a regular grid from scattered points using the maximum value " 94 : "in the search ellipse."; 95 : 96 5 : explicit GDALVectorGridMaximumAlgorithm(bool standaloneStep = false) 97 5 : : GDALVectorGridDataMetricsAbstractAlgorithm( 98 5 : NAME, DESCRIPTION, HELP_URL, "maximum", standaloneStep) 99 : { 100 5 : } 101 : 102 : ~GDALVectorGridMaximumAlgorithm() override; 103 : }; 104 : 105 : /************************************************************************/ 106 : /* GDALVectorGridMaximumAlgorithmStandalone */ 107 : /************************************************************************/ 108 : 109 6 : class GDALVectorGridMaximumAlgorithmStandalone final 110 : : public GDALVectorGridMaximumAlgorithm 111 : { 112 : public: 113 3 : GDALVectorGridMaximumAlgorithmStandalone() 114 3 : : GDALVectorGridMaximumAlgorithm(/* standaloneStep = */ true) 115 : { 116 3 : } 117 : 118 : ~GDALVectorGridMaximumAlgorithmStandalone() override; 119 : }; 120 : 121 : /************************************************************************/ 122 : /* GDALVectorGridRangeAlgorithm */ 123 : /************************************************************************/ 124 : 125 7 : class GDALVectorGridRangeAlgorithm /* non final */ 126 : : public GDALVectorGridDataMetricsAbstractAlgorithm 127 : { 128 : public: 129 : static constexpr const char *NAME = "range"; 130 : static constexpr const char *DESCRIPTION = 131 : "Create a regular grid from scattered points using the difference " 132 : "between the minimum and maximum values in the search ellipse."; 133 : 134 5 : explicit GDALVectorGridRangeAlgorithm(bool standaloneStep = false) 135 5 : : GDALVectorGridDataMetricsAbstractAlgorithm( 136 5 : NAME, DESCRIPTION, HELP_URL, "range", standaloneStep) 137 : { 138 5 : } 139 : 140 : ~GDALVectorGridRangeAlgorithm() override; 141 : }; 142 : 143 : /************************************************************************/ 144 : /* GDALVectorGridRangeAlgorithmStandalone */ 145 : /************************************************************************/ 146 : 147 6 : class GDALVectorGridRangeAlgorithmStandalone final 148 : : public GDALVectorGridRangeAlgorithm 149 : { 150 : public: 151 3 : GDALVectorGridRangeAlgorithmStandalone() 152 3 : : GDALVectorGridRangeAlgorithm(/* standaloneStep = */ true) 153 : { 154 3 : } 155 : 156 : ~GDALVectorGridRangeAlgorithmStandalone() override; 157 : }; 158 : 159 : /************************************************************************/ 160 : /* GDALVectorGridCountAlgorithm */ 161 : /************************************************************************/ 162 : 163 7 : class GDALVectorGridCountAlgorithm /* non final */ 164 : : public GDALVectorGridDataMetricsAbstractAlgorithm 165 : { 166 : public: 167 : static constexpr const char *NAME = "count"; 168 : static constexpr const char *DESCRIPTION = 169 : "Create a regular grid from scattered points using the number of " 170 : "points in the search ellipse."; 171 : 172 5 : explicit GDALVectorGridCountAlgorithm(bool standaloneStep = false) 173 5 : : GDALVectorGridDataMetricsAbstractAlgorithm( 174 5 : NAME, DESCRIPTION, HELP_URL, "count", standaloneStep) 175 : { 176 5 : } 177 : 178 : ~GDALVectorGridCountAlgorithm() override; 179 : }; 180 : 181 : /************************************************************************/ 182 : /* GDALVectorGridCountAlgorithmStandalone */ 183 : /************************************************************************/ 184 : 185 6 : class GDALVectorGridCountAlgorithmStandalone final 186 : : public GDALVectorGridCountAlgorithm 187 : { 188 : public: 189 3 : GDALVectorGridCountAlgorithmStandalone() 190 3 : : GDALVectorGridCountAlgorithm(/* standaloneStep = */ true) 191 : { 192 3 : } 193 : 194 : ~GDALVectorGridCountAlgorithmStandalone() override; 195 : }; 196 : 197 : /************************************************************************/ 198 : /* GDALVectorGridAverageDistanceAlgorithm */ 199 : /************************************************************************/ 200 : 201 7 : class GDALVectorGridAverageDistanceAlgorithm /* non final */ 202 : : public GDALVectorGridDataMetricsAbstractAlgorithm 203 : { 204 : public: 205 : static constexpr const char *NAME = "average-distance"; 206 : static constexpr const char *DESCRIPTION = 207 : "Create a regular grid from scattered points using the average " 208 : "distance between the grid node (center of the search ellipse) and all " 209 : "of the data points in the search ellipse."; 210 : 211 5 : explicit GDALVectorGridAverageDistanceAlgorithm(bool standaloneStep = false) 212 5 : : GDALVectorGridDataMetricsAbstractAlgorithm( 213 5 : NAME, DESCRIPTION, HELP_URL, "average_distance", standaloneStep) 214 : { 215 5 : } 216 : 217 : ~GDALVectorGridAverageDistanceAlgorithm() override; 218 : }; 219 : 220 : /************************************************************************/ 221 : /* GDALVectorGridAverageDistanceAlgorithmStandalone */ 222 : /************************************************************************/ 223 : 224 6 : class GDALVectorGridAverageDistanceAlgorithmStandalone final 225 : : public GDALVectorGridAverageDistanceAlgorithm 226 : { 227 : public: 228 3 : GDALVectorGridAverageDistanceAlgorithmStandalone() 229 3 : : GDALVectorGridAverageDistanceAlgorithm(/* standaloneStep = */ true) 230 : { 231 3 : } 232 : 233 : ~GDALVectorGridAverageDistanceAlgorithmStandalone() override; 234 : }; 235 : 236 : /************************************************************************/ 237 : /* GDALVectorGridAverageDistancePointsAlgorithm */ 238 : /************************************************************************/ 239 : 240 7 : class GDALVectorGridAverageDistancePointsAlgorithm /* non final */ 241 : : public GDALVectorGridDataMetricsAbstractAlgorithm 242 : { 243 : public: 244 : static constexpr const char *NAME = "average-distance-points"; 245 : static constexpr const char *DESCRIPTION = 246 : "Create a regular grid from scattered points using the average " 247 : "distance between the data points in the search ellipse."; 248 : 249 5 : explicit GDALVectorGridAverageDistancePointsAlgorithm( 250 : bool standaloneStep = false) 251 5 : : GDALVectorGridDataMetricsAbstractAlgorithm( 252 : NAME, DESCRIPTION, HELP_URL, "average_distance_pts", 253 5 : standaloneStep) 254 : { 255 5 : } 256 : 257 : ~GDALVectorGridAverageDistancePointsAlgorithm() override; 258 : }; 259 : 260 : /************************************************************************/ 261 : /* GDALVectorGridAverageDistancePointsAlgorithmStandalone */ 262 : /************************************************************************/ 263 : 264 6 : class GDALVectorGridAverageDistancePointsAlgorithmStandalone final 265 : : public GDALVectorGridAverageDistancePointsAlgorithm 266 : { 267 : public: 268 3 : GDALVectorGridAverageDistancePointsAlgorithmStandalone() 269 3 : : GDALVectorGridAverageDistancePointsAlgorithm( 270 3 : /* standaloneStep = */ true) 271 : { 272 3 : } 273 : 274 : ~GDALVectorGridAverageDistancePointsAlgorithmStandalone() override; 275 : }; 276 : 277 : //! @endcond 278 : 279 : #endif