Skip to content

Commit

Permalink
Report actual non-streamable stage in error. (#2189)
Browse files Browse the repository at this point in the history
* Report actual non-streamable stage in error.
Close #2186

* Rename function.
  • Loading branch information
abellgithub authored and hobu committed Oct 2, 2018
1 parent 69b73a0 commit ca7b236
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
10 changes: 10 additions & 0 deletions pdal/Stage.hpp
Expand Up @@ -137,6 +137,16 @@ class PDAL_DLL Stage
virtual bool pipelineStreamable() const
{ return false; }

/**
Return a pointer to a pipeline's first non-streamable stage,
if one exists.
\return nullptr if the stage is streamable, a pointer to this stage
otherwise.
*/
virtual const Stage *findNonstreamable() const
{ return this; }

/**
Set the spatial reference of a stage.
Expand Down
21 changes: 18 additions & 3 deletions pdal/Streamable.cpp
Expand Up @@ -53,6 +53,20 @@ bool Streamable::pipelineStreamable() const
}


const Stage *Streamable::findNonstreamable() const
{
const Stage *nonstreamable;

for (const Stage *s : m_inputs)
{
nonstreamable = s->findNonstreamable();
if (nonstreamable)
return nonstreamable;
}
return nullptr;
}


// Streamed execution.
void Streamable::execute(StreamPointTable& table)
{
Expand Down Expand Up @@ -100,9 +114,10 @@ void Streamable::execute(StreamPointTable& table)
}
};

if (!pipelineStreamable())
throwError("Attempting to use stream mode with a stage that doesn't "
"support streaming.");
const Stage *nonstreaming = findNonstreamable();
if (nonstreaming)
nonstreaming->throwError("Attempting to use stream mode with a "
"stage that doesn't support streaming.");

SpatialReference srs;
std::list<StreamableList> lists;
Expand Down
8 changes: 8 additions & 0 deletions pdal/Streamable.hpp
Expand Up @@ -107,6 +107,14 @@ class PDAL_DLL Streamable : public virtual Stage
*/
virtual void spatialReferenceChanged(const SpatialReference& /*srs*/)
{}

/**
Find the first nonstreamable stage in a pipeline.
\return NULL if the pipeline is streamable, otherwise return
a pointer to the first found stage that's not streamable.
*/
const Stage *findNonstreamable() const;
};

} // namespace pdal

0 comments on commit ca7b236

Please sign in to comment.