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

Method GDALVectorRenameLayerAlgorithm

apps/gdalalg_vector_rename_layer.cpp:29–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27/************************************************************************/
28
29GDALVectorRenameLayerAlgorithm::GDALVectorRenameLayerAlgorithm(
30 bool standaloneStep)
31 : GDALVectorPipelineStepAlgorithm(
32 NAME, DESCRIPTION, HELP_URL,
33 ConstructorOptions()
34 .SetStandaloneStep(standaloneStep)
35 .SetAddInputLayerNameArgument(false)
36 .SetOutputLayerNameAvailableInPipelineStep(true))
37{
38 AddLayerNameArg(&m_inputLayerName);
39 if (!standaloneStep)
40 {
41 AddOutputLayerNameArg(/* hiddenForCLI = */ false,
42 /* shortNameOutputLayerAllowed = */ false);
43 }
44 AddArg("ascii", 0, _("Force names to ASCII character"), &m_ascii);
45 AddArg("lower-case", 0,
46 _("Force names to lower case (only on ASCII characters)"),
47 &m_lowerCase);
48 AddArg("filename-compatible", 0, _("Force names to be usable as filenames"),
49 &m_filenameCompatible);
50 AddArg("reserved-characters", 0, _("Reserved character(s) to be removed"),
51 &m_reservedChars);
52 AddArg("replacement-character", 0,
53 _("Replacement character when ASCII conversion not possible"),
54 &m_replacementChar)
55 .SetMaxCharCount(1);
56 AddArg("max-length", 0, _("Maximum length of layer names"), &m_maxLength)
57 .SetMinValueIncluded(1);
58
59 AddValidationAction(
60 [this]()
61 {
62 if (!m_inputLayerName.empty() && m_outputLayerName.empty())
63 {
64 ReportError(CE_Failure, CPLE_AppDefined,
65 "Argument output-layer must be specified when "
66 "input-layer is specified");
67 return false;
68 }
69
70 if (!m_inputDataset.empty() && m_inputDataset[0].GetDatasetRef())
71 {
72 auto poSrcDS = m_inputDataset[0].GetDatasetRef();
73 if (!m_inputLayerName.empty() &&
74 poSrcDS->GetLayerByName(m_inputLayerName.c_str()) ==
75 nullptr)
76 {
77 ReportError(CE_Failure, CPLE_AppDefined,
78 "Input layer '%s' does not exist",
79 m_inputLayerName.c_str());
80 return false;
81 }
82
83 if (!m_outputLayerName.empty() && m_inputLayerName.empty() &&
84 poSrcDS->GetLayerCount() >= 2)
85 {
86 ReportError(CE_Failure, CPLE_AppDefined,

Callers

nothing calls this directly

Calls 7

ConstructorOptionsClass · 0.85
AddValidationActionFunction · 0.85
ReportErrorFunction · 0.50
emptyMethod · 0.45
GetLayerByNameMethod · 0.45
c_strMethod · 0.45
GetLayerCountMethod · 0.45

Tested by

no test coverage detected