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 reprojecting UTM 15 to DD with a filter TEST(ReprojectionFilterTest, stream_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\"]]"; Options ops1; ops1.add("filename", Support::datapath("las/utm15.las")); LasReader reader; reader.setOptions(ops1); Options options; options.add("out_srs", epsg4326_wkt); ReprojectionFilter reprojectionFilter; reprojectionFilter.setOptions(options); reprojectionFilter.setInput(reader); auto cb = [](PointRef& point) { static int i = 0; const double x = -93.351563; const double y = 41.577148; const double z = 16.000000; if (i == 0) { EXPECT_FLOAT_EQ(point.getFieldAs<float>(Dimension::Id::X), x); EXPECT_FLOAT_EQ(point.getFieldAs<float>(Dimension::Id::Y), y); EXPECT_FLOAT_EQ(point.getFieldAs<float>(Dimension::Id::Z), z); } ++i; return true; }; StreamCallbackFilter stream; stream.setCallback(cb); stream.setInput(reprojectionFilter); FixedPointTable table(20); stream.prepare(table); stream.execute(table); }
// 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); } }
TEST(CropFilterTest, test_crop_polygon_reprojection) { #ifdef PDAL_HAVE_GEOS Options options; Option in_srs("spatialreference",Support::datapath("autzen/autzen-srs.wkt"), "Input SRS"); Option out_srs("out_srs","EPSG:4326", "Output SRS to reproject to"); Option x_dim("x_dim", std::string("readers.las.X"), "Dimension name to use for 'X' data"); Option y_dim("y_dim", std::string("readers.las.Y"), "Dimension name to use for 'Y' data"); Option z_dim("z_dim", std::string("readers.las.Z"), "Dimension name to use for 'Z' data"); Option x_scale("scale_x", 0.0000001f, "Scale for output X data " "in the case when 'X' dimension data are to be scaled. Defaults " "to '1.0'. If not set, the Dimensions's scale will be used"); Option y_scale("scale_y", 0.0000001f, "Scale for output Y data " "in the case when 'Y' dimension data are to be scaled. Defaults " "to '1.0'. If not set, the Dimensions's scale will be used"); Option filename("filename", Support::datapath("las/1.2-with-color.las")); Option debug("debug", true, ""); Option verbose("verbose", 9, ""); // options.add(debug); // options.add(verbose); options.add(in_srs); options.add(out_srs); options.add(x_dim); options.add(y_dim); options.add(z_dim); options.add(x_scale); options.add(y_scale); options.add(filename); 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); #endif }