| 45 | using namespace pdal; |
| 46 | |
| 47 | TEST(ChipperTest, test_construction) |
| 48 | { |
| 49 | PointTable table; |
| 50 | |
| 51 | Options ops1; |
| 52 | std::string filename(Support::datapath("las/1.2-with-color.las")); |
| 53 | ops1.add("filename", filename); |
| 54 | LasReader reader; |
| 55 | reader.setOptions(ops1); |
| 56 | |
| 57 | { |
| 58 | // need to scope the writer, so that's it dtor can use the stream |
| 59 | |
| 60 | Options options; |
| 61 | Option capacity("capacity", 15); |
| 62 | options.add(capacity); |
| 63 | |
| 64 | ChipperFilter chipper; |
| 65 | chipper.setInput(reader); |
| 66 | chipper.setOptions(options); |
| 67 | chipper.prepare(table); |
| 68 | PointViewSet viewSet = chipper.execute(table); |
| 69 | EXPECT_EQ(viewSet.size(), 71u); |
| 70 | |
| 71 | std::vector<PointViewPtr> views; |
| 72 | for (auto it = viewSet.begin(); it != viewSet.end(); ++it) |
| 73 | views.push_back(*it); |
| 74 | |
| 75 | auto sorter = [](PointViewPtr p1, PointViewPtr p2) |
| 76 | { |
| 77 | //This is super inefficient, but we're doing tests. |
| 78 | BOX2D b1; |
| 79 | BOX2D b2; |
| 80 | |
| 81 | p1->calculateBounds(b1); |
| 82 | p2->calculateBounds(b2); |
| 83 | |
| 84 | return b1.minx < b2.minx ? true : |
| 85 | b1.minx > b2.minx ? false : |
| 86 | b1.miny < b2.miny; |
| 87 | }; |
| 88 | |
| 89 | std::sort(views.begin(), views.end(), sorter); |
| 90 | |
| 91 | PointViewPtr view = views[2]; |
| 92 | BOX2D bounds; |
| 93 | view->calculateBounds(bounds); |
| 94 | |
| 95 | EXPECT_NEAR(bounds.minx, 635674.05, 0.05); |
| 96 | EXPECT_NEAR(bounds.maxx, 635993.93, 0.05); |
| 97 | EXPECT_NEAR(bounds.miny, 848992.45, 0.05); |
| 98 | EXPECT_NEAR(bounds.maxy, 849427.07, 0.05); |
| 99 | |
| 100 | for (size_t i = 0; i < views.size(); ++i) |
| 101 | EXPECT_EQ(views[i]->size(), 15u); |
| 102 | } |
| 103 | } |
| 104 |
nothing calls this directly
no test coverage detected