| 55 | /************************************************************************/ |
| 56 | |
| 57 | GDALVectorPartitionAlgorithm::GDALVectorPartitionAlgorithm(bool standaloneStep) |
| 58 | : GDALVectorPipelineStepAlgorithm(NAME, DESCRIPTION, HELP_URL, |
| 59 | GetConstructorOptions(standaloneStep)) |
| 60 | { |
| 61 | if (standaloneStep) |
| 62 | { |
| 63 | AddVectorInputArgs(false); |
| 64 | } |
| 65 | else |
| 66 | { |
| 67 | AddVectorHiddenInputDatasetArg(); |
| 68 | } |
| 69 | AddProgressArg(); |
| 70 | |
| 71 | AddArg(GDAL_ARG_NAME_OUTPUT, 'o', _("Output directory"), &m_output) |
| 72 | .SetRequired() |
| 73 | .SetIsInput() |
| 74 | .SetMinCharCount(1) |
| 75 | .SetPositional(); |
| 76 | |
| 77 | constexpr const char *OVERWRITE_APPEND_EXCLUSION_GROUP = "overwrite-append"; |
| 78 | AddOverwriteArg(&m_overwrite) |
| 79 | .SetMutualExclusionGroup(OVERWRITE_APPEND_EXCLUSION_GROUP); |
| 80 | AddAppendLayerArg(&m_appendLayer) |
| 81 | .SetMutualExclusionGroup(OVERWRITE_APPEND_EXCLUSION_GROUP); |
| 82 | AddUpdateArg(&m_update).SetHidden(); |
| 83 | |
| 84 | AddOutputFormatArg(&m_format, /* bStreamAllowed = */ false, |
| 85 | /* bGDALGAllowed = */ false) |
| 86 | .AddMetadataItem(GAAMDI_REQUIRED_CAPABILITIES, |
| 87 | {GDAL_DCAP_VECTOR, GDAL_DCAP_CREATE}); |
| 88 | AddCreationOptionsArg(&m_creationOptions); |
| 89 | AddLayerCreationOptionsArg(&m_layerCreationOptions); |
| 90 | |
| 91 | auto &fieldNameArg = AddArg( |
| 92 | "field", 0, _("Attribute or geometry field(s) on which to partition"), |
| 93 | &m_fields); |
| 94 | SetAutoCompleteFunctionForFieldName(fieldNameArg, nullptr, |
| 95 | /* attributeFields = */ true, |
| 96 | /* geometryFields = */ true, |
| 97 | m_inputDataset); |
| 98 | AddArg("scheme", 0, _("Partitioning scheme"), &m_scheme) |
| 99 | .SetChoices(SCHEME_HIVE, SCHEME_FLAT) |
| 100 | .SetDefault(m_scheme); |
| 101 | AddArg("pattern", 0, |
| 102 | _("Filename pattern ('part_%010d' for scheme=hive, " |
| 103 | "'{LAYER_NAME}_{FIELD_VALUE}_%010d' for scheme=flat)"), |
| 104 | &m_pattern) |
| 105 | .SetMinCharCount(1) |
| 106 | .AddValidationAction( |
| 107 | [this]() |
| 108 | { |
| 109 | if (!m_pattern.empty()) |
| 110 | { |
| 111 | const auto nPercentPos = m_pattern.find('%'); |
| 112 | if (nPercentPos == std::string::npos) |
| 113 | { |
| 114 | ReportError(CE_Failure, CPLE_IllegalArg, "%s", |
nothing calls this directly
no test coverage detected