Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: "as-features" step of "gdal pipeline" 5 : * Author: Daniel Baston 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2025, ISciences, LLC 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #ifndef GDALALG_RASTER_AS_FEATURES_INCLUDED 14 : #define GDALALG_RASTER_AS_FEATURES_INCLUDED 15 : 16 : #include "gdalalg_abstract_pipeline.h" 17 : 18 : //! @cond Doxygen_Suppress 19 : 20 : /************************************************************************/ 21 : /* GDALRasterAsFeaturesAlgorithm */ 22 : /************************************************************************/ 23 : 24 18 : class GDALRasterAsFeaturesAlgorithm /* non final */ 25 : : public GDALPipelineStepAlgorithm 26 : { 27 : public: 28 : static constexpr const char *NAME = "as-features"; 29 : static constexpr const char *DESCRIPTION = 30 : "Create features from pixels of a raster dataset"; 31 : static constexpr const char *HELP_URL = 32 : "/programs/gdal_raster_as_features.html"; 33 : 34 : explicit GDALRasterAsFeaturesAlgorithm(bool standaloneStep = false); 35 : 36 : ~GDALRasterAsFeaturesAlgorithm() override; 37 : 38 14 : int GetInputType() const override 39 : { 40 14 : return GDAL_OF_RASTER; 41 : } 42 : 43 14 : int GetOutputType() const override 44 : { 45 14 : return GDAL_OF_VECTOR; 46 : } 47 : 48 : private: 49 : bool RunStep(GDALPipelineStepRunContext &ctxt) override; 50 : 51 : std::vector<int> m_bands{}; 52 : std::string m_geomTypeName = "none"; 53 : bool m_skipNoData = false; 54 : bool m_includeXY = false; 55 : bool m_includeRowCol = false; 56 : }; 57 : 58 : /************************************************************************/ 59 : /* GDALRasterAsFeaturesAlgorithmStandalone */ 60 : /************************************************************************/ 61 : 62 36 : class GDALRasterAsFeaturesAlgorithmStandalone final 63 : : public GDALRasterAsFeaturesAlgorithm 64 : { 65 : public: 66 18 : GDALRasterAsFeaturesAlgorithmStandalone() 67 18 : : GDALRasterAsFeaturesAlgorithm(/* standaloneStep = */ true) 68 : { 69 18 : } 70 : 71 : ~GDALRasterAsFeaturesAlgorithmStandalone() override; 72 : }; 73 : 74 : //! @endcond 75 : 76 : #endif