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

Method GDALVectorSelectAlgorithm

apps/gdalalg_vector_select.cpp:31–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29/************************************************************************/
30
31GDALVectorSelectAlgorithm::GDALVectorSelectAlgorithm(bool standaloneStep)
32 : GDALVectorPipelineStepAlgorithm(
33 NAME, DESCRIPTION, HELP_URL,
34 ConstructorOptions()
35 .SetStandaloneStep(standaloneStep)
36 .SetOutputLayerNameAvailableInPipelineStep(true))
37{
38 AddActiveLayerArg(&m_activeLayer);
39 if (!standaloneStep)
40 {
41 AddOutputLayerNameArg(/* hiddenForCLI = */ false,
42 /* shortNameOutputLayerAllowed = */ false);
43 }
44 AddArg("fields", 0, _("Fields to select (or exclude if --exclude)"),
45 &m_fields)
46 .SetDuplicateValuesAllowed(false)
47 .SetPositional()
48 .SetRequired();
49 AddArg("exclude", 0, _("Exclude specified fields"), &m_exclude)
50 .SetDuplicateValuesAllowed(false)
51 .SetMutualExclusionGroup("exclude-ignore");
52 AddArg("ignore-missing-fields", 0, _("Ignore missing fields"),
53 &m_ignoreMissingFields)
54 .SetMutualExclusionGroup("exclude-ignore");
55
56 AddValidationAction(
57 [this]()
58 {
59 if (!m_outputLayerName.empty() && m_activeLayer.empty() &&
60 m_inputDataset.size() == 1)
61 {
62 auto poSrcDS = m_inputDataset[0].GetDatasetRef();
63 if (poSrcDS && poSrcDS->GetLayerCount() > 1)
64 {
65 ReportError(CE_Failure, CPLE_IllegalArg,
66 "Argument 'output-layer' cannot be used when "
67 "the input dataset has multiple layers, unless "
68 "argument 'active-layer' is specified");
69 return false;
70 }
71 }
72 return true;
73 });
74}
75
76namespace
77{

Callers

nothing calls this directly

Calls 7

ConstructorOptionsClass · 0.85
AddValidationActionFunction · 0.85
SetPositionalMethod · 0.80
ReportErrorFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
GetLayerCountMethod · 0.45

Tested by

no test coverage detected