Skip to content

Commit

Permalink
Enable the LAS writer tests that pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed May 15, 2014
1 parent 815b0f9 commit 366a1cb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 38 deletions.
2 changes: 1 addition & 1 deletion test/unit/CMakeLists.txt
Expand Up @@ -32,7 +32,7 @@ SET(PDAL_UNITTEST_TEST_SRC
# filters/HexbinFilterTest.cpp
# filters/InPlaceReprojectionFilterTest.cpp
drivers/las/LasReaderTest.cpp
# drivers/las/LasWriterTest.cpp
drivers/las/LasWriterTest.cpp
# LogTest.cpp
MetadataTest.cpp
# filters/MosaicFilterTest.cpp
Expand Down
86 changes: 49 additions & 37 deletions test/unit/drivers/las/LasWriterTest.cpp
Expand Up @@ -55,20 +55,21 @@ BOOST_AUTO_TEST_SUITE(LasWriterTest)

BOOST_AUTO_TEST_CASE(LasWriterTest_test_simple_las)
{
PointContext ctx;

// remove file from earlier run, if needed
std::string temp_filename("temp-LasWriterTest_test_simple_las.las");
FileUtils::deleteFile(temp_filename);

pdal::drivers::las::Reader reader(Support::datapath("1.2-with-color.las"));

std::ostream* ofs = FileUtils::createFile(Support::temppath(temp_filename));

{
// need to scope the writer, so that's it dtor can use the stream
pdal::drivers::las::Writer writer(ofs);
writer.setInput(&reader);
BOOST_CHECK_EQUAL(writer.getDescription(), "Las Writer");
writer.initialize();
writer.prepare(ctx);

const boost::uint64_t numPoints = reader.getNumPoints();

Expand All @@ -78,7 +79,7 @@ BOOST_AUTO_TEST_CASE(LasWriterTest_test_simple_las)
writer.setSystemIdentifier("");
writer.setGeneratingSoftware("TerraScan");

writer.write(numPoints);
writer.execute(ctx);
}

FileUtils::closeFile(ofs);
Expand All @@ -95,6 +96,8 @@ BOOST_AUTO_TEST_CASE(LasWriterTest_test_simple_las)
#ifdef PDAL_HAVE_LASZIP
BOOST_AUTO_TEST_CASE(LasWriterTest_test_simple_laz)
{
PointContext ctx;

// remove file from earlier run, if needed
FileUtils::deleteFile("laszip/LasWriterTest_test_simple_laz.laz");

Expand All @@ -116,8 +119,8 @@ BOOST_AUTO_TEST_CASE(LasWriterTest_test_simple_laz)
writer.setGeneratingSoftware("TerraScan");
writer.setHeaderPadding(2);

writer.initialize();
writer.write(numPoints);
writer.prepare(ctx);
writer.execute(ctx);
}

FileUtils::closeFile(ofs);
Expand All @@ -128,7 +131,7 @@ BOOST_AUTO_TEST_CASE(LasWriterTest_test_simple_laz)

// these two files only differ by the description string in the VLR.
// This now skips the entire LASzip VLR for comparison.
const boost::uint32_t numdiffs = Support::diff_files(Support::temppath("LasWriterTest_test_simple_laz.laz"),
const boost::uint32_t numdiffs =Support::diff_files(Support::temppath("LasWriterTest_test_simple_laz.laz"),
Support::datapath("laszip/laszip-generated.laz"),
227, 106);
BOOST_CHECK_EQUAL(numdiffs, 0);
Expand All @@ -140,8 +143,11 @@ BOOST_AUTO_TEST_CASE(LasWriterTest_test_simple_laz)
}
#endif

/**
static void test_a_format(const std::string& refFile, boost::uint8_t majorVersion, boost::uint8_t minorVersion, int pointFormat)
{
PointContext ctx;
// remove file from earlier run, if needed
FileUtils::deleteFile("temp.las");
Expand All @@ -166,9 +172,8 @@ static void test_a_format(const std::string& refFile, boost::uint8_t majorVersio
boost::uuids::uuid u = boost::lexical_cast<boost::uuids::uuid>("8388f1b8-aa1b-4108-bca3-6bc68e7b062e");
writer.setProjectId(u);
writer.initialize();

writer.write(numPoints);
writer.prepare(ctx);
writer.execute(ctx);
}
FileUtils::closeFile(ofs);
Expand All @@ -183,9 +188,13 @@ static void test_a_format(const std::string& refFile, boost::uint8_t majorVersio
FileUtils::deleteFile(Support::temppath("temp.las"));
}
}
**/

/**
BOOST_AUTO_TEST_CASE(LasWriterTest_test_metadata)
{
PointContext ctx;
// remove file from earlier run, if needed
std::string temp_filename(Support::temppath("temp-LasWriterTest_test_metadata.las"));
FileUtils::deleteFile(temp_filename);
Expand Down Expand Up @@ -231,16 +240,14 @@ BOOST_AUTO_TEST_CASE(LasWriterTest_test_metadata)
{
pdal::drivers::las::Writer writer(options);
writer.setInput(&reader);
writer.initialize();

const boost::uint64_t numPoints = reader.getNumPoints();

writer.write(numPoints);
writer.prepare(ctx);
writer.execute(ctx);
}
PointContext ctx2;
pdal::drivers::las::Reader reader2(options);
reader2.initialize();
reader2.prepare(ctx2);
pdal::drivers::las::LasHeader const& h = reader2.getLasHeader();
Expand All @@ -259,9 +266,13 @@ BOOST_AUTO_TEST_CASE(LasWriterTest_test_metadata)
FileUtils::deleteFile(temp_filename);
}
**/

/**
BOOST_AUTO_TEST_CASE(LasWriterTest_test_ignored_dimensions)
{
PointContext ctx;
// remove file from earlier run, if needed
std::string temp_filename(Support::temppath("temp-LasWriterTest_test_ignored_dimensions.las"));
FileUtils::deleteFile(temp_filename);
Expand Down Expand Up @@ -299,29 +310,25 @@ BOOST_AUTO_TEST_CASE(LasWriterTest_test_ignored_dimensions)
selector.setInput(&reader);
pdal::drivers::las::Writer writer(options);
writer.setInput(&selector);
writer.initialize();

const boost::uint64_t numPoints = reader.getNumPoints();

writer.write(numPoints);
writer.prepare(ctx);
writer.execute(ctx);
}
{
pdal::drivers::las::Reader reader2(options);
reader2.initialize();

const Schema& schema2 = reader2.getSchema();
PointContext ctx2;
PointBuffer altered(schema2);
pdal::drivers::las::Reader reader2(options);
reader2.prepare(ctx2);
PointBuffer altered(ctx2);
pdal::StageSequentialIterator* iter = reader2.createSequentialIterator(altered);

pdal::StageSequentialIterator* iter =
reader2.createSequentialIterator();
iter->read(altered, 1);

pdal::Dimension const& dimRed = schema2.getDimension("Red");
pdal::Dimension const& dimX = schema2.getDimension("X");
Schema *schema2 = ctx2.getSchema();
pdal::Dimension const& dimRed = schema2->getDimension("Red");
pdal::Dimension const& dimX = schema2->getDimension("X");
boost::uint16_t r = altered.getField<boost::uint16_t>(dimRed, 0);
BOOST_CHECK_EQUAL(r, 0u);
boost::int32_t x = altered.getField<boost::int32_t>(dimX, 0);
Expand All @@ -331,17 +338,19 @@ BOOST_AUTO_TEST_CASE(LasWriterTest_test_ignored_dimensions)
}
{

PointContext ctx3;
pdal::drivers::las::Reader reader3(Support::datapath("interesting.las"));
reader3.initialize();
const Schema& schema1 = reader3.getSchema();
PointBuffer original(schema1);
pdal::StageSequentialIterator* iter2 = reader.createSequentialIterator(original);
reader3.prepare(ctx);
PointBuffer original(ctx);
pdal::StageSequentialIterator* iter2 =
reader.createSequentialIterator();
iter2->read(original, 1);
pdal::Dimension const& dimRed2 = schema1.getDimension("Red");
pdal::Dimension const& dimX2 = schema1.getDimension("X");
Schema *schema = ctx.getSchema();
pdal::Dimension const& dimRed2 = schema->getDimension("Red");
pdal::Dimension const& dimX2 = schema->getDimension("X");
boost::uint16_t r2 = original.getField<boost::uint16_t>(dimRed2, 0);
BOOST_CHECK_EQUAL(r2, 68u);
boost::int32_t x2 = original.getField<boost::int32_t>(dimX2, 0);
Expand All @@ -352,7 +361,9 @@ BOOST_AUTO_TEST_CASE(LasWriterTest_test_ignored_dimensions)
FileUtils::deleteFile(temp_filename);
}
**/

/**
BOOST_AUTO_TEST_CASE(test_different_formats)
{
test_a_format("1.0_0.las", 1, 0, 0);
Expand All @@ -377,6 +388,7 @@ BOOST_AUTO_TEST_CASE(test_summary_data_add_point)
BOOST_CHECK_EQUAL(b.getMinimum(0), b.getMaximum(0));
BOOST_CHECK_EQUAL(b.getMinimum(2), b.getMaximum(2));
}
**/


BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 366a1cb

Please sign in to comment.