Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: gdal "raster contour" 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_RASTER_CONTOUR_INCLUDED 14 : #define GDALALG_RASTER_CONTOUR_INCLUDED 15 : 16 : #include <limits> 17 : 18 : #include "gdalalgorithm.h" 19 : 20 : //! @cond Doxygen_Suppress 21 : 22 : /************************************************************************/ 23 : /* GDALRasterContourAlgorithm */ 24 : /************************************************************************/ 25 : 26 : class GDALRasterContourAlgorithm final : public GDALAlgorithm 27 : { 28 : public: 29 : static constexpr const char *NAME = "contour"; 30 : static constexpr const char *DESCRIPTION = 31 : "Creates a vector contour from a raster elevation model (DEM)."; 32 : static constexpr const char *HELP_URL = 33 : "/programs/gdal_raster_contour.html"; 34 : 35 305 : static std::vector<std::string> GetAliases() 36 : { 37 305 : return {}; 38 : } 39 : 40 : explicit GDALRasterContourAlgorithm(); 41 : 42 : GDALDataset *GetDatasetRef() 43 : { 44 : return m_inputDataset.GetDatasetRef(); 45 : } 46 : 47 : void SetDataset(GDALDataset *poDS) 48 : { 49 : auto arg = GetArg(GDAL_ARG_NAME_INPUT); 50 : arg->Set(poDS); 51 : arg->SetSkipIfAlreadySet(); 52 : } 53 : 54 : private: 55 : bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override; 56 : 57 : std::string m_outputFormat{}; 58 : GDALArgDatasetValue m_inputDataset{}; 59 : std::vector<std::string> m_openOptions{}; 60 : std::vector<std::string> m_inputFormats{}; 61 : GDALArgDatasetValue m_outputDataset{}; 62 : std::vector<std::string> m_creationOptions{}; 63 : 64 : // gdal_contour specific arguments 65 : int m_band = 1; // -b 66 : std::string m_outputLayerName; // -nln <name> 67 : std::string m_elevAttributeName; // -a <name> 68 : std::string m_amin; // -amin <value> 69 : std::string m_amax; // -amax <value> 70 : bool m_3d = false; // -3d 71 : // -inodata (skipped) 72 : double m_sNodata = 73 : std::numeric_limits<double>::quiet_NaN(); // -snodata <value> 74 : double m_interval = 75 : std::numeric_limits<double>::quiet_NaN(); // -i <interval> 76 : double m_offset = 77 : std::numeric_limits<double>::quiet_NaN(); // -off <offset> 78 : std::vector<std::string> 79 : m_levels; // -fl <level>[,<level>...] MIN/MAX are also supported 80 : int m_expBase = 0; // -e <base> 81 : bool m_polygonize = false; // -p 82 : int m_groupTransactions = 0; // gt <n> 83 : bool m_overwrite = false; // -overwrite 84 : }; 85 : 86 : //! @endcond 87 : 88 : #endif