LCOV - code coverage report
Current view: top level - apps - gdalalg_pipeline.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 12 12 100.0 %
Date: 2025-01-18 12:42:00 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  gdal "pipeline" 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 "cpl_error.h"
      14             : #include "gdalalgorithm.h"
      15             : #include "gdalalg_raster_pipeline.h"
      16             : #include "gdalalg_vector_pipeline.h"
      17             : #include "gdalalg_dispatcher.h"
      18             : #include "gdal_priv.h"
      19             : 
      20             : /************************************************************************/
      21             : /*                       GDALPipelineAlgorithm                          */
      22             : /************************************************************************/
      23             : 
      24             : class GDALPipelineAlgorithm final
      25             :     : public GDALDispatcherAlgorithm<GDALRasterPipelineAlgorithm,
      26             :                                      GDALVectorPipelineAlgorithm>
      27             : {
      28             :   public:
      29             :     static constexpr const char *NAME = "pipeline";
      30             :     static constexpr const char *DESCRIPTION =
      31             :         "Execute a pipeline (shortcut for 'gdal raster pipeline' or 'gdal "
      32             :         "vector pipeline').";
      33             :     static constexpr const char *HELP_URL = "/programs/gdal_pipeline.html";
      34             : 
      35        1414 :     static std::vector<std::string> GetAliases()
      36             :     {
      37        1414 :         return {};
      38             :     }
      39             : 
      40           6 :     GDALPipelineAlgorithm()
      41           6 :         : GDALDispatcherAlgorithm(NAME, DESCRIPTION, HELP_URL)
      42             :     {
      43             :         // only for the help message
      44           6 :         AddOutputFormatArg(&m_format).SetDefault("json").SetChoices("json",
      45           6 :                                                                     "text");
      46           6 :         AddInputDatasetArg(&m_dataset);
      47             : 
      48             :         m_longDescription =
      49             :             "For all options, run 'gdal raster pipeline --help' or "
      50           6 :             "'gdal vector pipeline --help'";
      51           6 :     }
      52             : 
      53             :   private:
      54             :     std::unique_ptr<GDALRasterPipelineAlgorithm> m_rasterPipeline{};
      55             :     std::unique_ptr<GDALVectorPipelineAlgorithm> m_vectorPipeline{};
      56             : 
      57             :     std::string m_format{};
      58             :     GDALArgDatasetValue m_dataset{};
      59             : 
      60           1 :     bool RunImpl(GDALProgressFunc, void *) override
      61             :     {
      62           1 :         CPLError(CE_Failure, CPLE_AppDefined,
      63             :                  "The Run() method should not be called directly on the \"gdal "
      64             :                  "pipeline\" program.");
      65           1 :         return false;
      66             :     }
      67             : };
      68             : 
      69             : GDAL_STATIC_REGISTER_ALG(GDALPipelineAlgorithm);

Generated by: LCOV version 1.14