Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: gdal "mdim" subcommand 5 : * Author: Even Rouault <even dot rouault at spatialys.com> 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2024, Even Rouault <even dot rouault at spatialys.com> 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #include "gdalalgorithm.h" 14 : 15 : #include "gdalalg_mdim_info.h" 16 : #include "gdalalg_mdim_convert.h" 17 : 18 : #include "gdal_priv.h" 19 : 20 : #ifndef _ 21 : #define _(x) (x) 22 : #endif 23 : 24 : /************************************************************************/ 25 : /* GDALMdimAlgorithm */ 26 : /************************************************************************/ 27 : 28 : class GDALMdimAlgorithm final : public GDALAlgorithm 29 : { 30 : public: 31 : static constexpr const char *NAME = "mdim"; 32 : static constexpr const char *DESCRIPTION = "Multidimensional commands."; 33 : static constexpr const char *HELP_URL = "/programs/gdal_mdim.html"; 34 : 35 26 : GDALMdimAlgorithm() : GDALAlgorithm(NAME, DESCRIPTION, HELP_URL) 36 : { 37 : AddArg("drivers", 0, 38 : _("Display multidimensional driver list as JSON document"), 39 26 : &m_drivers); 40 : 41 26 : AddOutputStringArg(&m_output); 42 : 43 26 : RegisterSubAlgorithm<GDALMdimInfoAlgorithm>(); 44 26 : RegisterSubAlgorithm<GDALMdimConvertAlgorithm>(); 45 26 : } 46 : 47 : private: 48 : std::string m_output{}; 49 : bool m_drivers = false; 50 : 51 : bool RunImpl(GDALProgressFunc, void *) override; 52 : }; 53 : 54 2 : bool GDALMdimAlgorithm::RunImpl(GDALProgressFunc, void *) 55 : { 56 2 : if (m_drivers) 57 : { 58 1 : m_output = GDALPrintDriverList(GDAL_OF_MULTIDIM_RASTER, true); 59 1 : return true; 60 : } 61 : else 62 : { 63 1 : CPLError(CE_Failure, CPLE_AppDefined, 64 : "The Run() method should not be called directly on the \"gdal " 65 : "mdim\" program."); 66 1 : return false; 67 : } 68 : } 69 : 70 : GDAL_STATIC_REGISTER_ALG(GDALMdimAlgorithm);