[Liblas-commits] libpc: w00t: .laz support

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Feb 28 19:21:08 EST 2011


details:   http://hg.liblas.orglibpc/rev/7a0191148d87
changeset: 123:7a0191148d87
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Feb 28 16:21:04 2011 -0800
description:
w00t: .laz support

diffstat:

 src/drivers/liblas/writer.cpp  |    8 +++++++
 src/drivers/liblas/writer.hpp  |    3 ++
 test/data/simple.laz           |    0 
 test/unit/LiblasWriterTest.cpp |   42 ++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 52 insertions(+), 1 deletions(-)

diffs (104 lines):

diff -r 17fff2474d04 -r 7a0191148d87 src/drivers/liblas/writer.cpp
--- a/src/drivers/liblas/writer.cpp	Mon Feb 28 16:15:15 2011 -0800
+++ b/src/drivers/liblas/writer.cpp	Mon Feb 28 16:21:04 2011 -0800
@@ -81,6 +81,8 @@
     setFormatVersion(1,2);
     setPointFormat(0);
 
+    setCompressed(false);
+
     setSystemIdentifier("libPC");
     setGeneratingSoftware(GetVersionString());
 
@@ -97,6 +99,12 @@
 }
 
 
+void LiblasWriter::setCompressed(bool v)
+{
+    m_externalHeader->SetCompressed(v);
+}
+
+
 void LiblasWriter::setFormatVersion(boost::uint8_t majorVersion, boost::uint8_t minorVersion)
 {
     m_externalHeader->SetVersionMajor(majorVersion);
diff -r 17fff2474d04 -r 7a0191148d87 src/drivers/liblas/writer.hpp
--- a/src/drivers/liblas/writer.hpp	Mon Feb 28 16:15:15 2011 -0800
+++ b/src/drivers/liblas/writer.hpp	Mon Feb 28 16:21:04 2011 -0800
@@ -64,6 +64,9 @@
     // up to 32 chars (default is "libPC x.y.z")
     void setGeneratingSoftware(const std::string& softwareId);
 
+    // default false
+    void setCompressed(bool);
+
 protected:
     // this is called once before the loop with the writeBuffer calls
     virtual void writeBegin();
diff -r 17fff2474d04 -r 7a0191148d87 test/data/simple.laz
Binary file test/data/simple.laz has changed
diff -r 17fff2474d04 -r 7a0191148d87 test/unit/LiblasWriterTest.cpp
--- a/test/unit/LiblasWriterTest.cpp	Mon Feb 28 16:15:15 2011 -0800
+++ b/test/unit/LiblasWriterTest.cpp	Mon Feb 28 16:21:04 2011 -0800
@@ -45,7 +45,7 @@
 
 BOOST_AUTO_TEST_SUITE(LiblasWriterTest)
 
-BOOST_AUTO_TEST_CASE(test_1)
+BOOST_AUTO_TEST_CASE(test_simple_las)
 {
     // remove file from earlier run, if needed
     Utils::deleteFile("temp.las");
@@ -61,6 +61,7 @@
         // need to scope the writer, so that's it dtor can use the stream
         LiblasWriter writer(reader, *ofs);
 
+        writer.setCompressed(false);
         writer.setDate(0, 0);
         writer.setPointFormat(3);
         writer.setSystemIdentifier("");
@@ -83,4 +84,43 @@
     return;
 }
 
+BOOST_AUTO_TEST_CASE(test_test_simple_laz)
+{
+    // remove file from earlier run, if needed
+    Utils::deleteFile("temp.las");
+
+    std::istream* ifs = Utils::openFile("../../test/data/1.2-with-color.las");
+    LiblasReader reader(*ifs);
+    
+    std::ostream* ofs = Utils::createFile("temp.laz");
+
+    {
+        const boost::uint64_t numPoints = reader.getHeader().getNumPoints();
+
+        // need to scope the writer, so that's it dtor can use the stream
+        LiblasWriter writer(reader, *ofs);
+
+        writer.setCompressed(true);
+        writer.setDate(0, 0);
+        writer.setPointFormat(3);
+        writer.setSystemIdentifier("");
+        writer.setGeneratingSoftware("TerraScan");
+
+        writer.write(numPoints);
+    }
+
+    Utils::closeFile(ofs);
+    Utils::closeFile(ifs);
+
+    bool filesSame = compare_files("temp.laz", "../../test/data/simple.laz");
+    BOOST_CHECK(filesSame);
+
+    if (filesSame)
+    {
+        Utils::deleteFile("temp.laz");
+    }
+
+    return;
+}
+
 BOOST_AUTO_TEST_SUITE_END()


More information about the Liblas-commits mailing list