From 6e8bcd7a7e977f8bb2a5d311d745d19e55beb093 Mon Sep 17 00:00:00 2001 From: Andrew Bell Date: Wed, 12 Sep 2018 14:26:04 -0400 Subject: [PATCH] Set spatialreference for all readers. (#2165) Close #2159 --- io/LasReader.cpp | 1 - io/TextReader.cpp | 1 - pdal/Reader.cpp | 1 + plugins/oci/io/OciReader.cpp | 1 - plugins/sqlite/io/SQLiteReader.cpp | 8 ++--- test/unit/apps/pcpipelineTestJSON.cpp | 52 +++++++++++++++++++++++++-- 6 files changed, 52 insertions(+), 12 deletions(-) diff --git a/io/LasReader.cpp b/io/LasReader.cpp index fa5a9cd01e..22d8da52f7 100644 --- a/io/LasReader.cpp +++ b/io/LasReader.cpp @@ -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"); diff --git a/io/TextReader.cpp b/io/TextReader.cpp index e61008c7b4..5715a80374 100644 --- a/io/TextReader.cpp +++ b/io/TextReader.cpp @@ -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); diff --git a/pdal/Reader.cpp b/pdal/Reader.cpp index ac1720a3b5..e37fb08293 100644 --- a/pdal/Reader.cpp +++ b/pdal/Reader.cpp @@ -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::max)()); + addSpatialReferenceArg(args); } } // namespace pdal diff --git a/plugins/oci/io/OciReader.cpp b/plugins/oci/io/OciReader.cpp index 4886ce0f96..6dc0384008 100644 --- a/plugins/oci/io/OciReader.cpp +++ b/plugins/oci/io/OciReader.cpp @@ -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); } diff --git a/plugins/sqlite/io/SQLiteReader.cpp b/plugins/sqlite/io/SQLiteReader.cpp index 386a207fe9..ca731fc7c0 100644 --- a/plugins/sqlite/io/SQLiteReader.cpp +++ b/plugins/sqlite/io/SQLiteReader.cpp @@ -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()); } @@ -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); diff --git a/test/unit/apps/pcpipelineTestJSON.cpp b/test/unit/apps/pcpipelineTestJSON.cpp index 9e16bfad94..d4a9619984 100644 --- a/test/unit/apps/pcpipelineTestJSON.cpp +++ b/test/unit/apps/pcpipelineTestJSON.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include "Support.hpp" #include @@ -307,7 +308,7 @@ 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"); @@ -315,7 +316,7 @@ TEST(json, issue1417) } // Make sure we handle repeated options properly -TEST(json, issue1941) +TEST(json, issue_1941) { PipelineManager manager; std::string file; @@ -338,7 +339,6 @@ TEST(json, issue1941) EXPECT_THROW(manager2.readPipeline(file), pdal_error); } - // Test that stage options passed via --stage..