MCPcopy Create free account
hub / github.com/OSGeo/gdal / GDALVectorCreateAlgorithm

Method GDALVectorCreateAlgorithm

apps/gdalalg_vector_create.cpp:28–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26/************************************************************************/
27
28GDALVectorCreateAlgorithm::GDALVectorCreateAlgorithm(bool standaloneStep)
29 : GDALVectorPipelineStepAlgorithm(
30 NAME, DESCRIPTION, HELP_URL,
31 ConstructorOptions()
32 .SetStandaloneStep(standaloneStep)
33 .SetOutputFormatCreateCapability(GDAL_DCAP_CREATE)
34
35 // Remove defaults because input is the optional template
36 .SetAddDefaultArguments(false)
37
38 // For --like input template
39 .SetAutoOpenInputDatasets(true)
40 .SetInputDatasetHelpMsg(_("Template vector dataset"))
41 .SetInputDatasetAlias("like")
42 .SetInputDatasetRequired(false)
43 .SetInputDatasetPositional(false)
44 .SetInputDatasetMaxCount(1)
45 .SetInputDatasetMetaVar("TEMPLATE-DATASET")
46
47 // Remove arguments that don't make sense in a create context
48 // Note: this is required despite SetAddDefaultArguments(false)
49 .SetAddUpsertArgument(false)
50 .SetAddSkipErrorsArgument(false)
51 .SetAddAppendLayerArgument(false))
52{
53
54 AddVectorInputArgs(false);
55 AddVectorOutputArgs(/* hiddenForCLI = */ false,
56 /* shortNameOutputLayerAllowed=*/false);
57 AddGeometryTypeArg(&m_geometryType, _("Layer geometry type"));
58
59 // Add optional geometry field name argument, not all drivers support it, and if not specified, the default "geom" name will be used.
60 auto &geomFieldNameArg =
61 AddArg("geometry-field", 0,
62 _("Name of the geometry field to create (if supported by the "
63 "output format)"),
64 &m_geometryFieldName)
65 .SetMetaVar("GEOMETRY-FIELD")
66 .SetDefault(m_geometryFieldName);
67
68 AddArg("crs", 0, _("Set CRS"), &m_crs)
69 .AddHiddenAlias("srs")
70 .SetIsCRSArg(/*noneAllowed=*/false);
71
72 AddArg("fid", 0, _("FID column name"), &m_fidColumnName);
73
74 constexpr auto inputMutexGroup = "like-schema-field";
75
76 // Apply mutex to GDAL_ARG_NAME_INPUT
77 // This is hackish and I really don't like const_cast but I couldn't find another way.
78 const_cast<GDALAlgorithmArgDecl &>(
79 GetArg(GDAL_ARG_NAME_INPUT)->GetDeclaration())
80 .SetMutualExclusionGroup(inputMutexGroup);
81
82 // Add --schema argument to read OGR_SCHEMA and populate field definitions from it. It is mutually exclusive with --like and --field arguments.
83 AddArg("schema", 0,
84 _("Read OGR_SCHEMA and populate field definitions from it"),
85 &m_schemaJsonOrPath)

Callers

nothing calls this directly

Calls 6

ConstructorOptionsClass · 0.85
GetArgFunction · 0.85
AddValidationActionFunction · 0.85
SetDefaultMethod · 0.80
ReportErrorFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected