Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: gdal "vector rasterize" subcommand 5 : * Author: Alessandro Pasotti <elpaso at itopen dot it> 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2025, Alessandro Pasotti <elpaso at itopen dot it> 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #ifndef GDALALG_VECTOR_RASTERIZE_INCLUDED 14 : #define GDALALG_VECTOR_RASTERIZE_INCLUDED 15 : 16 : #include <algorithm> 17 : #include <limits> 18 : 19 : #include "gdalpipelinestepalgorithm.h" 20 : 21 : //! @cond Doxygen_Suppress 22 : 23 : /************************************************************************/ 24 : /* GDALVectorRasterizeAlgorithm */ 25 : /************************************************************************/ 26 : 27 : class GDALVectorRasterizeAlgorithm /* non final */ 28 : : public GDALPipelineStepAlgorithm 29 : { 30 : public: 31 : static constexpr const char *NAME = "rasterize"; 32 : static constexpr const char *DESCRIPTION = 33 : "Burns vector geometries into a raster."; 34 : static constexpr const char *HELP_URL = 35 : "/programs/gdal_vector_rasterize.html"; 36 : 37 : explicit GDALVectorRasterizeAlgorithm(bool standaloneStep = false); 38 : 39 4 : bool IsNativelyStreamingCompatible() const override 40 : { 41 4 : return false; 42 : } 43 : 44 : private: 45 : bool RunStep(GDALPipelineStepRunContext &ctxt) override; 46 : bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override; 47 : 48 6 : int GetInputType() const override 49 : { 50 6 : return GDAL_OF_VECTOR; 51 : } 52 : 53 5 : int GetOutputType() const override 54 : { 55 5 : return GDAL_OF_RASTER; 56 : } 57 : 58 : std::vector<int> m_bands{}; 59 : bool m_invert = false; 60 : bool m_allTouched = false; 61 : std::vector<double> m_burnValues{}; 62 : std::string m_attributeName{}; 63 : bool m_3d = false; 64 : bool m_add = false; 65 : std::string m_layerName{}; // mutually exclusive with m_sql 66 : std::string m_where{}; 67 : std::string m_sql{}; // mutually exclusive with m_layerName 68 : std::string m_dialect{}; 69 : double m_nodata = std::numeric_limits<double>::quiet_NaN(); 70 : std::vector<double> m_initValues{}; 71 : GDALArgDatasetValue m_likeDataset{}; 72 : std::string m_srs{}; 73 : std::vector<std::string> m_transformerOption{}; 74 : std::vector<double> m_targetExtent{}; 75 : std::vector<double> 76 : m_targetResolution{}; // Mutually exclusive with targetSize 77 : bool m_tap = false; 78 : std::vector<int> 79 : m_targetSize{}; // Mutually exclusive with targetResolution 80 : std::string m_outputType{}; 81 : std::string m_optimization{}; // {AUTO|VECTOR|RASTER} 82 : }; 83 : 84 : /************************************************************************/ 85 : /* GDALVectorRasterizeAlgorithmStandalone */ 86 : /************************************************************************/ 87 : 88 208 : class GDALVectorRasterizeAlgorithmStandalone final 89 : : public GDALVectorRasterizeAlgorithm 90 : { 91 : public: 92 104 : GDALVectorRasterizeAlgorithmStandalone() 93 104 : : GDALVectorRasterizeAlgorithm(/* standaloneStep = */ true) 94 : { 95 104 : } 96 : 97 : ~GDALVectorRasterizeAlgorithmStandalone() override; 98 : }; 99 : 100 : //! @endcond 101 : 102 : #endif