[Liblas-commits] libpc: liblas writer working; added file comparator, support fun...

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Feb 25 16:05:03 EST 2011


details:   http://hg.liblas.orglibpc/rev/34233307260f
changeset: 99:34233307260f
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Feb 25 12:58:56 2011 -0800
description:
liblas writer working; added file comparator, support functions
Subject: libpc: merge

details:   http://hg.liblas.orglibpc/rev/bb6ea4c3e3fe
changeset: 100:bb6ea4c3e3fe
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Feb 25 12:59:12 2011 -0800
description:
merge
Subject: libpc: lint

details:   http://hg.liblas.orglibpc/rev/76cfeb54a23e
changeset: 101:76cfeb54a23e
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Feb 25 13:02:20 2011 -0800
description:
lint
Subject: libpc: fix dyn linkage

details:   http://hg.liblas.orglibpc/rev/e634794df074
changeset: 102:e634794df074
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Feb 25 13:04:42 2011 -0800
description:
fix dyn linkage
Subject: libpc: fix file path

details:   http://hg.liblas.orglibpc/rev/4736b915dee3
changeset: 103:4736b915dee3
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Feb 25 13:04:51 2011 -0800
description:
fix file path

diffstat:

 CMakeLists.txt                 |    2 +-
 include/libpc/LiblasWriter.hpp |    9 +++++-
 src/Dimension.cpp              |    4 +-
 src/LiblasReader.cpp           |    6 ++-
 src/LiblasWriter.cpp           |   62 +++++++++++++++++++++++++++++++++++++---
 test/data/simple.las           |    0 
 test/unit/BoundsTest.cpp       |    4 +-
 test/unit/CMakeLists.txt       |    2 +
 test/unit/ColorTest.cpp        |    4 +-
 test/unit/CropFilterTest.cpp   |    2 +
 test/unit/LiblasReaderTest.cpp |    4 +-
 test/unit/LiblasWriterTest.cpp |   12 +++++++-
 test/unit/PointDataTest.cpp    |    2 +
 test/unit/RangeTest.cpp        |    2 +
 test/unit/SchemaTest.cpp       |    2 +
 test/unit/UtilsTest.cpp        |   10 +++--
 test/unit/VectorTest.cpp       |    2 +
 test/unit/main.cpp             |    7 ++-
 test/unit/support.cpp          |   57 +++++++++++++++++++++++++++++++++++++
 test/unit/support.hpp          |    7 ++++
 20 files changed, 178 insertions(+), 22 deletions(-)

diffs (truncated from 466 to 300 lines):

diff -r 97f48e532edf -r 4736b915dee3 CMakeLists.txt
--- a/CMakeLists.txt	Fri Feb 25 11:30:11 2011 -0800
+++ b/CMakeLists.txt	Fri Feb 25 13:04:51 2011 -0800
@@ -178,7 +178,7 @@
 endif(WIN32)
 
 # BUG: are there other Boost components we're using?
-find_package(Boost 1.45 COMPONENTS program_options thread iostreams unit_test_framework REQUIRED)
+find_package(Boost 1.45 COMPONENTS program_options thread iostreams filesystem system unit_test_framework REQUIRED)
 
 if(Boost_FOUND AND Boost_PROGRAM_OPTIONS_FOUND)
   include_directories(${Boost_INCLUDE_DIRS})
diff -r 97f48e532edf -r 4736b915dee3 include/libpc/LiblasWriter.hpp
--- a/include/libpc/LiblasWriter.hpp	Fri Feb 25 11:30:11 2011 -0800
+++ b/include/libpc/LiblasWriter.hpp	Fri Feb 25 13:04:51 2011 -0800
@@ -37,6 +37,12 @@
 
 #include "libpc/Writer.hpp"
 
