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 "gdalalgorithm.h" 20 : 21 : //! @cond Doxygen_Suppress 22 : 23 : /************************************************************************/ 24 : /* GDALVectorRasterizeAlgorithm */ 25 : /************************************************************************/ 26 : 27 : class GDALVectorRasterizeAlgorithm final : public GDALAlgorithm 28 : { 29 : public: 30 : static constexpr const char *NAME = "rasterize"; 31 : static constexpr const char *DESCRIPTION = 32 : "Burns vector geometries into a raster."; 33 : static constexpr const char *HELP_URL = 34 : "/programs/gdal_vector_rasterize.html"; 35 : 36 242 : static std::vector<std::string> GetAliases() 37 : { 38 242 : return {}; 39 : } 40 : 41 : GDALVectorRasterizeAlgorithm(); 42 : 43 : void SetDataset(GDALDataset *poDS) 44 : { 45 : auto arg = GetArg(GDAL_ARG_NAME_INPUT); 46 : if (arg) 47 : { 48 : arg->Set(poDS); 49 : arg->SetSkipIfAlreadySet(); 50 : } 51 : } 52 : 53 : private: 54 : bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override; 55 : 56 : std::vector<int> m_bands{}; 57 : bool m_invert = false; 58 : bool m_allTouched = false; 59 : std::vector<double> m_burnValues{}; 60 : std::string m_attributeName{}; 61 : bool m_3d = false; 62 : bool m_add = false; 63 : std::string m_layerName{}; // mutually exclusive with m_sql 64 : std::string m_where{}; 65 : std::string m_sql{}; // mutually exclusive with m_layerName 66 : std::string m_dialect{}; 67 : std::vector<std::string> m_inputFormats{}; 68 : std::string m_outputFormat{}; 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<std::string> m_datasetCreationOptions{}; 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 : std::vector<std::string> m_openOptions{}; 83 : GDALArgDatasetValue m_inputDataset{}; 84 : GDALArgDatasetValue m_outputDataset{}; 85 : bool m_update{false}; 86 : bool m_overwrite{false}; 87 : }; 88 : 89 : //! @endcond 90 : 91 : #endif