Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: "reproject" step of "raster pipeline" 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_REPROJECT_INCLUDED 14 : #define GDALALG_RASTER_REPROJECT_INCLUDED 15 : 16 : #include "gdalalg_raster_pipeline.h" 17 : 18 : #include <limits> 19 : 20 : //! @cond Doxygen_Suppress 21 : 22 : /************************************************************************/ 23 : /* GDALRasterReprojectAlgorithm */ 24 : /************************************************************************/ 25 : 26 : class GDALRasterReprojectAlgorithm /* non final */ 27 : : public GDALRasterPipelineStepAlgorithm 28 : { 29 : public: 30 : static constexpr const char *NAME = "reproject"; 31 : static constexpr const char *DESCRIPTION = "Reproject a raster dataset."; 32 : static constexpr const char *HELP_URL = 33 : "/programs/gdal_raster_reproject.html"; 34 : 35 2226 : static std::vector<std::string> GetAliasesStatic() 36 : { 37 6678 : return {GDALAlgorithmRegistry::HIDDEN_ALIAS_SEPARATOR, "warp"}; 38 : } 39 : 40 : explicit GDALRasterReprojectAlgorithm(bool standaloneStep = false); 41 : 42 : bool CanHandleNextStep(GDALPipelineStepAlgorithm *) const override; 43 : 44 : private: 45 : bool RunStep(GDALPipelineStepRunContext &ctxt) override; 46 : 47 : std::string m_srsCrs{}; 48 : std::string m_dstCrs{}; 49 : std::string m_resampling{}; 50 : std::vector<double> m_resolution{}; 51 : std::vector<double> m_bbox{}; 52 : std::string m_bboxCrs{}; 53 : std::vector<int> m_size{}; 54 : bool m_targetAlignedPixels = false; 55 : std::vector<std::string> m_srcNoData{}; 56 : std::vector<std::string> m_dstNoData{}; 57 : bool m_addAlpha = false; 58 : std::vector<std::string> m_warpOptions{}; 59 : std::vector<std::string> m_transformOptions{}; 60 : double m_errorThreshold = std::numeric_limits<double>::quiet_NaN(); 61 : int m_numThreads = 0; 62 : GDALArgDatasetValue m_likeDataset{}; 63 : 64 : // Work variables 65 : std::string m_numThreadsStr{"ALL_CPUS"}; 66 : }; 67 : 68 : /************************************************************************/ 69 : /* GDALRasterReprojectAlgorithmStandalone */ 70 : /************************************************************************/ 71 : 72 78 : class GDALRasterReprojectAlgorithmStandalone final 73 : : public GDALRasterReprojectAlgorithm 74 : { 75 : public: 76 39 : GDALRasterReprojectAlgorithmStandalone() 77 39 : : GDALRasterReprojectAlgorithm(/* standaloneStep = */ true) 78 : { 79 39 : } 80 : 81 : ~GDALRasterReprojectAlgorithmStandalone() override; 82 : }; 83 : 84 : /************************************************************************/ 85 : /* GDALRasterReprojectUtils */ 86 : /************************************************************************/ 87 : 88 : class GDALRasterReprojectUtils final 89 : { 90 : public: 91 : static void AddResamplingArg(GDALAlgorithm *alg, std::string &resampling); 92 : 93 : static void AddWarpOptTransformOptErrorThresholdArg( 94 : GDALAlgorithm *alg, std::vector<std::string> &warpOptions, 95 : std::vector<std::string> &transformOptions, double &errorThreshold); 96 : }; 97 : 98 : //! @endcond 99 : 100 : #endif /* GDALALG_RASTER_REPROJECT_INCLUDED */