Skip to content

Commit

Permalink
Always emit a spatialReferenceChanged when processing starts (#2060)
Browse files Browse the repository at this point in the history
* Make sure we emit a single spatialReferenceChanged() when processing
points with no SRS.

* Fix overlay filter to deal with SRS change to empty SRS.
Add more info to failed pipeline test message.
  • Loading branch information
abellgithub committed Jun 26, 2018
1 parent 9eafd35 commit 76bdabd
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
2 changes: 2 additions & 0 deletions filters/OverlayFilter.cpp
Expand Up @@ -157,6 +157,8 @@ void OverlayFilter::ready(PointTableRef table)

void OverlayFilter::spatialReferenceChanged(const SpatialReference& srs)
{
if (srs.empty())
return;
for (auto& poly : m_polygons)
{
try
Expand Down
3 changes: 2 additions & 1 deletion pdal/Streamable.cpp
Expand Up @@ -211,7 +211,8 @@ void Streamable::execute(StreamPointTable& table,
// processed by subsequent filters.
for (Streamable *s : filters)
{
if (srsMap[s] != srs)
auto si = srsMap.find(s);
if (si == srsMap.end() || si->second != srs)
{
s->spatialReferenceChanged(srs);
srsMap[s] = srs;
Expand Down
44 changes: 44 additions & 0 deletions test/unit/StreamingTest.cpp
Expand Up @@ -155,3 +155,47 @@ TEST(Streaming, issue_2009)

EXPECT_EQ(t.m_srsCnt, 1);
}

// Test that an SRS change is emitted at the start even if there is no SRS
// in the source.
TEST(Streaming, issue_2038)
{
StageFactory f;

Stage& r1 = *(f.createStage("readers.text"));
Options r1Opts;
r1Opts.add("filename", Support::datapath("text/utm17_1.txt"));
r1.setOptions(r1Opts);

class TestFilter : public Filter, public Streamable
{
public:
TestFilter() : m_srsCnt(0)
{}

std::string getName() const { return "filters.test"; }

int m_srsCnt;

private:
virtual void spatialReferenceChanged(const SpatialReference&)
{
m_srsCnt++;
}

virtual bool processOne(PointRef&)
{
EXPECT_EQ(m_srsCnt, 1);
return true;
}
};

TestFilter t;
t.setInput(r1);

FixedPointTable table(100);
t.prepare(table);
t.execute(table);

EXPECT_EQ(t.m_srsCnt, 1);
}
3 changes: 2 additions & 1 deletion test/unit/apps/pcpipelineTestJSON.cpp
Expand Up @@ -65,7 +65,8 @@ void run_pipeline(std::string const& pipelineFile,
std::string file(Support::configuredpath(pipelineFile));
int stat = pdal::Utils::run_shell_command(cmd + " " + file + " " +
options + " 2>&1", output);
EXPECT_EQ(0, stat);
EXPECT_EQ(0, stat) << "Failure running '" << pipelineFile << "' with "
"options '" << options << "'.";
if (stat)
std::cerr << output << std::endl;
if (lookFor.size())
Expand Down

0 comments on commit 76bdabd

Please sign in to comment.