diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 3032415c59..20ec16177a 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -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 diff --git a/test/unit/drivers/las/LasWriterTest.cpp b/test/unit/drivers/las/LasWriterTest.cpp index b46b1a22d5..d40e1d7db8 100644 --- a/test/unit/drivers/las/LasWriterTest.cpp +++ b/test/unit/drivers/las/LasWriterTest.cpp @@ -55,12 +55,13 @@ 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)); { @@ -68,7 +69,7 @@ BOOST_AUTO_TEST_CASE(LasWriterTest_test_simple_las) 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(); @@ -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); @@ -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"); @@ -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); @@ -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); @@ -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"); @@ -166,9 +172,8 @@ static void test_a_format(const std::string& refFile, boost::uint8_t majorVersio boost::uuids::uuid u = boost::lexical_cast("8388f1b8-aa1b-4108-bca3-6bc68e7b062e"); writer.setProjectId(u); - writer.initialize(); - - writer.write(numPoints); + writer.prepare(ctx); + writer.execute(ctx); } FileUtils::closeFile(ofs); @@ -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); @@ -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(); @@ -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); @@ -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(dimRed, 0); BOOST_CHECK_EQUAL(r, 0u); boost::int32_t x = altered.getField(dimX, 0); @@ -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(dimRed2, 0); BOOST_CHECK_EQUAL(r2, 68u); boost::int32_t x2 = original.getField(dimX2, 0); @@ -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); @@ -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()