TEST(LasReaderTest, EmptyGeotiffVlr) { PointTable table; Options readOps; readOps.add("filename", Support::datapath("las/1.2-empty-geotiff-vlrs.las")); LasReader reader; reader.setOptions(readOps); reader.prepare(table); PointViewSet viewSet = reader.execute(table); PointViewPtr view = *viewSet.begin(); EXPECT_EQ(43u, view->size()); }
cpd::Matrix CpdKernel::readFile(const std::string& filename) { Stage& reader = makeReader(filename, ""); PointTable table; PointViewSet viewSet; if (!m_bounds.empty()) { Options boundsOptions; boundsOptions.add("bounds", m_bounds); Stage& crop = makeFilter("filters.crop", reader); crop.setOptions(boundsOptions); crop.prepare(table); viewSet = crop.execute(table); } else { reader.prepare(table); viewSet = reader.execute(table); } cpd::Matrix matrix(0, 3); for (auto it = viewSet.begin(); it != viewSet.end(); ++it) { PointViewPtr view = *it; point_count_t rowidx; if (matrix.rows() == 0) { rowidx = 0; matrix.resize(view->size(), 3); } else { rowidx = matrix.rows(); matrix.conservativeResize(matrix.rows() + view->size(), 3); } for (point_count_t bufidx = 0; bufidx < view->size(); ++bufidx, ++rowidx) { matrix(rowidx, 0) = view->getFieldAs<double>(Dimension::Id::X, bufidx); matrix(rowidx, 1) = view->getFieldAs<double>(Dimension::Id::Y, bufidx); matrix(rowidx, 2) = view->getFieldAs<double>(Dimension::Id::Z, bufidx); } } return matrix; }
TEST(LasWriterTest, auto_offset) { using namespace Dimension; const std::string FILENAME(Support::temppath("offset_test.las")); PointTable table; table.layout()->registerDim(Id::X); PointViewPtr view(new PointView(table)); view->setField(Id::X, 0, 125000.00); view->setField(Id::X, 1, 74529.00); view->setField(Id::X, 2, 523523.02); Options writerOps; writerOps.add("filename", FILENAME); writerOps.add("offset_x", "auto"); writerOps.add("scale_x", "auto"); LasWriter writer; writer.setOptions(writerOps); writer.prepare(table); WriterWrapper::ready(writer, table); WriterWrapper::write(writer, view); WriterWrapper::done(writer, table); Options readerOps; readerOps.add("filename", FILENAME); PointTable readTable; LasReader reader; reader.setOptions(readerOps); reader.prepare(readTable); EXPECT_DOUBLE_EQ(74529.00, reader.header().offsetX()); PointViewSet viewSet = reader.execute(readTable); EXPECT_EQ(viewSet.size(), 1u); view = *viewSet.begin(); EXPECT_EQ(view->size(), 3u); EXPECT_NEAR(125000.00, view->getFieldAs<double>(Id::X, 0), .0001); EXPECT_NEAR(74529.00, view->getFieldAs<double>(Id::X, 1), .0001); EXPECT_NEAR(523523.02, view->getFieldAs<double>(Id::X, 2), .0001); FileUtils::deleteFile(FILENAME); }
TEST(RxpReaderTest, testNoPpsSync) { Options options = defaultRxpReaderOptions(); Option syncToPps("sync_to_pps", false); options.add(syncToPps); RxpReader reader; reader.setOptions(options); PointTable table; reader.prepare(table); PointViewSet viewSet = reader.execute(table); PointViewPtr view = *viewSet.begin(); checkPoint(view, 0, 0.0705248788, -0.0417557284, 0.0304775704, 31.917255942733149, 0.14050000667339191, 0.689999998, -14.4898596, 3, false, 1, 1); }
TEST_F(PythonFilterTest, pipelineJSON) { PipelineManager manager; manager.readPipeline( Support::configuredpath("plang/programmable-update-y-dims.json")); manager.execute(); PointViewSet viewSet = manager.views(); EXPECT_EQ(viewSet.size(), 1u); PointViewPtr view = *viewSet.begin(); for (PointId idx = 0; idx < 10; ++idx) { int32_t y = view->getFieldAs<int32_t>(Dimension::Id::Y, idx); EXPECT_EQ(y, 314); } }
TEST(TextReaderTest, strip_whitespace_from_dimension_names) { TextReader reader; Options options; options.add("filename", Support::datapath("text/crlf_test.txt")); reader.setOptions(options); PointTable table; reader.prepare(table); PointViewSet pointViewSet = reader.execute(table); PointViewPtr pointViewPtr = *pointViewSet.begin(); for (PointId i = 0; i < pointViewPtr->size(); ++i) { EXPECT_EQ( i, pointViewPtr->getFieldAs<uint16_t>(Dimension::Id::Intensity, i)); } }
TEST(ComputeRangeFilterTest, compute) { using namespace Dimension; PointTable table; PointLayoutPtr layout(table.layout()); layout->registerDim(Id::X); layout->registerDim(Id::Y); layout->registerDim(Id::Z); Id pn = layout->registerOrAssignDim("Pixel Number", Type::Double); Id fn = layout->registerOrAssignDim("Frame Number", Type::Double); PointViewPtr view(new PointView(table)); BufferReader r; r.addView(view); ComputeRangeFilter crop; crop.setInput(r); crop.prepare(table); view->setField(Id::X, 0, 0.0); view->setField(Id::Y, 0, 0.0); view->setField(Id::Z, 0, 0.0); view->setField(pn, 0, 0.0); view->setField(fn, 0, 0.0); view->setField(Id::X, 1, 0.0); view->setField(Id::Y, 1, 3.0); view->setField(Id::Z, 1, 4.0); view->setField(pn, 1, -5.0); view->setField(fn, 1, 0.0); PointViewSet s = crop.execute(table); EXPECT_EQ(1u, s.size()); Id range = layout->findDim("Range"); EXPECT_NE(Id::Unknown, range); PointViewPtr out = *s.begin(); EXPECT_EQ(2u, out->size()); EXPECT_EQ(5.0, out->getFieldAs<double>(range, 0)); EXPECT_EQ(0.0, out->getFieldAs<double>(range, 1)); }
TEST_F(TransformationFilterTest, Rotation) { Options filterOpts; filterOpts.add("matrix", "0 1 0 0\n-1 0 0 0\n0 0 1 0\n0 0 0 1"); m_filter.setOptions(filterOpts); PointTable table; m_filter.prepare(table); PointViewSet viewSet = m_filter.execute(table); PointViewPtr view = *viewSet.begin(); for (point_count_t i = 0; i < view->size(); ++i) { EXPECT_DOUBLE_EQ(2, view->getFieldAs<double>(Dimension::Id::X, i)); EXPECT_DOUBLE_EQ(-1, view->getFieldAs<double>(Dimension::Id::Y, i)); EXPECT_DOUBLE_EQ(3, view->getFieldAs<double>(Dimension::Id::Z, i)); } }
TEST(PlyReader, ReadBinary) { PlyReader reader; Options options; options.add("filename", Support::datapath("ply/simple_binary.ply")); reader.setOptions(options); PointTable table; reader.prepare(table); PointViewSet viewSet = reader.execute(table); EXPECT_EQ(viewSet.size(), 1u); PointViewPtr view = *viewSet.begin(); EXPECT_EQ(view->size(), 3u); checkPoint(view, 0, -1, 0, 0); checkPoint(view, 1, 0, 1, 0); checkPoint(view, 2, 1, 0, 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")); }
TEST_F(PythonFilterTest, pdalargs) { StageFactory f; BOX3D bounds(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); Options ops; ops.add("bounds", bounds); ops.add("count", 10); ops.add("mode", "ramp"); FauxReader reader; reader.setOptions(ops); Option source("source", "import numpy\n" "import sys\n" "import redirector\n" "def myfunc(ins,outs):\n" " pdalargs['name']\n" "# print ('pdalargs', pdalargs, file=sys.stderr,)\n" " return True\n" ); Option module("module", "MyModule"); Option function("function", "myfunc"); Option args("pdalargs", "{\"name\":\"Howard\",\"something\":42, \"another\": \"True\"}"); Options opts; opts.add(source); opts.add(module); opts.add(function); opts.add(args); Stage* filter(f.createStage("filters.python")); filter->setOptions(opts); filter->setInput(reader); PointTable table; filter->prepare(table); PointViewSet viewSet = filter->execute(table); EXPECT_EQ(viewSet.size(), 1u); PointViewPtr view = *viewSet.begin(); // Not throwing anything is success for now }
TEST(CropFilterTest, test_crop_polygon_reprojection) { Options options; options.add("spatialreference", Support::datapath("autzen/autzen-srs.wkt")); options.add("out_srs", "EPSG:4326"); options.add("x_dim", std::string("readers.las.X")); options.add("y_dim", std::string("readers.las.Y")); options.add("z_dim", std::string("readers.las.Z")); options.add("scale_x", 0.0000001f); options.add("scale_y", 0.0000001f); options.add("filename", Support::datapath("las/1.2-with-color.las")); std::istream* wkt_stream = FileUtils::openFile( Support::datapath("autzen/autzen-selection-dd.wkt")); std::stringstream strbuf; strbuf << wkt_stream->rdbuf(); std::string wkt(strbuf.str()); Option polygon("polygon", wkt); options.add(polygon); LasReader reader; reader.setOptions(options); ReprojectionFilter reprojection; reprojection.setOptions(options); reprojection.setInput(reader); CropFilter crop; crop.setOptions(options); crop.setInput(reprojection); PointTable table; PointViewPtr view(new PointView(table)); crop.prepare(table); PointViewSet viewSet = crop.execute(table); EXPECT_EQ(viewSet.size(), 1u); view = *viewSet.begin(); EXPECT_EQ(view->size(), 47u); FileUtils::closeFile(wkt_stream); }
TEST(TextReaderTest, insertHeader) { TextReader reader; Options options; options.add("header", "A,B,C,G"); options.add("filename", Support::datapath("text/crlf_test.txt")); reader.setOptions(options); PointTable table; reader.prepare(table); PointViewSet pointViewSet = reader.execute(table); PointViewPtr pointViewPtr = *pointViewSet.begin(); EXPECT_EQ(pointViewPtr->size(), 11U); PointLayoutPtr layout = table.layout(); EXPECT_TRUE(layout->findDim("A") != Dimension::Id::Unknown); EXPECT_TRUE(layout->findDim("B") != Dimension::Id::Unknown); EXPECT_TRUE(layout->findDim("C") != Dimension::Id::Unknown); EXPECT_TRUE(layout->findDim("G") != Dimension::Id::Unknown); }
TEST(RxpReaderTest, testRead) { Options options = defaultRxpReaderOptions(); RxpReader reader; reader.setOptions(options); PointTable table; reader.prepare(table); PointViewSet viewSet = reader.execute(table); EXPECT_EQ(viewSet.size(), 1); PointViewPtr view = *viewSet.begin(); EXPECT_EQ(view->size(), 177208); checkPoint(view, 0, 2.2630672454833984, -0.038407701998949051, -1.3249952793121338, 342656.34233957872, 2.6865001276019029, 19.8699989, 5.70246553, 4, true, 1, 1); checkPoint(view, 1, 2.2641847133636475, -0.038409631699323654, -1.3245694637298584, 342656.34235912003, 2.687250127637526, 19.5299988, 5.36292124, 2, true, 1, 1); checkPoint(view, 2, 2.26853346824646, -0.038410264998674393, -1.3260456323623657, 342656.34237866144, 2.6917501278512646, 19.3699989, 5.2056551, 5, true, 1, 1); }
TEST(LasReaderTest, test_sequential) { PointTable table; Options ops1; ops1.add("filename", Support::datapath("las/1.2-with-color.las")); ops1.add("count", 103); LasReader reader; reader.setOptions(ops1); reader.prepare(table); PointViewSet viewSet = reader.execute(table); EXPECT_EQ(viewSet.size(), 1u); PointViewPtr view = *viewSet.begin(); Support::check_p0_p1_p2(*view); PointViewPtr view2 = view->makeNew(); view2->appendPoint(*view, 100); view2->appendPoint(*view, 101); view2->appendPoint(*view, 102); Support::check_p100_p101_p102(*view2); }
TEST(LasWriterTest, fix1063_1064_1065) { std::string outfile = Support::temppath("out.las"); std::string infile = Support::datapath("las/test1_4.las"); FileUtils::deleteFile(outfile); std::string cmd = "pdal translate --writers.las.forward=all " "--writers.las.a_srs=\"EPSG:4326\" " + infile + " " + outfile; std::string output; Utils::run_shell_command(Support::binpath(cmd), output); Options o; o.add("filename", outfile); LasReader r; r.setOptions(o); PointTable t; r.prepare(t); PointViewSet s = r.execute(t); EXPECT_EQ(s.size(), 1u); PointViewPtr v = *s.begin(); EXPECT_EQ(v->size(), 1000u); // https://github.com/PDAL/PDAL/issues/1063 for (PointId idx = 0; idx < v->size(); ++idx) EXPECT_EQ(8, v->getFieldAs<int>(Dimension::Id::ClassFlags, idx)); // https://github.com/PDAL/PDAL/issues/1064 MetadataNode m = r.getMetadata(); m = m.findChild("global_encoding"); EXPECT_EQ(17, m.value<int>()); // https://github.com/PDAL/PDAL/issues/1065 SpatialReference ref = v->spatialReference(); std::string wkt = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]"; EXPECT_EQ(ref.getWKT(), wkt); }
TEST(MergeTest, test3) { using namespace pdal; PipelineManager mgr; mgr.readPipeline(Support::configuredpath("filters/merge3.xml")); std::ostringstream oss; std::ostream& o = std::clog; auto ctx = Utils::redirect(o, oss); mgr.execute(); std::string s = oss.str(); EXPECT_TRUE(s.find("inconsistent spatial references") != s.npos); Utils::restore(o, ctx); PointViewSet viewSet = mgr.views(); EXPECT_EQ(1u, viewSet.size()); PointViewPtr view = *viewSet.begin(); EXPECT_EQ(2130u, view->size()); }
TEST(GDALReaderTest, simple) { Options ro; ro.add("filename", Support::datapath("png/autzen-height.png")); GDALReader gr; gr.setOptions(ro); PointTable t; gr.prepare(t); PointViewSet s = gr.execute(t); PointViewPtr v = *s.begin(); PointLayoutPtr l = t.layout(); Dimension::Id::Enum id1 = l->findDim("band-1"); Dimension::Id::Enum id2 = l->findDim("band-2"); Dimension::Id::Enum id3 = l->findDim("band-3"); EXPECT_EQ(v->size(), (size_t)(735 * 973)); auto verify = [v, id1, id2, id3] (PointId idx, double xx, double xy, double xr, double xg, double xb) { double r, g, b, x, y; x = v->getFieldAs<double>(Dimension::Id::X, idx); y = v->getFieldAs<double>(Dimension::Id::Y, idx); r = v->getFieldAs<double>(id1, idx); g = v->getFieldAs<double>(id2, idx); b = v->getFieldAs<double>(id3, idx); EXPECT_DOUBLE_EQ(x, xx); EXPECT_DOUBLE_EQ(y, xy); EXPECT_DOUBLE_EQ(r, xr); EXPECT_DOUBLE_EQ(g, xg); EXPECT_DOUBLE_EQ(b, xb); }; verify(0, .5, .5, 0, 0, 0); verify(120000, 195.5, 163.5, 255, 213, 0); verify(290000, 410.5, 394.5, 0, 255, 206); verify(715154, 734.5, 972.5, 0, 0, 0); }
TEST(PtsReader, ReadPtsExtraDims) { PtsReader reader; Options options; options.add("filename", Support::datapath("pts/test.pts")); reader.setOptions(options); PointTable table; reader.prepare(table); PointViewSet viewSet = reader.execute(table); EXPECT_EQ(viewSet.size(), 1u); PointViewPtr view = *viewSet.begin(); EXPECT_EQ(view->size(), 19u); PointLayout *layout = view->layout(); EXPECT_FLOAT_EQ(view->getFieldAs<float>(Dimension::Id::X, 0), 3.9809721f); EXPECT_FLOAT_EQ(view->getFieldAs<float>(Dimension::Id::Y, 0), -2.006119f); EXPECT_FLOAT_EQ(view->getFieldAs<float>(Dimension::Id::Z, 0), -0.010086f); EXPECT_EQ(view->getFieldAs<int>(Dimension::Id::Red, 0), 97); EXPECT_EQ(view->getFieldAs<int>(Dimension::Id::Green, 0), 59); EXPECT_EQ(view->getFieldAs<int>(Dimension::Id::Blue, 0), 38); }
// Test reprojecting UTM 15 to DD with a filter TEST(ReprojectionFilterTest, ReprojectionFilterTest_test_1) { const char* epsg4326_wkt = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4326\"]]"; PointTable table; const double postX = -93.351563; const double postY = 41.577148; const double postZ = 16.000000; { const SpatialReference out_ref(epsg4326_wkt); Options ops1; ops1.add("filename", Support::datapath("las/utm15.las")); LasReader reader; reader.setOptions(ops1); Options options; options.add("out_srs", out_ref.getWKT()); ReprojectionFilter reprojectionFilter; reprojectionFilter.setOptions(options); reprojectionFilter.setInput(reader); reprojectionFilter.prepare(table); PointViewSet viewSet = reprojectionFilter.execute(table); EXPECT_EQ(viewSet.size(), 1u); PointViewPtr view = *viewSet.begin(); double x, y, z; getPoint(*view.get(), x, y, z); EXPECT_FLOAT_EQ(x, postX); EXPECT_FLOAT_EQ(y, postY); EXPECT_FLOAT_EQ(z, postZ); } }
// Make sure that we can translate this special test data to 1.4, dataformat 6. TEST(LasWriterTest, issue2320) { std::string outfile(Support::temppath("2320.laz")); { LasReader r; Options ro; ro.add("filename", Support::datapath("las/wontcompress3.las")); r.setOptions(ro); LasWriter w; Options wo; wo.add("minor_version", 4); wo.add("dataformat_id", 6); wo.add("filename", outfile); w.setOptions(wo); w.setInput(r); PointTable t; w.prepare(t); w.execute(t); } // Check that we can read. { LasReader r; Options ro; ro.add("filename", outfile); r.setOptions(ro); PointTable t; r.prepare(t); PointViewSet s = r.execute(t); EXPECT_EQ(s.size(), 1U); PointViewPtr v = *s.begin(); EXPECT_EQ(v->size(), 1000U); } }
TEST(CropFilterTest, test_crop_polygon) { #ifdef PDAL_HAVE_GEOS Options ops1; ops1.add("filename", Support::datapath("las/1.2-with-color.las")); LasReader reader; reader.setOptions(ops1); Options options; Option debug("debug", true, ""); Option verbose("verbose", 9, ""); std::istream* wkt_stream = FileUtils::openFile(Support::datapath("autzen/autzen-selection.wkt")); std::stringstream strbuf; strbuf << wkt_stream->rdbuf(); std::string wkt(strbuf.str()); Option polygon("polygon", wkt, ""); options.add(polygon); CropFilter crop; crop.setInput(reader); crop.setOptions(options); PointTable table; crop.prepare(table); PointViewSet viewSet = crop.execute(table); EXPECT_EQ(viewSet.size(), 1u); PointViewPtr view = *viewSet.begin(); EXPECT_EQ(view->size(), 47u); FileUtils::closeFile(wkt_stream); #endif }
int PCLKernel::execute() { PointTable table; Stage& readerStage(makeReader(m_inputFile, "")); // go ahead and prepare/execute on reader stage only to grab input // PointViewSet, this makes the input PointView available to both the // processing pipeline. readerStage.prepare(table); PointViewSet viewSetIn = readerStage.execute(table); // the input PointViewSet will be used to populate a BufferReader that is // consumed by the processing pipeline PointViewPtr input_view = *viewSetIn.begin(); std::shared_ptr<BufferReader> bufferReader(new BufferReader); bufferReader->addView(input_view); Options filterOptions({"filename", m_pclFile}); Stage& pclStage = makeFilter("filters.pclblock", *bufferReader, filterOptions); // the PCLBlock stage consumes the BufferReader rather than the // readerStage Options writerOptions; if (m_bCompress) writerOptions.add<bool>("compression", true); if (m_bForwardMetadata) writerOptions.add("forward_metadata", true); Stage& writer(makeWriter(m_outputFile, pclStage, "", writerOptions)); writer.prepare(table); writer.execute(table); return 0; }
TEST(RangeFilterTest, nan) { LasReader reader; Options options; options.add("filename", Support::datapath("las/gps-time-nan.las")); reader.setOptions(options); Options rangeOptions; rangeOptions.add("limits", "GpsTime[-1:1]"); RangeFilter filter; filter.setOptions(rangeOptions); filter.setInput(reader); PointTable table; filter.prepare(table); PointViewSet viewSet = filter.execute(table); PointViewPtr view = *viewSet.begin(); EXPECT_EQ(1u, viewSet.size()); EXPECT_EQ(0u, view->size()); }
// Make sure that dimension names containing digits works TEST(RangeFilterTest, case_1659) { TextReader reader; Options ops; ops.add("filename", Support::datapath("text/numeric_dim.txt")); reader.setOptions(ops); Options rangeOps; rangeOps.add("limits", "Eigenvalue0[:35]"); RangeFilter filter; filter.setOptions(rangeOps); filter.setInput(reader); PointTable table; filter.prepare(table); PointViewSet viewSet = filter.execute(table); PointViewPtr view = *viewSet.begin(); EXPECT_EQ(1u, viewSet.size()); EXPECT_EQ(3u, view->size()); }
int RandomKernel::execute() { Options readerOptions; if (!m_bounds.empty()) readerOptions.add("bounds", m_bounds); std::string distribution(Utils::tolower(m_distribution)); if (distribution == "uniform") readerOptions.add("mode", "uniform"); else if (distribution == "normal") readerOptions.add("mode", "normal"); else if (distribution == "random") readerOptions.add("mode", "random"); else throw pdal_error("invalid distribution: " + m_distribution); readerOptions.add("count", m_numPointsToWrite); Options writerOptions; if (m_bCompress) writerOptions.add("compression", true); Stage& reader = makeReader("", "readers.faux"); reader.addOptions(readerOptions); Stage& writer = makeWriter(m_outputFile, reader, ""); writer.addOptions(writerOptions); PointTable table; writer.prepare(table); PointViewSet viewSet = writer.execute(table); if (isVisualize()) visualize(*viewSet.begin()); return 0; }
TEST(SbetReaderTest, testRead) { Option filename("filename", Support::datapath("sbet/2-points.sbet"), ""); Options options(filename); std::shared_ptr<SbetReader> reader(new SbetReader); reader->setOptions(options); PointTable table; reader->prepare(table); PointViewSet viewSet = reader->execute(table); EXPECT_EQ(viewSet.size(), 1u); PointViewPtr view = *viewSet.begin(); EXPECT_EQ(view->size(), 2u); checkPoint(*view.get(), 0, 1.516310028360710e+05, 5.680211852972264e-01, -2.041654392303940e+00, 1.077152953296560e+02, -2.332420866600025e+00, -3.335067504871401e-01, -3.093961631767838e-02, -2.813407149321339e-02, -2.429905393889139e-02, 3.046773230278662e+00, -2.198414736922658e-02, 7.859639737752390e-01, 7.849084719295495e-01, -2.978807916450262e-01, 6.226807982589819e-05, 9.312162756440178e-03, 7.217812320996525e-02); checkPoint(*view.get(), 1, 1.516310078318641e+05, 5.680211834722869e-01, -2.041654392034053e+00, 1.077151424357507e+02, -2.336228229691271e+00, -3.324663118952635e-01, -3.022948961008987e-02, -2.813856631423094e-02, -2.425215669392169e-02, 3.047131105236811e+00, -2.198416007932108e-02, 8.397590491636475e-01, 3.252165276637165e-01, -1.558883225990844e-01, 8.379685112283802e-04, 7.372886784718076e-03, 7.179027672314571e-02); }
TEST(OldPCLBlockTests, StatisticalOutliers2) { StageFactory f; Options ro; ro.add("filename", Support::datapath("autzen/autzen-point-format-3.las")); Stage* r(f.createStage("readers.las")); EXPECT_TRUE(r); r->setOptions(ro); Options fo; fo.add("method", "statistical"); fo.add("multiplier", 0.0); fo.add("mean_k", 5); Stage* outlier(f.createStage("filters.outlier")); EXPECT_TRUE(outlier); outlier->setOptions(fo); outlier->setInput(*r); Options rangeOpts; rangeOpts.add("limits", "Classification![7:7]"); Stage* range(f.createStage("filters.range")); EXPECT_TRUE(range); range->setOptions(rangeOpts); range->setInput(*outlier); PointTable table; range->prepare(table); PointViewSet viewSet = range->execute(table); EXPECT_EQ(1u, viewSet.size()); PointViewPtr view = *viewSet.begin(); EXPECT_EQ(63u, view->size()); }
TEST(QFITReaderTest, test_14_word) { Options options; options.add("filename", Support::datapath("qfit/14-word.qi"), "Input filename for reader to use"); options.add("flip_coordinates", false, "Flip coordinates from 0-360 to -180-180"); options.add("scale_z", 0.001f, "Z scale from mm to m"); options.add("count", 3); PointTable table; std::shared_ptr<QfitReader> reader(new QfitReader); reader->setOptions(options); reader->prepare(table); PointViewSet viewSet = reader->execute(table); EXPECT_EQ(viewSet.size(), 1u); PointViewPtr view = *viewSet.begin(); EXPECT_EQ(view->size(), 3u); Check_Point(*view, 0, 244.306337, 35.623317, 1056.830000000, 903); Check_Point(*view, 1, 244.306260, 35.623280, 1056.409000000, 903); Check_Point(*view, 2, 244.306204, 35.623257, 1056.483000000, 903); }
TEST(Compression, simple) { const std::string file(Support::datapath("las/1.2-with-color.las")); const pdal::Option opt_filename("filename", file); pdal::Options opts; opts.add(opt_filename); LasReader reader; reader.setOptions(opts); PointTable table; PointLayoutPtr layout(table.layout()); reader.prepare(table); PointViewSet viewSet = reader.execute(table); PointViewPtr view = *viewSet.begin(); EXPECT_EQ(layout->pointSize(), 52U); std::vector<unsigned char> rawBuf; DimTypeList dimTypes = layout->dimTypes(); auto cb = [&rawBuf](char *buf, size_t bufsize) { unsigned char *ubuf = reinterpret_cast<unsigned char *>(buf); rawBuf.insert(rawBuf.end(), ubuf, ubuf + bufsize); }; LazPerfCompressor compressor(cb, dimTypes); std::vector<char> tmpbuf(layout->pointSize()); for (PointId idx = 0; idx < view->size(); ++idx) { view->getPackedPoint(dimTypes, idx, tmpbuf.data()); compressor.compress(tmpbuf.data(), layout->pointSize()); } compressor.done(); EXPECT_EQ(view->size() * layout->pointSize(), (size_t)55380); EXPECT_EQ(rawBuf.size(), (size_t)30945); PointViewPtr otherView(new PointView(table)); PointId nextId(0); auto cb2 = [&otherView, &dimTypes, &nextId](char *buf, size_t bufsize) { otherView->setPackedPoint(dimTypes, nextId, buf); nextId++; }; LazPerfDecompressor(cb2, dimTypes, view->size()). decompress(reinterpret_cast<const char *>(rawBuf.data()), rawBuf.size()); EXPECT_EQ(otherView->size(), 1065U); EXPECT_EQ(getBytes(otherView).size(), (size_t)(52 * 1065)); uint16_t r = otherView->getFieldAs<uint16_t>(Dimension::Id::Red, 10); EXPECT_EQ(r, 64U); int32_t x = otherView->getFieldAs<int32_t>(Dimension::Id::X, 10); EXPECT_EQ(x, 636038); double xd = otherView->getFieldAs<double>(Dimension::Id::X, 10); EXPECT_FLOAT_EQ(xd, 636037.53); int32_t y = otherView->getFieldAs<int32_t>(Dimension::Id::Y, 10); EXPECT_EQ(y, 849338); }