Skip to content

Commit

Permalink
Implement initial 'gdal raster pipeline' and 'gdal raster reproject'
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Dec 5, 2024
1 parent 93cbcce commit 736c7c2
Show file tree
Hide file tree
Showing 18 changed files with 1,912 additions and 48 deletions.
4 changes: 4 additions & 0 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ add_library(
gdalalg_raster.cpp
gdalalg_raster_info.cpp
gdalalg_raster_convert.cpp
gdalalg_raster_pipeline.cpp
gdalalg_raster_read.cpp
gdalalg_raster_reproject.cpp
gdalalg_raster_write.cpp
gdalalg_vector.cpp
gdalalg_vector_info.cpp
gdalalg_vector_convert.cpp
Expand Down
53 changes: 5 additions & 48 deletions apps/gdalalg_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,24 @@

#include "cpl_error.h"
#include "gdalalgorithm.h"
//#include "gdalalg_raster_pipeline.h"
#include "gdalalg_raster_pipeline.h"
#include "gdalalg_vector_pipeline.h"
#include "gdalalg_dispatcher.h"
#include "gdal_priv.h"

/************************************************************************/
/* GDALDummyRasterPipelineAlgorithm */
/************************************************************************/

class GDALDummyRasterPipelineAlgorithm final : public GDALAlgorithm
{
public:
static constexpr const char *NAME = "pipeline";
static constexpr const char *DESCRIPTION = "Dummy raster pipeline.";
static constexpr const char *HELP_URL = "";

static std::vector<std::string> GetAliases()
{
return {};
}

explicit GDALDummyRasterPipelineAlgorithm(bool = false)
: GDALAlgorithm(NAME, DESCRIPTION, HELP_URL)
{
}

bool ParseCommandLineArguments(const std::vector<std::string> &) override
{
return false;
}

/* cppcheck-suppress functionStatic */
GDALDataset *GetDatasetRef()
{
return nullptr;
}

/* cppcheck-suppress functionStatic */
void SetDataset(GDALDataset *)
{
}

private:
bool RunImpl(GDALProgressFunc, void *) override
{
return false;
}
};

/************************************************************************/
/* GDALPipelineAlgorithm */
/************************************************************************/

class GDALPipelineAlgorithm final
: public GDALDispatcherAlgorithm<GDALDummyRasterPipelineAlgorithm,
: public GDALDispatcherAlgorithm<GDALRasterPipelineAlgorithm,
GDALVectorPipelineAlgorithm>
{
public:
static constexpr const char *NAME = "pipeline";
static constexpr const char *DESCRIPTION =
"Execute a pipeline (shortcut for 'gdal vector pipeline').";
"Execute a pipeline (shortcut for 'gdal raster pipeline' or 'gdal "
"vector pipeline').";
static constexpr const char *HELP_URL = ""; // TODO

static std::vector<std::string> GetAliases()
Expand All @@ -94,7 +51,7 @@ class GDALPipelineAlgorithm final
}

private:
std::unique_ptr<GDALDummyRasterPipelineAlgorithm> m_rasterPipeline{};
std::unique_ptr<GDALRasterPipelineAlgorithm> m_rasterPipeline{};
std::unique_ptr<GDALVectorPipelineAlgorithm> m_vectorPipeline{};

std::string m_format{};
Expand Down
4 changes: 4 additions & 0 deletions apps/gdalalg_raster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "gdalalg_raster_info.h"
#include "gdalalg_raster_convert.h"
#include "gdalalg_raster_pipeline.h"
#include "gdalalg_raster_reproject.h"

/************************************************************************/
/* GDALRasterAlgorithm */
Expand All @@ -35,6 +37,8 @@ class GDALRasterAlgorithm final : public GDALAlgorithm
{
RegisterSubAlgorithm<GDALRasterInfoAlgorithm>();
RegisterSubAlgorithm<GDALRasterConvertAlgorithm>();
RegisterSubAlgorithm<GDALRasterPipelineAlgorithm>();
RegisterSubAlgorithm<GDALRasterReprojectAlgorithmStandalone>();
}

private:
Expand Down
Loading

0 comments on commit 736c7c2

Please sign in to comment.