GDAL
gdalalg_raster_pixel_info.h
1/******************************************************************************
2 *
3 * Project: GDAL
4 * Purpose: gdal "raster pixelinfo" subcommand
5 * Author: Even Rouault <even dot rouault at spatialys.com>
6 *
7 ******************************************************************************
8 * Copyright (c) 2025, Even Rouault <even dot rouault at spatialys.com>
9 *
10 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13#ifndef GDALALG_RASTER_PIXEL_INFO_INCLUDED
14#define GDALALG_RASTER_PIXEL_INFO_INCLUDED
15
16#include "gdalalg_abstract_pipeline.h"
17
18#include "cpl_vsi_virtual.h"
19
21
22/************************************************************************/
23/* GDALRasterPixelInfoAlgorithm */
24/************************************************************************/
25
26class GDALRasterPixelInfoAlgorithm /* non final */
27 : public GDALPipelineStepAlgorithm
28{
29 public:
30 static constexpr const char *NAME = "pixel-info";
31 static constexpr const char *DESCRIPTION =
32 "Return information on a pixel of a raster dataset.";
33 static constexpr const char *HELP_URL =
34 "/programs/gdal_raster_pixel_info.html";
35
36 explicit GDALRasterPixelInfoAlgorithm(bool standaloneStep = false);
37 ~GDALRasterPixelInfoAlgorithm() override;
38
39 bool IsNativelyStreamingCompatible() const override
40 {
41 // It could potentially be made fully streamable in pipeline mode since
42 // we read coordinates from an input vector dataset. "Just" needs some
43 // code reorganization.
44 return false;
45 }
46
47 int GetInputType() const override
48 {
49 return GDAL_OF_RASTER;
50 }
51
52 int GetOutputType() const override
53 {
54 return GDAL_OF_VECTOR;
55 }
56
57 private:
58 bool RunStep(GDALPipelineStepRunContext &ctxt) override;
59 bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override;
60
61 GDALArgDatasetValue m_vectorDataset{};
62 std::vector<std::string> m_includeFields{"ALL"};
63
64 std::vector<int> m_band{};
65 int m_overview = -1;
66 std::vector<double> m_pos{};
67 std::string m_posCrs{};
68 std::string m_resampling = "nearest";
69 bool m_promotePixelValueToZ = false;
70
71 VSIVirtualHandleUniquePtr m_outputFile{};
72 std::string m_osTmpFilename{};
73};
74
75/************************************************************************/
76/* GDALRasterPixelInfoAlgorithmStandalone */
77/************************************************************************/
78
79class GDALRasterPixelInfoAlgorithmStandalone final
80 : public GDALRasterPixelInfoAlgorithm
81{
82 public:
83 GDALRasterPixelInfoAlgorithmStandalone()
84 : GDALRasterPixelInfoAlgorithm(/* standaloneStep = */ true)
85 {
86 }
87
88 ~GDALRasterPixelInfoAlgorithmStandalone() override;
89};
90
92
93#endif
Value for an argument that points to a GDALDataset.
Definition gdalalgorithm_cpp.h:163
#define GDAL_OF_RASTER
Allow raster drivers to be used.
Definition gdal.h:1125
#define GDAL_OF_VECTOR
Allow vector drivers to be used.
Definition gdal.h:1130