Skip to content

Commit

Permalink
Make sure when we run a pipeline without a reader.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Oct 20, 2020
1 parent 502b5fe commit d1c05a5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernels/PipelineKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ int PipelineKernel::execute()
try
{
m_manager.readPipeline(m_inputFile);
if (!m_manager.hasReader())
throw pdal_error("Pipeline does not start with a reader.");
m_manager.prepare();
root["valid"] = true;
root["error_detail"] = "";
Expand All @@ -144,6 +146,8 @@ int PipelineKernel::execute()
}

m_manager.readPipeline(m_inputFile);
if (!m_manager.hasReader())
throw pdal_error("Pipeline does not start with a reader.");
if (m_manager.execute(m_mode).m_mode == ExecMode::None)
throw pdal_error("Couldn't run pipeline in requested execution mode.");

Expand Down
7 changes: 7 additions & 0 deletions pdal/PipelineManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
****************************************************************************/

#include <pdal/PipelineManager.hpp>
#include <pdal/Reader.hpp>
#include <pdal/StageFactory.hpp>
#include <pdal/PipelineReaderJSON.hpp>
#include <pdal/PDALUtils.hpp>
Expand Down Expand Up @@ -187,6 +188,12 @@ bool PipelineManager::pipelineStreamable() const
}


bool PipelineManager::hasReader() const
{
return (dynamic_cast<Reader *>(m_stages.front()));
}


QuickInfo PipelineManager::preview() const
{
QuickInfo qi;
Expand Down
1 change: 1 addition & 0 deletions pdal/PipelineManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class PDAL_DLL PipelineManager
void executeStream(StreamPointTable& table);
void validateStageOptions() const;
bool pipelineStreamable() const;
bool hasReader() const;

// Get the resulting point views.
const PointViewSet& views() const
Expand Down
8 changes: 8 additions & 0 deletions test/unit/apps/pcpipelineTestJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,12 @@ TEST(json, issue_2438)
EXPECT_TRUE(FileUtils::fileExists(file2));
}

//
// Make sure that we throw an error if we use pipeline without a reader.
//
TEST(json, issue_3233)
{
run_bad_pipeline("pipeline/filter-only.json", "", "start with a reader");
}

} // namespace pdal

0 comments on commit d1c05a5

Please sign in to comment.