+namespace liblas
+{
+    class Writer;
+}
+
+
 namespace libpc
 {
 
@@ -45,7 +51,7 @@
 public:
     LiblasWriter(Stage& prevStage, std::ostream&);
 
-    //void write();
+    ~LiblasWriter();
 
 protected:
     // this is called once before the loop with the writeBuffer calls
@@ -59,6 +65,7 @@
 
 private:
     std::ostream& m_ostream;
+    liblas::Writer* m_writer;
 
     LiblasWriter& operator=(const LiblasWriter&); // not implemented
     LiblasWriter(const LiblasWriter&); // not implemented
diff -r 97f48e532edf -r 4736b915dee3 src/Dimension.cpp
--- a/src/Dimension.cpp	Fri Feb 25 11:30:11 2011 -0800
+++ b/src/Dimension.cpp	Fri Feb 25 13:04:51 2011 -0800
@@ -371,16 +371,16 @@
 
 DimensionLayout::DimensionLayout(const Dimension& dimension)
     : m_dimension(dimension)
+    , m_byteOffset(0)
     , m_position(0)
-    , m_byteOffset(0)
 {
 }
 
 /// copy constructor
 DimensionLayout::DimensionLayout(DimensionLayout const& other) 
     : m_dimension(other.m_dimension)
+    , m_byteOffset(other.m_byteOffset)
     , m_position(other.m_position)
-    , m_byteOffset(other.m_byteOffset)
 {
 }
 
diff -r 97f48e532edf -r 4736b915dee3 src/LiblasReader.cpp
--- a/src/LiblasReader.cpp	Fri Feb 25 11:30:11 2011 -0800
+++ b/src/LiblasReader.cpp	Fri Feb 25 13:04:51 2011 -0800
@@ -45,10 +45,11 @@
 LiblasReader::LiblasReader(std::istream& istream)
     : Reader()
     , m_istream(istream)
+    , m_reader(NULL)
 {
     liblas::ReaderFactory f;
-    liblas::Reader rr = f.CreateWithStream(m_istream);
-    m_reader = new liblas::Reader(rr);
+    liblas::Reader reader = f.CreateWithStream(m_istream);
+    m_reader = new liblas::Reader(reader);
 
     const liblas::Header& extHeader = m_reader->GetHeader();
     
@@ -69,6 +70,7 @@
     return;
 }
 
+
 LiblasReader::~LiblasReader()
 {
     delete m_reader;
diff -r 97f48e532edf -r 4736b915dee3 src/LiblasWriter.cpp
--- a/src/LiblasWriter.cpp	Fri Feb 25 11:30:11 2011 -0800
+++ b/src/LiblasWriter.cpp	Fri Feb 25 13:04:51 2011 -0800
@@ -32,9 +32,12 @@
 * OF SUCH DAMAGE.
 ****************************************************************************/
 
+#include "libpc/LiblasWriter.hpp"
+
 #include <cassert>
 
-#include "libpc/LiblasWriter.hpp"
+#include <liblas/Writer.hpp>
+
 #include "libpc/LiblasHeader.hpp"
 
 namespace libpc
@@ -44,14 +47,39 @@
 LiblasWriter::LiblasWriter(Stage& prevStage, std::ostream& ostream)
     : Writer(prevStage)
     , m_ostream(ostream)
+    , m_writer(NULL)
 {
-    LiblasHeader* liblasHeader = new LiblasHeader;
-    setHeader(liblasHeader);
+    liblas::Header extHeader;
+    extHeader.SetCompressed(false);
+
+    m_writer = new liblas::Writer(m_ostream, extHeader);
+
+
+    // make our own header
+    LiblasHeader* myHeader = new LiblasHeader;
+    setHeader(myHeader);
+
+    //myHeader->setNumPoints( extHeader.GetPointRecordsCount() );
+
+    //const liblas::Bounds<double>& extBounds = extHeader.GetExtent();
+    //const Bounds<double> bounds(extBounds.minx(), extBounds.miny(), extBounds.minz(), extBounds.maxx(), extBounds.maxy(), extBounds.maxz());
+    //myHeader->setBounds(bounds);
+
+    //Schema& schema = myHeader->getSchema();
+    //schema.addDimension(Dimension(Dimension::Field_X, Dimension::Double));
+    //schema.addDimension(Dimension(Dimension::Field_Y, Dimension::Double));
+    //schema.addDimension(Dimension(Dimension::Field_Z, Dimension::Double));
 
     return;
 }
 
 
+LiblasWriter::~LiblasWriter()
+{
+    delete m_writer;
+}
+
+
 void LiblasWriter::writeBegin()
 {
     return;
@@ -64,9 +92,33 @@
 }
 
 
-boost::uint32_t LiblasWriter::writeBuffer(const PointData&)
+boost::uint32_t LiblasWriter::writeBuffer(const PointData& pointData)
 {
-    return 0;
+    boost::uint32_t numPoints = pointData.getNumPoints();
+    boost::uint32_t i = 0;
+
+    const std::size_t indexX = pointData.getDimensionIndex(Dimension::Field_X);
+    const std::size_t indexY = pointData.getDimensionIndex(Dimension::Field_Y);
+    const std::size_t indexZ = pointData.getDimensionIndex(Dimension::Field_Z);
+    const std::size_t indexT = pointData.getDimensionIndex(Dimension::Field_Time);
+
+    liblas::Point pt;
+
+    for (i=0; i<numPoints; i++)
+    {
+        const double x = pointData.getField<float>(i, indexX);
+        const double y = pointData.getField<float>(i, indexY);
+        const double z = pointData.getField<float>(i, indexZ);
+        const boost::uint64_t t = pointData.getField<boost::uint64_t>(i, indexT);
+
+        pt.SetCoordinates(x,y,z);
+        pt.SetTime((double)t);
+
+        bool ok = m_writer->WritePoint(pt);
+        assert(ok);
+    }
+
+    return numPoints;
 }
 
 } // namespace libpc
diff -r 97f48e532edf -r 4736b915dee3 test/data/simple.las
Binary file test/data/simple.las has changed
diff -r 97f48e532edf -r 4736b915dee3 test/unit/BoundsTest.cpp
--- a/test/unit/BoundsTest.cpp	Fri Feb 25 11:30:11 2011 -0800
+++ b/test/unit/BoundsTest.cpp	Fri Feb 25 13:04:51 2011 -0800
@@ -1,4 +1,6 @@
+#ifdef _MSC_VER
 #define BOOST_TEST_DYN_LINK
+#endif
 
 #include <boost/test/unit_test.hpp>
 
@@ -48,7 +50,7 @@
 
     Range<int> v1(1,3);
     Range<int> v2(2,4);
-    std::vector<Range<int>> rv;
+    std::vector< Range<int> > rv;
     rv.push_back(v1);
     rv.push_back(v2);
     Bounds<int> b3(rv);
diff -r 97f48e532edf -r 4736b915dee3 test/unit/CMakeLists.txt
--- a/test/unit/CMakeLists.txt	Fri Feb 25 11:30:11 2011 -0800
+++ b/test/unit/CMakeLists.txt	Fri Feb 25 13:04:51 2011 -0800
@@ -22,6 +22,8 @@
 	SchemaTest.cpp
 	UtilsTest.cpp
 	VectorTest.cpp
+    support.cpp
+    support.hpp
     main.cpp)
 
 INCLUDE_DIRECTORIES(
diff -r 97f48e532edf -r 4736b915dee3 test/unit/ColorTest.cpp
--- a/test/unit/ColorTest.cpp	Fri Feb 25 11:30:11 2011 -0800
+++ b/test/unit/ColorTest.cpp	Fri Feb 25 13:04:51 2011 -0800
@@ -1,4 +1,6 @@
+#ifdef _MSC_VER
 #define BOOST_TEST_DYN_LINK
+#endif
 
 #include <boost/test/unit_test.hpp>
 #include <boost/cstdint.hpp>
@@ -13,7 +15,7 @@
 {
     Color c0;
     Color c1(1,2,3);
-    boost::array<boost::uint16_t,3> a = {1,2,3};
+    boost::array<boost::uint16_t,3> a = {{1,2,3}};
     Color c2(a);
     Color c3(c2);
     Color c4 = c3;
diff -r 97f48e532edf -r 4736b915dee3 test/unit/CropFilterTest.cpp
--- a/test/unit/CropFilterTest.cpp	Fri Feb 25 11:30:11 2011 -0800
+++ b/test/unit/CropFilterTest.cpp	Fri Feb 25 13:04:51 2011 -0800
@@ -1,4 +1,6 @@
+#ifdef _MSC_VER
 #define BOOST_TEST_DYN_LINK
+#endif
 
 #include <boost/test/unit_test.hpp>
 #include <boost/cstdint.hpp>
diff -r 97f48e532edf -r 4736b915dee3 test/unit/LiblasReaderTest.cpp
--- a/test/unit/LiblasReaderTest.cpp	Fri Feb 25 11:30:11 2011 -0800
+++ b/test/unit/LiblasReaderTest.cpp	Fri Feb 25 13:04:51 2011 -0800
@@ -1,4 +1,6 @@
+#ifdef _MSC_VER
 #define BOOST_TEST_DYN_LINK
+#endif
 
 #include <boost/test/unit_test.hpp>
 #include <boost/cstdint.hpp>
@@ -15,7 +17,7 @@
 
 BOOST_AUTO_TEST_CASE(test_1)
 {
-    std::istream* ifs = Utils::openFile("test/data/1.2-with-color.las");
+    std::istream* ifs = Utils::openFile("../../test/data/1.2-with-color.las");
     
     LiblasReader reader(*ifs);
 
diff -r 97f48e532edf -r 4736b915dee3 test/unit/LiblasWriterTest.cpp
--- a/test/unit/LiblasWriterTest.cpp	Fri Feb 25 11:30:11 2011 -0800
+++ b/test/unit/LiblasWriterTest.cpp	Fri Feb 25 13:04:51 2011 -0800
@@ -1,4 +1,6 @@
+#ifdef _MSC_VER
 #define BOOST_TEST_DYN_LINK
+#endif
 
 #include <boost/test/unit_test.hpp>
 #include <boost/cstdint.hpp>
@@ -6,6 +8,8 @@
 #include "libpc/FauxReader.hpp"
 #include "libpc/LiblasWriter.hpp"
 
+#include "support.hpp"
+
 using namespace libpc;
 
 BOOST_AUTO_TEST_SUITE(LiblasWriterTest)
@@ -20,10 +24,16 @@
 
     std::ostream* ofs = Utils::createFile("temp.las");
 
-    LiblasWriter writer(reader, *ofs);
+    {
+        // need to scope the writer, so that's it dtor can use the stream
+        LiblasWriter writer(reader, *ofs);
+        writer.write(10);
+    }
 
     Utils::closeFile(ofs);
 


More information about the Liblas-commits mailing list