1+ """
2+ This module provides a python-syntax interface for constructing and executing pdal-python json
3+ pipelines. The API is not explicitly defined but stage names are validated against the pdal executable's drivers when possible.
4+
5+ To construct pipeline stages, access the driver name from this module. This will create
6+ a callable function where driver parameters can be specified as keyword arguments. For example:
7+
8+ >>> from pdal import pio
9+ >>> las_reader = pio.readers.las(filename="test.las")
10+
11+ To construct a pipeline, sum stages together.
12+
13+ >>> pipeline = pio.readers.las(filename="test.las") + pio.writers.ply(filename="test.ply")
14+
15+ To execute a pipeline and return results, call `execute`.
16+
17+ >>> arr = pipeline.execute() # returns a numpy structured array
18+
19+ To access the pipelines as a dict (which may be dumped to json), call `spec`.
20+
21+ >>> json.dumps(pipeline.spec)
22+
23+ """
24+
125import types
226import json
327import subprocess
@@ -36,6 +60,10 @@ def __init__(self, prefix, **kwargs):
3660
3761 @property
3862 def pipeline (self ):
63+ """
64+ Promote this stage to a `pdal.pio.PipelineSpec` with one `pdal.pio.StageSpec`
65+ and return it.
66+ """
3967 output = PipelineSpec ()
4068 output .add_stage (self )
4169 return output
@@ -73,11 +101,17 @@ def __init__(self, other=None):
73101
74102 @property
75103 def spec (self ):
104+ """
105+ Return a `dict` containing the pdal pipeline suitable for dumping to json
106+ """
76107 return {
77108 "pipeline" : [stage .spec for stage in self .stages ]
78109 }
79110
80111 def add_stage (self , stage ):
112+ """
113+ Add a StageSpec to the end of this pipeline, and return the updated result.
114+ """
81115 assert isinstance (stage , StageSpec ), "Expected StageSpec"
82116
83117 self .stages .append (stage )
@@ -98,6 +132,9 @@ def __add__(self, stage_or_pipeline):
98132 return output
99133
100134 def execute (self ):
135+ """
136+ Shortcut to execute and return the results of the pipeline.
137+ """
101138 # TODO: do some validation before calling execute
102139
103140 # TODO: some exception/error handling around pdal
0 commit comments