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 "gdalalg_abstract_pipeline.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 1 : bool IsNativelyStreamingCompatible() const override 40 : { 41 1 : return false; 42 : } 43 : 44 : private: 45 : bool RunStep(GDALPipelineStepRunContext &ctxt) override; 46 : bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override; 47 : 48 1 : int GetInputType() const override 49 : { 50 1 : return GDAL_OF_VECTOR; 51 : } 52 : 53 1 : int GetOutputType() const override 54 : { 55 1 : 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 : std::string m_srs{}; 72 : std::vector<std::string> m_transformerOption{}; 73 : std::vector<double> m_targetExtent{}; 74 : std::vector<double> 75 : m_targetResolution{}; // Mutually exclusive with targetSize 76 : bool m_tap = false; 77 : std::vector<int> 78 : m_targetSize{}; // Mutually exclusive with targetResolution 79 : std::string m_outputType{}; 80 : std::string m_optimization{}; // {AUTO|VECTOR|RASTER} 81 : }; 82 : 83 : /************************************************************************/ 84 : /* GDALVectorRasterizeAlgorithmStandalone */ 85 : /************************************************************************/ 86 : 87 68 : class GDALVectorRasterizeAlgorithmStandalone final 88 : : public GDALVectorRasterizeAlgorithm 89 : { 90 : public: 91 34 : GDALVectorRasterizeAlgorithmStandalone() 92 34 : : GDALVectorRasterizeAlgorithm(/* standaloneStep = */ true) 93 : { 94 34 : } 95 : 96 : ~GDALVectorRasterizeAlgorithmStandalone() override; 97 : }; 98 : 99 : //! @endcond 100 : 101 : #endif