Skip to content

Commit

Permalink
tests now working
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemann16 committed Jan 15, 2021
1 parent 08d710e commit 048a8b6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 19 deletions.
63 changes: 44 additions & 19 deletions plugins/draco/test/DracoReaderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,61 +71,81 @@ TEST(DracoReader, Constructor)
}


void check_pN(const pdal::PointView& data, PointId index,
double xref, double yref, double zref, double tolerance)
{
float x0 = data.getFieldAs<float>(Dimension::Id::X, index);
float y0 = data.getFieldAs<float>(Dimension::Id::Y, index);
float z0 = data.getFieldAs<float>(Dimension::Id::Z, index);

EXPECT_TRUE(Utils::compare_approx(x0, static_cast<float>(xref), tolerance));
EXPECT_TRUE(Utils::compare_approx(y0, static_cast<float>(yref), tolerance));
EXPECT_TRUE(Utils::compare_approx(z0, static_cast<float>(zref), tolerance));
}

void check_p0_p1_p2(const pdal::PointView& data, double tolerance)
{
check_pN(data, 0, 637012.240000, 849028.310000, 431.660000, tolerance);
check_pN(data, 1, 636896.330000, 849087.700000, 446.390000, tolerance);
check_pN(data, 2, 636784.740000, 849106.660000, 426.710000, tolerance);
}

TEST(DracoReaderTest, test_sequential)
{
PointTable table;

Options ops1;
ops1.add("filename", Support::datapath("draco/1.2-with-color.drc"));
ops1.add("filename", Support::datapath("draco/1.2-with-color-test.drc"));
DracoReader 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);

check_p0_p1_p2(*view, 0.001);
}


TEST(DracoReaderTest, accuracy)
{
//create pipeline that reads draco file and transforms it via
//filters.transformation. Then apply the offset from RTC_CENTER from
//the pnts file. Check that the results of this fall within the bounds of
//red-rocks.laz

// RTC_CENTER: [ -0.015410084428367554, -0.35363949998281896, 92.70944035355933 ]
PipelineManager pipeline;
//bounding box for original red-rocks.laz this file was created from
BOX3D bounds(-105.2091581, 39.66130695, 1843.98, -105.2009355, 39.669282, 2029.41);
BOX3D bounds(482060.5, 4390187.5, 1843.98, 482763.78, 4391071, 2029.41);
bounds.grow(1);

Options readOptions;
std::string path = Support::datapath("draco/redrocks.drc");
Stage& reader = pipeline.makeReader(path, "readers.draco");

//transform by tileset from cesium
Options filterOptions1;
filterOptions1.add("matrix", "0.9649933973123795 0.16741023360918053 -0.20189491530603648 -1289846.4516338364 -0.26227417551774335 0.6159575938289551 -0.742838138130328 -4745771.507684133 0 0.7697857210207032 0.6383023920624428 4050624.605121021 0 0 0 1");
Stage& filter1 = pipeline.makeFilter("filters.transformation", reader);
filter1.setOptions(filterOptions1);

//transform by RTC center
std::string xOff = "-0.015410084428367554";
std::string yOff = "-0.35363949998281896";
std::string zOff = "92.70944035355933";
Options filterOptions2;
filterOptions2.add("matrix", "1 0 0 "+xOff+" 0 1 0 "+yOff+" 0 0 1 "+zOff+" 0 0 0 1");
Stage& filter2 = pipeline.makeFilter("filters.transformation", filter1);
filter2.setOptions(filterOptions2);
Options rtcOptions;
rtcOptions.add("matrix", "1 0 0 "+xOff+" 0 1 0 "+yOff+" 0 0 1 "+zOff+" 0 0 0 1");
Stage& rtcTransformationFilter = pipeline.makeFilter("filters.transformation", reader);
rtcTransformationFilter.setOptions(rtcOptions);

//transform by tileset from cesium
Options tilesetOptions;
tilesetOptions.add("matrix", "0.9649933973123795 0.16741023360918053 -0.20189491530603648 -1289846.4516338364 -0.26227417551774335 0.6159575938289551 -0.742838138130328 -4745771.507684133 0 0.7697857210207032 0.6383023920624428 4050624.605121021 0 0 0 1");
Stage& tilesetTransformationFilter = pipeline.makeFilter("filters.transformation", rtcTransformationFilter);
tilesetTransformationFilter.setOptions(tilesetOptions);


//set up projection so we can use it against our bounding box
Options projectionOptions;
projectionOptions.add("in_srs", "EPSG:4978");
projectionOptions.add("out_srs", "EPSG:4326");
Stage& projection = pipeline.makeFilter("filters.reprojection", filter2);
projection.setOptions(projectionOptions);
Options reprojectionOptions;
reprojectionOptions.add("in_srs", "EPSG:4978");
reprojectionOptions.add("out_srs", "EPSG:26913");
Stage& reprojectionFilter = pipeline.makeFilter("filters.reprojection", tilesetTransformationFilter);
reprojectionFilter.setOptions(reprojectionOptions);

point_count_t count = pipeline.execute();

Expand All @@ -137,6 +157,11 @@ TEST(DracoReaderTest, accuracy)
double y = v->getFieldAs<double>(Dimension::Id::Y, i);
double z = v->getFieldAs<double>(Dimension::Id::Z, i);
EXPECT_TRUE(bounds.contains(x, y, z));
if (!bounds.contains(x,y,z)) {
std::cout << "X: " << x << std::endl;
std::cout << "Y: " << y << std::endl;
std::cout << "Z: " << z << std::endl;
}
}

}
Expand Down
Binary file added test/data/draco/1.2-with-color-test.drc
Binary file not shown.

0 comments on commit 048a8b6

Please sign in to comment.