GDAL
gdalalg_vector_create.h
1/******************************************************************************
2 *
3 * Project: GDAL
4 * Purpose: gdal "vector create" subcommand
5 * Author: Alessandro Pasotti <elpaso at itopen dot it>
6 *
7 ******************************************************************************
8 * Copyright (c) 2026, Alessandro Pasotti <elpaso at itopen dot it>
9 *
10 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13#ifndef GDALALG_VECTOR_CREATE_INCLUDED
14#define GDALALG_VECTOR_CREATE_INCLUDED
15
16#include "gdalalg_vector_pipeline.h"
17
19
20/************************************************************************/
21/* GDALVectorCreateAlgorithm */
22/************************************************************************/
23
24class GDALVectorCreateAlgorithm /* non final */
25 : public GDALVectorPipelineStepAlgorithm
26{
27 public:
28 static constexpr const char *NAME = "create";
29 static constexpr const char *DESCRIPTION = "Create a vector dataset.";
30 static constexpr const char *HELP_URL = "/programs/gdal_vector_create.html";
31
32 explicit GDALVectorCreateAlgorithm(bool /* standaloneStep */ = true);
33
34 private:
35 bool RunStep(GDALPipelineStepRunContext &ctxt) override;
36 bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override;
37
43 std::vector<OGRFieldDefn> GetOutputFields() const;
44
45 bool CanBeFirstStep() const override
46 {
47 return true;
48 }
49
50 bool CanBeMiddleStep() const override
51 {
52 return true;
53 }
54
55 bool CanBeLastStep() const override
56 {
57 return true;
58 }
59
64 bool CreateLayer(
65 GDALDataset *poDstDS, const std::string &layerName,
66 const std::string &fidColumnName,
67 const std::vector<OGRFieldDefn> &fieldDefinitions,
68 const std::vector<OGRGeomFieldDefn> &geometryFieldDefinitions) const;
69
70 std::string m_crs{};
71 std::string m_fidColumnName{};
72 std::string m_geometryType{};
73 std::string m_geometryFieldName{"geom"};
74 std::string m_schemaJsonOrPath{};
75 std::vector<OGRFieldDefn> m_fieldDefinitions{};
76 std::vector<std::string> m_fieldStrDefinitions{};
77};
78
79/************************************************************************/
80/* GDALVectorCreateAlgorithmStandalone */
81/************************************************************************/
82
83class GDALVectorCreateAlgorithmStandalone final
84 : public GDALVectorCreateAlgorithm
85{
86 public:
87 GDALVectorCreateAlgorithmStandalone()
88 : GDALVectorCreateAlgorithm(/* standaloneStep = */ true)
89 {
90 }
91
92 ~GDALVectorCreateAlgorithmStandalone() override;
93};
94
96
97#endif // GDALALG_VECTOR_CREATE_INCLUDED
A set of associated raster bands, usually from one file.
Definition gdal_dataset.h:77