Skip to content

Commit 86a33ea

Browse files
committed
Append a merge filter to pipelines that consist of readers only
1 parent 150affe commit 86a33ea

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

pdal/pipeline.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ def get_meshio(self, idx: int) -> Optional[Mesh]:
102102
def _get_json(self) -> str:
103103
options_list = []
104104
stage2tag: Dict[Stage, str] = {}
105-
for stage in self._stages:
105+
stages = self._stages
106+
if all(isinstance(stage, Reader) for stage in stages):
107+
stages = [*stages, Filter.merge()]
108+
for stage in stages:
106109
stage2tag[stage] = stage.tag or _generate_tag(stage, stage2tag.values())
107110
options = stage.options
108111
options["tag"] = stage2tag[stage]

test/test_pipeline.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,20 @@ def test_logging(self, filename):
249249
assert "\nexiting filter()\n" in r.log
250250
assert "(pypipeline writers.las Debug)" in r.log
251251

252+
def test_only_readers(self):
253+
"""Does a pipeline that consists of only readers return the merged data"""
254+
read = pdal.Reader("test/data/*.las")
255+
r1 = read.pipeline()
256+
count1 = r1.execute()
257+
array1 = r1.arrays[0]
258+
259+
r2 = read | read
260+
count2 = r2.execute()
261+
array2 = r2.arrays[0]
262+
263+
assert count2 == 2 * count1
264+
np.testing.assert_array_equal(np.concatenate([array1, array1]), array2)
265+
252266

253267
class TestArrayLoad:
254268
def test_merged_arrays(self):

0 commit comments

Comments
 (0)