Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into issue-2087
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Sep 13, 2018
2 parents aa3dc43 + 6e8bcd7 commit 87fcf53
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 12 deletions.
1 change: 0 additions & 1 deletion io/LasReader.cpp
Expand Up @@ -79,7 +79,6 @@ LasReader::~LasReader()

void LasReader::addArgs(ProgramArgs& args)
{
addSpatialReferenceArg(args);
args.add("extra_dims", "Dimensions to assign to extra byte data",
m_extraDimSpec);
args.add("compression", "Decompressor to use", m_compression, "EITHER");
Expand Down
1 change: 0 additions & 1 deletion io/TextReader.cpp
Expand Up @@ -156,7 +156,6 @@ void TextReader::initialize(PointTableRef table)

void TextReader::addArgs(ProgramArgs& args)
{
addSpatialReferenceArg(args);
m_separatorArg = &(args.add("separator", "Separator character that "
"overrides special character found in header line", m_separator, ' '));
args.add("header", "Use this string as the header line.", m_header);
Expand Down
1 change: 1 addition & 0 deletions pdal/Reader.cpp
Expand Up @@ -43,6 +43,7 @@ void Reader::readerAddArgs(ProgramArgs& args)
m_filenameArg = &args.add("filename", "Name of file to read", m_filename);
m_countArg = &args.add("count", "Maximum number of points read", m_count,
(std::numeric_limits<point_count_t>::max)());
addSpatialReferenceArg(args);
}

} // namespace pdal
1 change: 0 additions & 1 deletion plugins/oci/io/OciReader.cpp
Expand Up @@ -63,7 +63,6 @@ void OciReader::addArgs(ProgramArgs& args)
args.add("connection", "Connection string", m_connSpec);
args.add("populate_pointsourceid", "Set point source ID",
m_updatePointSourceId);
addSpatialReferenceArg(args);
}


Expand Down
8 changes: 2 additions & 6 deletions plugins/sqlite/io/SQLiteReader.cpp
Expand Up @@ -79,10 +79,8 @@ void SQLiteReader::initialize()
std::string(e.what()));
}

if (m_spatialRef.empty())
m_spatialRef = fetchSpatialReference(m_query);
setSpatialReference(m_spatialRef);

if (getSpatialReference().empty())
setSpatialReference(fetchSpatialReference(m_query));
m_patch = PatchPtr(new Patch());
}

Expand Down Expand Up @@ -123,8 +121,6 @@ SQLiteReader::fetchSpatialReference(std::string const& query) const

void SQLiteReader::addArgs(ProgramArgs& args)
{
args.add("spatialreference", "Spatial reference to apply to points if "
"one doesn't exist", m_spatialRef);
args.add("query", "SELECT statement that returns point cloud", m_query);
args.add("connection", "Database connection string", m_connection);
args.add("module", "Spatialite module name", m_modulename);
Expand Down
52 changes: 49 additions & 3 deletions test/unit/apps/pcpipelineTestJSON.cpp
Expand Up @@ -39,6 +39,7 @@
#include <pdal/util/FileUtils.hpp>
#include <pdal/util/Utils.hpp>
#include <io/LasReader.hpp>
#include <filters/StatsFilter.hpp>
#include "Support.hpp"

#include <iostream>
Expand Down Expand Up @@ -307,15 +308,15 @@ TEST(json, tags)
EXPECT_EQ(totalInputs, 3U);
}

TEST(json, issue1417)
TEST(json, issue_1417)
{
std::string options = "--readers.las.filename=" +
Support::datapath("las/utm15.las");
run_pipeline("pipeline/issue1417.json", options);
}

// Make sure we handle repeated options properly
TEST(json, issue1941)
TEST(json, issue_1941)
{
PipelineManager manager;
std::string file;
Expand All @@ -338,7 +339,6 @@ TEST(json, issue1941)
EXPECT_THROW(manager2.readPipeline(file), pdal_error);
}


// Test that stage options passed via --stage.<tagname>.<option> work.
TEST(json, stagetags)
{
Expand Down Expand Up @@ -415,4 +415,50 @@ TEST(json, stagetags)
EXPECT_NE(stat, 0);
}

// Make sure that spatialreference works for random readers
TEST(json, issue_2159)
{
class XReader : public Reader
{
std::string getName() const
{ return "readers.x"; }

virtual void addDimensions(PointLayoutPtr layout)
{
using namespace Dimension;

layout->registerDims( { Id::X, Id::Y, Id::Z } );
}

virtual point_count_t read(PointViewPtr v, point_count_t count)
{
using namespace Dimension;

for (PointId idx = 0; idx < count; ++idx)
{
v->setField(Id::X, idx, idx);
v->setField(Id::Y, idx, 10 * idx);
v->setField(Id::Z, idx, 1.152);
}
return count;
}
};

XReader xr;
Options rOpts;
rOpts.add("count", "1000");
rOpts.add("spatialreference", "EPSG:4326");
xr.setOptions(rOpts);

StatsFilter f;
f.setInput(xr);

PointTable t;
f.prepare(t);
PointViewSet s = f.execute(t);
PointViewPtr v = *(s.begin());
SpatialReference srs = v->spatialReference();
EXPECT_EQ(srs, SpatialReference("EPSG:4326"));
}

} // namespace pdal

0 comments on commit 87fcf53

Please sign in to comment.