Skip to content

Commit edc838e

Browse files
committed
gdal pipeline: avoid error/creating file named '[ ... ]' when an inner read pipeline is a VRT
Fixes #14732
1 parent b6e8a94 commit edc838e

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

apps/gdalalg_abstract_pipeline.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "gdalalg_vector_read.h"
2323
#include "gdalalg_tee.h"
2424

25+
#include "vrtdataset.h"
26+
2527
#include <algorithm>
2628
#include <cassert>
2729

@@ -1567,6 +1569,9 @@ std::string GDALAbstractPipelineAlgorithm::BuildNestedPipeline(
15671569
curAlg->m_oMapDatasetNameToDataset[datasetNameOut] = poDS;
15681570

15691571
poDS->SetDescription(argsStr.c_str());
1572+
auto poVRTDataset = dynamic_cast<VRTDataset *>(poDS);
1573+
if (poVRTDataset)
1574+
poVRTDataset->SetWritable(false);
15701575
}
15711576

15721577
m_apoNestedPipelines.emplace_back(std::move(nestedPipeline));

autotest/utilities/test_gdalalg_pipeline.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,18 @@ def test_gdalalg_pipeline_nested_nominal():
835835
]
836836

837837

838+
def test_gdalalg_pipeline_inner_pipeline_vrt(tmp_path):
839+
"""Test bugfix for https://github.com/OSGeo/gdal/issues/14732"""
840+
841+
shutil.copy("data/color_file.txt", tmp_path)
842+
843+
with gdal.alg.pipeline(
844+
pipeline=f"read ../gcore/data/byte.tif ! blend --overlay [ read ../gcore/data/byte.tif ! color-map --color-map {tmp_path}/color_file.txt ]"
845+
) as alg:
846+
ds = alg.Output()
847+
assert ds.GetRasterBand(1).Checksum() == 4475
848+
849+
838850
def test_gdalalg_pipeline_nested_serialize_to_gdalg(tmp_vsimem):
839851

840852
out_filename = tmp_vsimem / "out.gdalg.json"

0 commit comments

Comments
 (0)