Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: gdal "raster sieve" 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_SIEVE_INCLUDED 14 : #define GDALALG_RASTER_SIEVE_INCLUDED 15 : 16 : #include "gdalalg_raster_pipeline.h" 17 : 18 : //! @cond Doxygen_Suppress 19 : 20 : /************************************************************************/ 21 : /* GDALRasterSieveAlgorithm */ 22 : /************************************************************************/ 23 : 24 : class GDALRasterSieveAlgorithm /* non final */ 25 : : public GDALRasterPipelineNonNativelyStreamingAlgorithm 26 : { 27 : public: 28 : static constexpr const char *NAME = "sieve"; 29 : static constexpr const char *DESCRIPTION = 30 : "Remove small polygons from a raster dataset."; 31 : static constexpr const char *HELP_URL = "/programs/gdal_raster_sieve.html"; 32 : 33 : explicit GDALRasterSieveAlgorithm(bool standaloneStep = false); 34 : 35 : private: 36 : bool RunStep(GDALProgressFunc pfnProgress, void *pProgressData) override; 37 : 38 : int m_band = 1; 39 : int m_sizeThreshold = 2; 40 : bool m_connectDiagonalPixels = false; 41 : GDALArgDatasetValue m_maskDataset{}; 42 : }; 43 : 44 : /************************************************************************/ 45 : /* GDALRasterSieveAlgorithmStandalone */ 46 : /************************************************************************/ 47 : 48 : class GDALRasterSieveAlgorithmStandalone final : public GDALRasterSieveAlgorithm 49 : { 50 : public: 51 12 : GDALRasterSieveAlgorithmStandalone() 52 12 : : GDALRasterSieveAlgorithm(/* standaloneStep = */ true) 53 : { 54 12 : } 55 : }; 56 : 57 : //! @endcond 58 : 59 : #endif