| 29 | /************************************************************************/ |
| 30 | |
| 31 | GDALVectorSelectAlgorithm::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 | |
| 76 | namespace |
| 77 | { |
nothing calls this directly
no test coverage detected