File: gdalalg_convert.cpp

package info (click to toggle)
gdal 3.12.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 92,292 kB
  • sloc: cpp: 1,223,498; ansic: 206,434; python: 26,278; java: 6,001; xml: 4,769; sh: 3,855; cs: 2,513; yacc: 1,306; makefile: 214
file content (63 lines) | stat: -rw-r--r-- 2,188 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/******************************************************************************
 *
 * Project:  GDAL
 * Purpose:  gdal "convert" subcommand
 * Author:   Even Rouault <even dot rouault at spatialys.com>
 *
 ******************************************************************************
 * Copyright (c) 2024, Even Rouault <even dot rouault at spatialys.com>
 *
 * SPDX-License-Identifier: MIT
 ****************************************************************************/

#include "cpl_error.h"
#include "gdalalgorithm.h"
#include "gdalalg_raster_convert.h"
#include "gdalalg_vector_convert.h"
#include "gdalalg_dispatcher.h"
#include "gdal_priv.h"

/************************************************************************/
/*                        GDALConvertAlgorithm                          */
/************************************************************************/

class GDALConvertAlgorithm final
    : public GDALDispatcherAlgorithm<GDALRasterConvertAlgorithm,
                                     GDALVectorConvertAlgorithm>
{
  public:
    static constexpr const char *NAME = "convert";
    static constexpr const char *DESCRIPTION =
        "Convert a dataset (shortcut for 'gdal raster convert' or "
        "'gdal vector convert').";
    static constexpr const char *HELP_URL = "/programs/gdal_convert.html";

    static std::vector<std::string> GetAliasesStatic()
    {
        return {GDALAlgorithmRegistry::HIDDEN_ALIAS_SEPARATOR, "translate"};
    }

    GDALConvertAlgorithm()
        : GDALDispatcherAlgorithm(NAME, DESCRIPTION, HELP_URL)
    {
        // only for the help message
        AddProgressArg();
        AddOutputFormatArg(&m_format);
        AddInputDatasetArg(&m_inputDataset);
        AddOutputDatasetArg(&m_outputDataset);

        m_longDescription = "For all options, run 'gdal raster convert --help' "
                            "or 'gdal vector convert --help'";
    }

    ~GDALConvertAlgorithm() override;

  private:
    std::string m_format{};
    GDALArgDatasetValue m_inputDataset{};
    GDALArgDatasetValue m_outputDataset{};
};

GDALConvertAlgorithm::~GDALConvertAlgorithm() = default;

GDAL_STATIC_REGISTER_ALG(GDALConvertAlgorithm);