pdal::Stage

pdal::Stage is the base class of pdal::Filter, pdal::Reader, and pdal::MultiFilter classes that implement the reading API in a PDAL pipeline.

class pdal::Stage

A stage performs the actual processing in PDAL.

Stages may read data, modify or filter read data, create metadata or write processed data.

Stages are linked with setInput() into a pipeline. The pipeline is run with by calling in sequence prepare() and execute() on the stage at the end of the pipeline. PipelineManager can also be used to create and run a pipeline.

Subclassed by pdal::Filter, pdal::Reader, pdal::Streamable, pdal::Writer

Public Types

enum WhereMergeMode

Values:

enumerator Auto
enumerator True
enumerator False

Public Functions

Stage()
virtual ~Stage()
inline void setInput(Stage &input)

Add a stage to the input list of this stage.

Parameters

inputStage to use as input.

inline void setProgressFd(int fd)

Set a file descriptor to which progress information should be written.

Parameters

fd – Progress file descriptor.

QuickInfo preview()

Retrieve some basic point information without reading all data when possible.

Usually implemented only by Readers.

void prepare(PointTableRef table)

Prepare a stage for execution.

This function needs to be called on the terminal stage of a pipeline (linked set of stages) before execute can be called. Prepare recurses through all input stages.

Parameters

table – PointTable being used for stage pipeline.

PointViewSet execute(PointTableRef table)

Execute a prepared pipeline (linked set of stages).

This performs the action associated with the stage by executing the run function of each stage in depth first order. Each stage is run to completion (all points are processed) before the next stages is run.o

Parameters

table – Point table being used for stage pipeline. This must be the same table used in the prepare function.

inline virtual void execute(StreamPointTable &table)
inline virtual bool pipelineStreamable() const

Determine if a pipeline with this stage as a sink is streamable.

Returns

Whether the pipeline is streamable.

inline virtual const Stage *findNonstreamable() const

Return a pointer to a pipeline’s first non-streamable stage, if one exists.

Returns

nullptr if the stage is streamable, a pointer to this stage otherwise.

void setSpatialReference(SpatialReference const &srs)

Set the spatial reference of a stage.

Set the spatial reference that will override that being carried by the PointView being processed. This is usually used when reprojecting data to a new spatial reference. The stage spatial reference will be carried by PointViews processes by this stage to subsequent stages.

If called by a Reader whose spatial reference has been set with option ‘spatialreference’ or ‘override_srs’, then this function will have no effect.

Parameters

srs – Spatial reference to set.

const SpatialReference &getSpatialReference() const

Get the spatial reference of the stage.

Get the spatial reference that will override that being carried by the PointView being processed. This is usually used when reprojecting data to a new spatial reference. The stage spatial reference will be carried by PointViews processes by this stage to subsequent stages.

Returns

The stage’s spatial reference.

inline void setOptions(Options options)

Set a stage’s options.

Set the options on a stage, clearing all previously set options.

Parameters

optionsOptions to set.

void addConditionalOptions(const Options &opts)

Add options if an option with the same name doesn’t already exist on the stage.

Parameters

optsOptions to add.

void addAllArgs(ProgramArgs &args)

Add a stage’s options to a ProgramArgs set.

Parameters

argsProgramArgs to add to.

inline void addOptions(const Options &opts)

Add options to the existing option set.

Parameters

optsOptions to add.

inline void removeOptions(const Options &opts)

Remove options from a stage’s option set.

Parameters

optsOptions to remove.

inline void setLog(const LogPtr &log)

Set the stage’s log.

Parameters

logLog pointer.

inline virtual LogPtr log() const

Return the stage’s log pointer.

Returns

Log pointer.

void startLogging() const

Push the stage’s leader into the log.

void stopLogging() const

Pop the stage’s leader from the log.

inline bool isDebug() const

Determine whether the stage is in debug mode or not.

Returns

The stage’s debug state.

virtual std::string getName() const = 0

Return the name of a stage.

Returns

The stage’s name.

inline void setTag(const std::string &tag)

Set a specific tag name.

inline virtual std::string tag() const

Return the tag name of a stage.

Returns

The tag name.

inline std::vector<Stage*> &getInputs()

Return a list of the stage’s inputs.

Returns

A vector pointers to input stages.

inline MetadataNode getMetadata() const

Get the stage’s metadata node.

Returns

Stage’s metadata.

void serialize(MetadataNode root, PipelineWriter::TagMap &tags) const

Serialize a stage by inserting apporpritate data into the provided MetadataNode.

Used to dump a pipeline specification in a portable format.

Parameters
  • root – Node to which a stages metadata should be added.

  • tags – Pipeline writer’s current list of stage tags.

Public Static Functions

static bool parseName(std::string o, std::string::size_type &pos)

Parse a stage name from a string.

Return the name and update the position in the input string to the end of the stage name.

Parameters
  • o – Input string to parse.

  • pos – Parsing start/end position.

Returns

Whether the parsed name is a valid stage name.

static bool parseTagName(std::string o, std::string::size_type &pos)

Parse a tag name from a string.

Return the name and update the position in the input string to the end of the tag name.

Parameters
  • o – Input string to parse.

  • pos – Parsing start/end position.

  • tag – Parsed tag name.

Returns

Whether the parsed name is a valid tag name.