/src/gdal/apps/gdalalg_vector_grid.h
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: GDAL |
4 | | * Purpose: gdal "vector grid" 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_INCLUDED |
14 | | #define GDALALG_VECTOR_GRID_INCLUDED |
15 | | |
16 | | #include "gdalalg_abstract_pipeline.h" |
17 | | |
18 | | #include <limits> |
19 | | |
20 | | //! @cond Doxygen_Suppress |
21 | | |
22 | | /************************************************************************/ |
23 | | /* GDALVectorGridAlgorithm */ |
24 | | /************************************************************************/ |
25 | | |
26 | | class GDALVectorGridAlgorithm /* non final */ : public GDALPipelineStepAlgorithm |
27 | | { |
28 | | public: |
29 | | static constexpr const char *NAME = "grid"; |
30 | | static constexpr const char *DESCRIPTION = |
31 | | "Create a regular grid from scattered points."; |
32 | | static constexpr const char *HELP_URL = "/programs/gdal_vector_grid.html"; |
33 | | |
34 | | explicit GDALVectorGridAlgorithm(bool standaloneStep = false); |
35 | | |
36 | | int GetInputType() const override |
37 | 0 | { |
38 | 0 | return GDAL_OF_VECTOR; |
39 | 0 | } |
40 | | |
41 | | int GetOutputType() const override |
42 | 0 | { |
43 | 0 | return GDAL_OF_RASTER; |
44 | 0 | } |
45 | | |
46 | | private: |
47 | | bool RunStep(GDALPipelineStepRunContext &ctxt) override; |
48 | | bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override; |
49 | | }; |
50 | | |
51 | | /************************************************************************/ |
52 | | /* GDALVectorGridAlgorithmStandalone */ |
53 | | /************************************************************************/ |
54 | | |
55 | | class GDALVectorGridAlgorithmStandalone final : public GDALVectorGridAlgorithm |
56 | | { |
57 | | public: |
58 | | GDALVectorGridAlgorithmStandalone() |
59 | 0 | : GDALVectorGridAlgorithm(/* standaloneStep = */ true) |
60 | 0 | { |
61 | 0 | } |
62 | | |
63 | | ~GDALVectorGridAlgorithmStandalone() override; |
64 | | }; |
65 | | |
66 | | /************************************************************************/ |
67 | | /* GDALVectorGridAbstractAlgorithm */ |
68 | | /************************************************************************/ |
69 | | |
70 | | class GDALVectorGridAbstractAlgorithm /* non final */ |
71 | | : public GDALPipelineStepAlgorithm |
72 | | { |
73 | | protected: |
74 | | std::vector<double> m_targetExtent{}; |
75 | | std::vector<double> |
76 | | m_targetResolution{}; // Mutually exclusive with targetSize |
77 | | std::vector<int> |
78 | | m_targetSize{}; // Mutually exclusive with targetResolution |
79 | | std::string m_outputType{"Float64"}; |
80 | | std::string m_crs{}; |
81 | | std::vector<std::string> m_layers{}; |
82 | | std::string m_sql{}; |
83 | | std::string m_zField{}; |
84 | | double m_zOffset = 0; |
85 | | double m_zMultiply = 1; |
86 | | std::vector<double> m_bbox{}; |
87 | | |
88 | | // Common per-algorithm parameters |
89 | | double m_radius1 = 0.0; |
90 | | double m_radius2 = 0.0; |
91 | | double m_radius = 0.0; |
92 | | double m_angle = 0.0; |
93 | | int m_minPoints = 0; |
94 | | int m_maxPoints = std::numeric_limits<int>::max(); |
95 | | int m_minPointsPerQuadrant = 0; |
96 | | int m_maxPointsPerQuadrant = std::numeric_limits<int>::max(); |
97 | | double m_nodata = 0; |
98 | | |
99 | | GDALVectorGridAbstractAlgorithm(const std::string &name, |
100 | | const std::string &description, |
101 | | const std::string &helpURL, |
102 | | bool standaloneStep); |
103 | | |
104 | | bool IsNativelyStreamingCompatible() const override |
105 | 0 | { |
106 | 0 | return false; |
107 | 0 | } |
108 | | |
109 | | int GetInputType() const override |
110 | 0 | { |
111 | 0 | return GDAL_OF_VECTOR; |
112 | 0 | } |
113 | | |
114 | | int GetOutputType() const override |
115 | 0 | { |
116 | 0 | return GDAL_OF_RASTER; |
117 | 0 | } |
118 | | |
119 | | bool RunStep(GDALPipelineStepRunContext &ctxt) override; |
120 | | bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override; |
121 | | |
122 | | GDALInConstructionAlgorithmArg &AddRadiusArg(); |
123 | | void AddRadius1AndRadius2Arg(); |
124 | | GDALInConstructionAlgorithmArg &AddAngleArg(); |
125 | | GDALInConstructionAlgorithmArg &AddMinPointsArg(); |
126 | | GDALInConstructionAlgorithmArg &AddMaxPointsArg(); |
127 | | void AddMinMaxPointsPerQuadrantArg(); |
128 | | GDALInConstructionAlgorithmArg &AddNodataArg(); |
129 | | |
130 | | virtual std::string GetGridAlgorithm() const = 0; |
131 | | }; |
132 | | |
133 | | //! @endcond |
134 | | |
135 | | #endif |