Skip to content

Commit 759b29f

Browse files
authored
Move 'gdal vector geom' subcommands directly under 'gdal vector', and rename 'set-type' as 'set-geom-type' (#12439)
* Add GDALAlgorithm::IsHidden() and WarnIfDeprecated() * gdal raster/vector pipeline: do not show hidden algorithms in usage * Move 'gdal vector geom' subcommands directly under 'gdal vector', and rename 'set-type' as 'set-geom-type' The old path can still be used in 3.12, but with a runtime message at Run() time advertizing that it will be removed in 3.13 Fixes #12422
2 parents 2f9b255 + f22969e commit 759b29f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+658
-955
lines changed

MIGRATION_GUIDE.TXT

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
MIGRATION GUIDE FROM GDAL 3.11 to GDAL 3.12
2+
-------------------------------------------
3+
4+
- The following changes have been done to the "gdal" command line interface:
5+
6+
* Sub-commands "buffer", "explode-collections", "make-valid", "segmentize",
7+
"simplify", "swap-xy" of "gdal vector geom" are now directly available
8+
under "gdal vector". Support for the old location is kept for 3.12, but
9+
will be definitely removed in 3.13.
10+
* Furthermore, sub-command "set-type" of "gdal vector geom" is renamed as
11+
"set-geom-type" and also placed under "gdal vector".
12+
13+
114
MIGRATION GUIDE FROM GDAL 3.10 to GDAL 3.11
215
-------------------------------------------
316

apps/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ add_library(
7272
gdalalg_vector_read.cpp
7373
gdalalg_vector_filter.cpp
7474
gdalalg_vector_geom.cpp
75-
gdalalg_vector_geom_set_type.cpp
76-
gdalalg_vector_geom_explode_collections.cpp
77-
gdalalg_vector_geom_make_valid.cpp
78-
gdalalg_vector_geom_segmentize.cpp
79-
gdalalg_vector_geom_simplify.cpp
80-
gdalalg_vector_geom_simplify_coverage.cpp
81-
gdalalg_vector_geom_buffer.cpp
82-
gdalalg_vector_geom_swap_xy.cpp
75+
gdalalg_vector_set_geom_type.cpp
76+
gdalalg_vector_explode_collections.cpp
77+
gdalalg_vector_make_valid.cpp
78+
gdalalg_vector_segmentize.cpp
79+
gdalalg_vector_simplify.cpp
80+
gdalalg_vector_simplify_coverage.cpp
81+
gdalalg_vector_buffer.cpp
82+
gdalalg_vector_swap_xy.cpp
8383
gdalalg_vector_grid.cpp
8484
gdalalg_vector_grid_average.cpp
8585
gdalalg_vector_grid_data_metrics.cpp

apps/gdalalg_abstract_pipeline.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,12 @@ std::string GDALAbstractPipelineAlgorithm<StepAlgorithm>::GetUsageAsJSON() const
463463
for (const std::string &name : m_stepRegistry.GetNames())
464464
{
465465
auto alg = GetStepAlg(name);
466-
CPLJSONDocument oStepDoc;
467-
CPL_IGNORE_RET_VAL(oStepDoc.LoadMemory(alg->GetUsageAsJSON()));
468-
jPipelineSteps.Add(oStepDoc.GetRoot());
466+
if (!alg->IsHidden())
467+
{
468+
CPLJSONDocument oStepDoc;
469+
CPL_IGNORE_RET_VAL(oStepDoc.LoadMemory(alg->GetUsageAsJSON()));
470+
jPipelineSteps.Add(oStepDoc.GetRoot());
471+
}
469472
}
470473
oDoc.GetRoot().Add("pipeline_algorithms", jPipelineSteps);
471474

apps/gdalalg_raster_pipeline.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,13 @@ std::string GDALRasterPipelineAlgorithm::GetUsageForCLI(
686686
if (name != GDALRasterReadAlgorithm::NAME &&
687687
name != GDALRasterWriteAlgorithm::NAME)
688688
{
689-
ret += '\n';
690689
auto alg = GetStepAlg(name);
691-
alg->SetCallPath({name});
692-
ret += alg->GetUsageForCLI(shortUsage, stepUsageOptions);
690+
if (!alg->IsHidden())
691+
{
692+
ret += '\n';
693+
alg->SetCallPath({name});
694+
ret += alg->GetUsageForCLI(shortUsage, stepUsageOptions);
695+
}
693696
}
694697
}
695698
{

apps/gdalalg_vector.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,27 @@
1313
#include "gdalalgorithm.h"
1414

1515
#include "gdalalg_vector_info.h"
16+
#include "gdalalg_vector_buffer.h"
1617
#include "gdalalg_vector_clip.h"
1718
#include "gdalalg_vector_concat.h"
1819
#include "gdalalg_vector_convert.h"
1920
#include "gdalalg_vector_edit.h"
21+
#include "gdalalg_vector_explode_collections.h"
2022
#include "gdalalg_vector_geom.h"
2123
#include "gdalalg_vector_grid.h"
2224
#include "gdalalg_vector_layer_algebra.h"
2325
#include "gdalalg_vector_pipeline.h"
2426
#include "gdalalg_vector_rasterize.h"
2527
#include "gdalalg_vector_filter.h"
2628
#include "gdalalg_vector_reproject.h"
29+
#include "gdalalg_vector_segmentize.h"
2730
#include "gdalalg_vector_select.h"
31+
#include "gdalalg_vector_set_geom_type.h"
32+
#include "gdalalg_vector_simplify.h"
33+
#include "gdalalg_vector_simplify_coverage.h"
2834
#include "gdalalg_vector_sql.h"
35+
#include "gdalalg_vector_make_valid.h"
36+
#include "gdalalg_vector_swap_xy.h"
2937

3038
#include "gdal_priv.h"
3139

@@ -53,19 +61,27 @@ class GDALVectorAlgorithm final : public GDALAlgorithm
5361
AddOutputStringArg(&m_output);
5462

5563
RegisterSubAlgorithm<GDALVectorInfoAlgorithm>();
64+
RegisterSubAlgorithm<GDALVectorBufferAlgorithmStandalone>();
5665
RegisterSubAlgorithm<GDALVectorClipAlgorithmStandalone>();
5766
RegisterSubAlgorithm<GDALVectorConcatAlgorithmStandalone>();
5867
RegisterSubAlgorithm<GDALVectorConvertAlgorithm>();
5968
RegisterSubAlgorithm<GDALVectorEditAlgorithmStandalone>();
69+
RegisterSubAlgorithm<GDALVectorExplodeCollectionsAlgorithmStandalone>();
6070
RegisterSubAlgorithm<GDALVectorGridAlgorithm>();
6171
RegisterSubAlgorithm<GDALVectorRasterizeAlgorithm>();
6272
RegisterSubAlgorithm<GDALVectorPipelineAlgorithm>();
6373
RegisterSubAlgorithm<GDALVectorFilterAlgorithmStandalone>();
6474
RegisterSubAlgorithm<GDALVectorGeomAlgorithmStandalone>();
6575
RegisterSubAlgorithm<GDALVectorLayerAlgebraAlgorithm>();
76+
RegisterSubAlgorithm<GDALVectorMakeValidAlgorithmStandalone>();
6677
RegisterSubAlgorithm<GDALVectorReprojectAlgorithmStandalone>();
78+
RegisterSubAlgorithm<GDALVectorSegmentizeAlgorithmStandalone>();
6779
RegisterSubAlgorithm<GDALVectorSelectAlgorithmStandalone>();
80+
RegisterSubAlgorithm<GDALVectorSetGeomTypeAlgorithmStandalone>();
81+
RegisterSubAlgorithm<GDALVectorSimplifyAlgorithmStandalone>();
82+
RegisterSubAlgorithm<GDALVectorSimplifyCoverageAlgorithmStandalone>();
6883
RegisterSubAlgorithm<GDALVectorSQLAlgorithmStandalone>();
84+
RegisterSubAlgorithm<GDALVectorSwapXYAlgorithmStandalone>();
6985
}
7086

7187
private:

apps/gdalalg_vector_geom_buffer.cpp renamed to apps/gdalalg_vector_buffer.cpp

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/******************************************************************************
22
*
33
* Project: GDAL
4-
* Purpose: "gdal vector geom buffer"
4+
* Purpose: "gdal vector buffer"
55
* Author: Even Rouault <even dot rouault at spatialys.com>
66
*
77
******************************************************************************
@@ -10,7 +10,7 @@
1010
* SPDX-License-Identifier: MIT
1111
****************************************************************************/
1212

13-
#include "gdalalg_vector_geom_buffer.h"
13+
#include "gdalalg_vector_buffer.h"
1414

1515
#include "gdal_priv.h"
1616
#include "ogrsf_frmts.h"
@@ -22,11 +22,10 @@
2222
#endif
2323

2424
/************************************************************************/
25-
/* GDALVectorGeomBufferAlgorithm() */
25+
/* GDALVectorBufferAlgorithm() */
2626
/************************************************************************/
2727

28-
GDALVectorGeomBufferAlgorithm::GDALVectorGeomBufferAlgorithm(
29-
bool standaloneStep)
28+
GDALVectorBufferAlgorithm::GDALVectorBufferAlgorithm(bool standaloneStep)
3029
: GDALVectorGeomAbstractAlgorithm(NAME, DESCRIPTION, HELP_URL,
3130
standaloneStep, m_opts)
3231
{
@@ -63,16 +62,16 @@ namespace
6362
{
6463

6564
/************************************************************************/
66-
/* GDALVectorGeomBufferAlgorithmLayer */
65+
/* GDALVectorBufferAlgorithmLayer */
6766
/************************************************************************/
6867

69-
class GDALVectorGeomBufferAlgorithmLayer final
70-
: public GDALVectorGeomOneToOneAlgorithmLayer<GDALVectorGeomBufferAlgorithm>
68+
class GDALVectorBufferAlgorithmLayer final
69+
: public GDALVectorGeomOneToOneAlgorithmLayer<GDALVectorBufferAlgorithm>
7170
{
7271
public:
73-
GDALVectorGeomBufferAlgorithmLayer(
74-
OGRLayer &oSrcLayer, const GDALVectorGeomBufferAlgorithm::Options &opts)
75-
: GDALVectorGeomOneToOneAlgorithmLayer<GDALVectorGeomBufferAlgorithm>(
72+
GDALVectorBufferAlgorithmLayer(
73+
OGRLayer &oSrcLayer, const GDALVectorBufferAlgorithm::Options &opts)
74+
: GDALVectorGeomOneToOneAlgorithmLayer<GDALVectorBufferAlgorithm>(
7675
oSrcLayer, opts)
7776
{
7877
m_aosBufferOptions.SetNameValue("ENDCAP_STYLE",
@@ -100,8 +99,7 @@ class GDALVectorGeomBufferAlgorithmLayer final
10099
/* TranslateFeature() */
101100
/************************************************************************/
102101

103-
std::unique_ptr<OGRFeature>
104-
GDALVectorGeomBufferAlgorithmLayer::TranslateFeature(
102+
std::unique_ptr<OGRFeature> GDALVectorBufferAlgorithmLayer::TranslateFeature(
105103
std::unique_ptr<OGRFeature> poSrcFeature) const
106104
{
107105
const int nGeomFieldCount = poSrcFeature->GetGeomFieldCount();
@@ -133,28 +131,25 @@ GDALVectorGeomBufferAlgorithmLayer::TranslateFeature(
133131
#endif // HAVE_GEOS
134132

135133
/************************************************************************/
136-
/* GDALVectorGeomBufferAlgorithm::CreateAlgLayer() */
134+
/* GDALVectorBufferAlgorithm::CreateAlgLayer() */
137135
/************************************************************************/
138136

139137
std::unique_ptr<OGRLayerWithTranslateFeature>
140-
GDALVectorGeomBufferAlgorithm::CreateAlgLayer(
141-
[[maybe_unused]] OGRLayer &srcLayer)
138+
GDALVectorBufferAlgorithm::CreateAlgLayer([[maybe_unused]] OGRLayer &srcLayer)
142139
{
143140
#ifdef HAVE_GEOS
144-
return std::make_unique<GDALVectorGeomBufferAlgorithmLayer>(srcLayer,
145-
m_opts);
141+
return std::make_unique<GDALVectorBufferAlgorithmLayer>(srcLayer, m_opts);
146142
#else
147143
CPLAssert(false);
148144
return nullptr;
149145
#endif
150146
}
151147

152148
/************************************************************************/
153-
/* GDALVectorGeomBufferAlgorithm::RunStep() */
149+
/* GDALVectorBufferAlgorithm::RunStep() */
154150
/************************************************************************/
155151

156-
bool GDALVectorGeomBufferAlgorithm::RunStep(
157-
GDALVectorPipelineStepRunContext &ctxt)
152+
bool GDALVectorBufferAlgorithm::RunStep(GDALVectorPipelineStepRunContext &ctxt)
158153
{
159154
#ifdef HAVE_GEOS
160155
if (m_opts.m_side == "right")
Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/******************************************************************************
22
*
33
* Project: GDAL
4-
* Purpose: "gdal vector geom buffer"
4+
* Purpose: "gdal vector buffer"
55
* Author: Even Rouault <even dot rouault at spatialys.com>
66
*
77
******************************************************************************
@@ -10,26 +10,25 @@
1010
* SPDX-License-Identifier: MIT
1111
****************************************************************************/
1212

13-
#ifndef GDALALG_VECTOR_GEOM_BUFFER_INCLUDED
14-
#define GDALALG_VECTOR_GEOM_BUFFER_INCLUDED
13+
#ifndef GDALALG_VECTOR_BUFFER_INCLUDED
14+
#define GDALALG_VECTOR_BUFFER_INCLUDED
1515

1616
#include "gdalalg_vector_geom.h"
1717

1818
//! @cond Doxygen_Suppress
1919

2020
/************************************************************************/
21-
/* GDALVectorGeomBufferAlgorithm */
21+
/* GDALVectorBufferAlgorithm */
2222
/************************************************************************/
2323

24-
class GDALVectorGeomBufferAlgorithm final
24+
class GDALVectorBufferAlgorithm /* non final */
2525
: public GDALVectorGeomAbstractAlgorithm
2626
{
2727
public:
2828
static constexpr const char *NAME = "buffer";
2929
static constexpr const char *DESCRIPTION =
3030
"Compute a buffer around geometries of a vector dataset.";
31-
static constexpr const char *HELP_URL =
32-
"/programs/gdal_vector_geom_buffer.html";
31+
static constexpr const char *HELP_URL = "/programs/gdal_vector_buffer.html";
3332

3433
struct Options : public GDALVectorGeomAbstractAlgorithm::OptionsBase
3534
{
@@ -44,14 +43,28 @@ class GDALVectorGeomBufferAlgorithm final
4443
std::unique_ptr<OGRLayerWithTranslateFeature>
4544
CreateAlgLayer(OGRLayer &srcLayer) override;
4645

47-
explicit GDALVectorGeomBufferAlgorithm(bool standaloneStep);
46+
explicit GDALVectorBufferAlgorithm(bool standaloneStep = false);
4847

4948
private:
5049
bool RunStep(GDALVectorPipelineStepRunContext &ctxt) override;
5150

5251
Options m_opts{};
5352
};
5453

54+
/************************************************************************/
55+
/* GDALVectorBufferAlgorithmStandalone */
56+
/************************************************************************/
57+
58+
class GDALVectorBufferAlgorithmStandalone final
59+
: public GDALVectorBufferAlgorithm
60+
{
61+
public:
62+
GDALVectorBufferAlgorithmStandalone()
63+
: GDALVectorBufferAlgorithm(/* standaloneStep = */ true)
64+
{
65+
}
66+
};
67+
5568
//! @endcond
5669

57-
#endif /* GDALALG_VECTOR_GEOM_BUFFER_INCLUDED */
70+
#endif /* GDALALG_VECTOR_BUFFER_INCLUDED */

0 commit comments

Comments
 (0)