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 : #include "gdalalg_mdim_mosaic.h" 18 : 19 : #include "gdal_priv.h" 20 : 21 : #ifndef _ 22 : #define _(x) (x) 23 : #endif 24 : 25 : /************************************************************************/ 26 : /* GDALMdimAlgorithm */ 27 : /************************************************************************/ 28 : 29 : class GDALMdimAlgorithm final : public GDALAlgorithm 30 : { 31 : public: 32 : static constexpr const char *NAME = "mdim"; 33 : static constexpr const char *DESCRIPTION = "Multidimensional commands."; 34 : static constexpr const char *HELP_URL = "/programs/gdal_mdim.html"; 35 : 36 58 : GDALMdimAlgorithm() : GDALAlgorithm(NAME, DESCRIPTION, HELP_URL) 37 : { 38 : AddArg("drivers", 0, 39 : _("Display multidimensional driver list as JSON document"), 40 58 : &m_drivers); 41 : 42 58 : AddOutputStringArg(&m_output); 43 : 44 58 : RegisterSubAlgorithm<GDALMdimInfoAlgorithm>(); 45 58 : RegisterSubAlgorithm<GDALMdimConvertAlgorithm>(); 46 58 : RegisterSubAlgorithm<GDALMdimMosaicAlgorithm>(); 47 58 : } 48 : 49 : private: 50 : std::string m_output{}; 51 : bool m_drivers = false; 52 : 53 : bool RunImpl(GDALProgressFunc, void *) override; 54 : }; 55 : 56 2 : bool GDALMdimAlgorithm::RunImpl(GDALProgressFunc, void *) 57 : { 58 2 : if (m_drivers) 59 : { 60 1 : m_output = GDALPrintDriverList(GDAL_OF_MULTIDIM_RASTER, true); 61 1 : return true; 62 : } 63 : else 64 : { 65 1 : CPLError(CE_Failure, CPLE_AppDefined, 66 : "The Run() method should not be called directly on the \"gdal " 67 : "mdim\" program."); 68 1 : return false; 69 : } 70 : } 71 : 72 : GDAL_STATIC_REGISTER_ALG(GDALMdimAlgorithm);