LCOV - code coverage report
Current view: top level - apps - gdalalg_raster_pipeline.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 7 7 100.0 %
Date: 2025-06-19 12:30:01 Functions: 4 5 80.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  gdal "raster 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             : #ifndef GDALALG_RASTER_PIPELINE_INCLUDED
      14             : #define GDALALG_RASTER_PIPELINE_INCLUDED
      15             : 
      16             : #include "gdalalgorithm.h"
      17             : #include "gdalalg_abstract_pipeline.h"
      18             : 
      19             : //! @cond Doxygen_Suppress
      20             : 
      21             : /************************************************************************/
      22             : /*                GDALRasterPipelineStepAlgorithm                       */
      23             : /************************************************************************/
      24             : 
      25        1994 : class GDALRasterPipelineStepAlgorithm /* non final */
      26             :     : public GDALPipelineStepAlgorithm
      27             : {
      28             :   public:
      29             :     ~GDALRasterPipelineStepAlgorithm() override;
      30             : 
      31             :   protected:
      32             :     GDALRasterPipelineStepAlgorithm(const std::string &name,
      33             :                                     const std::string &description,
      34             :                                     const std::string &helpURL,
      35             :                                     bool standaloneStep);
      36             : 
      37             :     GDALRasterPipelineStepAlgorithm(const std::string &name,
      38             :                                     const std::string &description,
      39             :                                     const std::string &helpURL,
      40             :                                     const ConstructorOptions &options);
      41             : 
      42             :     friend class GDALRasterPipelineAlgorithm;
      43             :     friend class GDALAbstractPipelineAlgorithm<GDALRasterPipelineStepAlgorithm>;
      44             :     friend class GDALRasterMosaicStackCommonAlgorithm;
      45             : 
      46         258 :     int GetInputType() const override
      47             :     {
      48         258 :         return GDAL_OF_RASTER;
      49             :     }
      50             : 
      51         267 :     int GetOutputType() const override
      52             :     {
      53         267 :         return GDAL_OF_RASTER;
      54             :     }
      55             : 
      56             :     void SetOutputVRTCompatible(bool b);
      57             : };
      58             : 
      59             : /************************************************************************/
      60             : /*           GDALRasterPipelineNonNativelyStreamingAlgorithm            */
      61             : /************************************************************************/
      62             : 
      63             : class GDALRasterPipelineNonNativelyStreamingAlgorithm /* non-final */
      64             :     : public GDALRasterPipelineStepAlgorithm
      65             : {
      66             :   protected:
      67             :     GDALRasterPipelineNonNativelyStreamingAlgorithm(
      68             :         const std::string &name, const std::string &description,
      69             :         const std::string &helpURL, bool standaloneStep);
      70             : 
      71             :     bool IsNativelyStreamingCompatible() const override;
      72             : 
      73             :     static std::unique_ptr<GDALDataset>
      74             :     CreateTemporaryDataset(int nWidth, int nHeight, int nBands,
      75             :                            GDALDataType eDT, bool bTiledIfPossible,
      76             :                            GDALDataset *poSrcDSForMetadata,
      77             :                            bool bCopyMetadata = true);
      78             :     static std::unique_ptr<GDALDataset>
      79             :     CreateTemporaryCopy(GDALAlgorithm *poAlg, GDALDataset *poSrcDS,
      80             :                         int nSingleBand, bool bTiledIfPossible,
      81             :                         GDALProgressFunc pfnProgress, void *pProgressData);
      82             : };
      83             : 
      84             : /************************************************************************/
      85             : /*                     GDALRasterPipelineAlgorithm                      */
      86             : /************************************************************************/
      87             : 
      88             : // This is an easter egg to pay tribute to PROJ pipeline syntax
      89             : // We accept "gdal vector +gdal=pipeline +step +gdal=read +input=in.tif +step +gdal=reproject +dst-crs=EPSG:32632 +step +gdal=write +output=out.tif +overwrite"
      90             : // as an alternative to (recommended):
      91             : // "gdal vector pipeline ! read in.tif ! reproject--dst-crs=EPSG:32632 ! write out.tif --overwrite"
      92             : #ifndef GDAL_PIPELINE_PROJ_NOSTALGIA
      93             : #define GDAL_PIPELINE_PROJ_NOSTALGIA
      94             : #endif
      95             : 
      96             : class GDALRasterPipelineAlgorithm final
      97             :     : public GDALAbstractPipelineAlgorithm<GDALRasterPipelineStepAlgorithm>
      98             : {
      99             :   public:
     100             :     static constexpr const char *NAME = "pipeline";
     101             :     static constexpr const char *DESCRIPTION = "Process a raster dataset.";
     102             :     static constexpr const char *HELP_URL =
     103             :         "/programs/gdal_raster_pipeline.html";
     104             : 
     105         979 :     static std::vector<std::string> GetAliasesStatic()
     106             :     {
     107             :         return {
     108             : #ifdef GDAL_PIPELINE_PROJ_NOSTALGIA
     109             :             GDALAlgorithmRegistry::HIDDEN_ALIAS_SEPARATOR,
     110             :             "+pipeline",
     111             :             "+gdal=pipeline",
     112             : #endif
     113        3916 :         };
     114             :     }
     115             : 
     116             :     explicit GDALRasterPipelineAlgorithm(bool openForMixedRasterVector = false);
     117             : 
     118             :     bool
     119             :     ParseCommandLineArguments(const std::vector<std::string> &args) override;
     120             : 
     121             :     std::string GetUsageForCLI(bool shortUsage,
     122             :                                const UsageOptions &usageOptions) const override;
     123             : 
     124             :     static void RegisterAlgorithms(GDALAlgorithmRegistry &registry,
     125             :                                    bool forMixedPipeline);
     126             : };
     127             : 
     128             : //! @endcond
     129             : 
     130             : #endif

Generated by: LCOV version 1.14