GDAL

gdalalg_vector_set_field_type.h
1/******************************************************************************
2 *
3 * Project: GDAL
4 * Purpose: "set-field-type" step of "vector pipeline"
5 * Author: Alessandro Pasotti <elpaso at itopen dot it>
6 *
7 ******************************************************************************
8 * Copyright (c) 2025, Alessandro Pasotti <elpaso at itopen dot it>
9 *
10 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13#ifndef GDALALG_VECTOR_SET_FIELD_TYPE_INCLUDED
14#define GDALALG_VECTOR_SET_FIELD_TYPE_INCLUDED
15
16#include "gdalalg_vector_pipeline.h"
17
19
20/************************************************************************/
21/* GDALVectorSetFieldTypeAlgorithm */
22/************************************************************************/
23
24 class GDALVectorSetFieldTypeAlgorithm /* non final */
25 : public GDALVectorPipelineStepAlgorithm
26{
27 public:
28 static constexpr const char *NAME = "set-field-type";
29 static constexpr const char *DESCRIPTION =
30 "Modify the type of a field of a vector dataset.";
31 static constexpr const char *HELP_URL =
32 "/programs/gdal_vector_set_field_type.html";
33
34 explicit GDALVectorSetFieldTypeAlgorithm(bool standaloneStep = false);
35
36 CPLJSONObject Get_OGR_SCHEMA_OpenOption_Layer() const override;
37
38 private:
39 bool RunStep(GDALPipelineStepRunContext &ctxt) override;
40 bool GlobalValidation() const;
41
42 // NOTE: if adding any option, please update Get_OGR_SCHEMA_OpenOption_Layer() */
43 std::string m_activeLayer{};
44 std::string m_fieldName{};
45 OGRFieldType m_srcFieldType{OGRFieldType::OFTString};
46 OGRFieldSubType m_srcFieldSubType{OGRFieldSubType::OFSTNone};
47 std::string m_srcFieldTypeSubTypeStr{};
48 OGRFieldType m_newFieldType{OGRFieldType::OFTString};
49 OGRFieldSubType m_newFieldSubType{OGRFieldSubType::OFSTNone};
50 std::string m_newFieldTypeSubTypeStr{};
51 // NOTE: if adding any option, please update Get_OGR_SCHEMA_OpenOption_Layer() */
52};
53
54/************************************************************************/
55/* GDALVectorSetFieldTypeAlgorithmStandalone */
56/************************************************************************/
57
58 class GDALVectorSetFieldTypeAlgorithmStandalone final
59 : public GDALVectorSetFieldTypeAlgorithm
60{
61 public:
62 GDALVectorSetFieldTypeAlgorithmStandalone()
63 : GDALVectorSetFieldTypeAlgorithm(/* standaloneStep = */ true)
64 {
65 }
66
67 ~GDALVectorSetFieldTypeAlgorithmStandalone() override;
68};
69
71
72#endif /* GDALALG_VECTOR_SET_FIELD_TYPE_INCLUDED */
CPLJSONObject
The CPLJSONArray class holds JSON object from CPLJSONDocument.
Definition cpl_json.h:56
OGRFieldSubType
OGRFieldSubType
List of field subtypes.
Definition ogr_core.h:799
OFSTNone
@ OFSTNone
No subtype.
Definition ogr_core.h:800
OGRFieldType
OGRFieldType
List of feature field types.
Definition ogr_core.h:772
OFTString
@ OFTString
String of ASCII chars.
Definition ogr_core.h:777