GDAL

gdalalg_materialize.h
1/******************************************************************************
2 *
3 * Project: GDAL
4 * Purpose: gdal "materialize" pipeline step
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_MATERIALIZE_INCLUDED
14#define GDALALG_MATERIALIZE_INCLUDED
15
16#include "gdalalg_abstract_pipeline.h"
17#include "gdalalg_raster_pipeline.h"
18#include "gdalalg_vector_pipeline.h"
19
21
22/************************************************************************/
23/* GDALMaterializeStepAlgorithm */
24/************************************************************************/
25
26 template <class BaseStepAlgorithm, int nDatasetType>
27 class GDALMaterializeStepAlgorithm /* non final */
28 : public BaseStepAlgorithm
29{
30 public:
31 static constexpr const char *NAME = "materialize";
32 static constexpr const char *DESCRIPTION =
33 "Materialize a piped dataset on disk to increase the efficiency of the "
34 "following steps.";
35
36 bool IsNativelyStreamingCompatible() const override
37 {
38 return false;
39 }
40
41 bool GeneratesFilesFromUserInput() const override
42 {
43 return !this->m_outputDataset.GetName().empty();
44 }
45
46 protected:
47 explicit GDALMaterializeStepAlgorithm(const char *helpURL);
48
49 int GetInputType() const override
50 {
51 return nDatasetType;
52 }
53
54 int GetOutputType() const override
55 {
56 return nDatasetType;
57 }
58};
59
60/************************************************************************/
61/* GDALMaterializeStepAlgorithm::GDALMaterializeStepAlgorithm() */
62/************************************************************************/
63
64 template <class BaseStepAlgorithm, int nDatasetType>
65GDALMaterializeStepAlgorithm<BaseStepAlgorithm, nDatasetType>::
66 GDALMaterializeStepAlgorithm(const char *helpURL)
67 : BaseStepAlgorithm(NAME, DESCRIPTION, helpURL,
68 GDALPipelineStepAlgorithm::ConstructorOptions()
69 .SetAddDefaultArguments(false))
70{
71}
72
73/************************************************************************/
74/* GDALMaterializeRasterAlgorithm */
75/************************************************************************/
76
77 class GDALMaterializeRasterAlgorithm final
78 : public GDALMaterializeStepAlgorithm<GDALRasterPipelineStepAlgorithm,
79 GDAL_OF_RASTER>
80{
81 public:
82 static constexpr const char *HELP_URL =
83 "/programs/gdal_raster_materialize.html";
84
85 GDALMaterializeRasterAlgorithm();
86
87 private:
88 bool RunStep(GDALPipelineStepRunContext &ctxt) override;
89};
90
91/************************************************************************/
92/* GDALMaterializeVectorAlgorithm */
93/************************************************************************/
94
95 class GDALMaterializeVectorAlgorithm final
96 : public GDALMaterializeStepAlgorithm<GDALVectorPipelineStepAlgorithm,
97 GDAL_OF_VECTOR>
98{
99 public:
100 static constexpr const char *HELP_URL =
101 "/programs/gdal_vector_materialize.html";
102
103 GDALMaterializeVectorAlgorithm();
104
105 private:
106 bool RunStep(GDALPipelineStepRunContext &ctxt) override;
107};
108
110
111#endif