[Liblas-commits] hg-main-tree: add libxml2

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Apr 15 19:37:11 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/b1cc00985875
changeset: 584:b1cc00985875
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Apr 15 14:43:44 2011 -0700
description:
add libxml2
Subject: hg-main-tree: checkpoint -- turning on native las tests

details:   http://hg.libpc.orghg-main-tree/rev/fe9a2872cf46
changeset: 585:fe9a2872cf46
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Apr 15 15:44:39 2011 -0700
description:
checkpoint -- turning on native las tests
Subject: hg-main-tree: checkpoint - native las drivers almost to partiy with liblas drivers

details:   http://hg.libpc.orghg-main-tree/rev/3cd8e2af373a
changeset: 586:3cd8e2af373a
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Apr 15 16:36:12 2011 -0700
description:
checkpoint - native las drivers almost to partiy with liblas drivers
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/e3718039465f
changeset: 587:e3718039465f
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Apr 15 16:36:50 2011 -0700
description:
merge

diffstat:

 include/libpc/drivers/las/Header.hpp      |    4 +-
 include/libpc/drivers/las/Reader.hpp      |    7 +-
 include/libpc/drivers/las/SummaryData.hpp |    4 +-
 include/libpc/drivers/las/Writer.hpp      |   18 +
 include/libpc/drivers/oci/Common.hpp      |   11 +-
 include/libpc/drivers/oci/Schema.hpp      |   14 +-
 mpg-config.bat                            |    5 +
 src/Utils.cpp                             |    4 +-
 src/drivers/las/Iterator.cpp              |   14 +-
 src/drivers/las/LasHeaderReader.cpp       |   20 +-
 src/drivers/las/Reader.cpp                |   28 +-
 src/drivers/las/SummaryData.cpp           |    2 +-
 src/drivers/las/Writer.cpp                |  112 +++++--
 src/drivers/oci/Reader.cpp                |   30 ++-
 src/drivers/oci/Schema.cpp                |   49 +++-
 src/drivers/oci/common.cpp                |   20 +
 test/unit/CMakeLists.txt                  |    2 +
 test/unit/LasReaderTest.cpp               |  428 ++++++++++++++++++++++++++++++
 test/unit/LasWriterTest.cpp               |  187 +++++++++++++
 test/unit/OCITest.cpp                     |  180 ++++++++----
 20 files changed, 1016 insertions(+), 123 deletions(-)

diffs (truncated from 1533 to 300 lines):

diff -r a21269125167 -r e3718039465f include/libpc/drivers/las/Header.hpp
--- a/include/libpc/drivers/las/Header.hpp	Fri Apr 15 14:14:28 2011 -0700
+++ b/include/libpc/drivers/las/Header.hpp	Fri Apr 15 16:36:50 2011 -0700
@@ -226,10 +226,10 @@
     void SetRecordsCount(boost::uint32_t v);
     
     /// Get identifier of point data (record) format.
-    libpc::drivers::las::PointFormat getPointFormat() const;
+    PointFormat getPointFormat() const;
 
     /// Set identifier of point data (record) format.
-    void setPointFormat(libpc::drivers::las::PointFormat v);
+    void setPointFormat(PointFormat v);
 
     /// The length in bytes of each point.  All points in the file are 
     /// considered to be fixed in size, and the PointFormatName is used 
diff -r a21269125167 -r e3718039465f include/libpc/drivers/las/Reader.hpp
--- a/include/libpc/drivers/las/Reader.hpp	Fri Apr 15 14:14:28 2011 -0700
+++ b/include/libpc/drivers/las/Reader.hpp	Fri Apr 15 16:36:50 2011 -0700
@@ -73,9 +73,14 @@
     // this is called by the stage's iterator
     boost::uint32_t processBuffer(PointBuffer& PointBuffer, std::istream& stream) const;
 
-    const LasHeader& getLasHeader() const { return m_lasHeader; }
+    PointFormat getPointFormat() const;
+    boost::uint8_t getVersionMajor() const;
+    boost::uint8_t getVersionMinor() const;
+
+    boost::uint64_t getPointDataOffset() const;
 
 protected:
+    const LasHeader& getLasHeader() const { return m_lasHeader; }
     LasHeader& getLasHeaderRef() { return m_lasHeader; }
 
 private:
diff -r a21269125167 -r e3718039465f include/libpc/drivers/las/SummaryData.hpp
--- a/include/libpc/drivers/las/SummaryData.hpp	Fri Apr 15 14:14:28 2011 -0700
+++ b/include/libpc/drivers/las/SummaryData.hpp	Fri Apr 15 16:36:50 2011 -0700
@@ -49,14 +49,14 @@
 
     void reset();
 
-    // note that returnNumber is in the range [1..5]
+    // note that returnNumber is in the range [0..4]
     void addPoint(double x, double y, double z, int returnNumber);
 
     boost::uint32_t getTotalNumPoints() const;
 
     void getBounds(double& minX, double& minY, double& minZ, double& maxX, double& maxY, double& maxZ) const;
 
-    // note that returnNumber is in the range [1..5]
+    // note that returnNumber is in the range [0..4]
     boost::uint32_t getReturnCount(int returnNumber) const;
 
     void dump(std::ostream&) const;
diff -r a21269125167 -r e3718039465f include/libpc/drivers/las/Writer.hpp
--- a/include/libpc/drivers/las/Writer.hpp	Fri Apr 15 14:14:28 2011 -0700
+++ b/include/libpc/drivers/las/Writer.hpp	Fri Apr 15 16:36:50 2011 -0700
@@ -39,6 +39,7 @@
 
 #include <libpc/Writer.hpp>
 #include <libpc/drivers/las/Header.hpp>
+#include <libpc/drivers/las/SummaryData.hpp>
 
 namespace libpc { namespace drivers { namespace las {
 
@@ -50,6 +51,21 @@
 
     const std::string& getName() const;
 
+    void setFormatVersion(boost::uint8_t majorVersion, boost::uint8_t minorVersion);
+    void setPointFormat(PointFormat);
+    void setDate(boost::uint16_t dayOfYear, boost::uint16_t year);
+    
+    void setProjectId(const boost::uuids::uuid&);
+
+    // up to 32 chars (default is "libPC")
+    void setSystemIdentifier(const std::string& systemId); 
+    
+    // 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();
@@ -64,6 +80,8 @@
     std::ostream& m_ostream;
     LasHeader m_lasHeader;
     boost::uint32_t m_numPointsWritten;
+    bool m_isCompressed;
+    SummaryData m_summaryData;
 
     LasWriter& operator=(const LasWriter&); // not implemented
     LasWriter(const LasWriter&); // not implemented
diff -r a21269125167 -r e3718039465f include/libpc/drivers/oci/Common.hpp
--- a/include/libpc/drivers/oci/Common.hpp	Fri Apr 15 14:14:28 2011 -0700
+++ b/include/libpc/drivers/oci/Common.hpp	Fri Apr 15 16:36:50 2011 -0700
@@ -60,7 +60,7 @@
 typedef boost::shared_ptr<OWStatement> Statement ;
 
 
-// use this for code still under development
+
 class connection_failed : public libpc_error
 {
 public:
@@ -69,7 +69,6 @@
     {}
 };
 
-// use this for code still under development
 class buffer_too_small : public libpc_error
 {
 public:
@@ -78,6 +77,14 @@
     {}
 };
 
+class schema_error : public libpc_error
+{
+public:
+    schema_error(std::string const& msg)
+        : libpc_error(msg)
+    {}
+};
+
 
 #ifdef LIBPC_COMPILER_MSVC
 #define compare_no_case(a,b,n)  _strnicmp( (a), (b), (n) )
diff -r a21269125167 -r e3718039465f include/libpc/drivers/oci/Schema.hpp
--- a/include/libpc/drivers/oci/Schema.hpp	Fri Apr 15 14:14:28 2011 -0700
+++ b/include/libpc/drivers/oci/Schema.hpp	Fri Apr 15 16:36:50 2011 -0700
@@ -41,19 +41,26 @@
 #include <libpc/drivers/oci/Reader.hpp>
 
 #include <string>
+#include <stdarg.h>
 
 #include <libxml/parser.h>
 #include <libxml/xmlschemas.h>
 
-
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xinclude.h>
+#include <libxml/xmlIO.h>
 
 namespace libpc { namespace drivers { namespace oci {
 
 
+void OCISchemaGenericErrorHandler (void * ctx, const char* message, ...);
+void OCISchemaStructuredErrorHandler (void * userData, xmlErrorPtr error);
+
 class Schema
 {
 public:
-    Schema();
+    Schema(std::string xml, std::string xmlschema);
     ~Schema();
 
 
@@ -62,6 +69,9 @@
     Schema& operator=(const Schema&); // not implemented
     Schema(const Schema&); // not implemented;
     
+    xmlDocPtr m_doc;
+    xmlDocPtr m_schema;
+    
 
 };
 
diff -r a21269125167 -r e3718039465f mpg-config.bat
--- a/mpg-config.bat	Fri Apr 15 14:14:28 2011 -0700
+++ b/mpg-config.bat	Fri Apr 15 16:36:50 2011 -0700
@@ -15,6 +15,8 @@
 set FREEGLUT_DIR=d:\dev\freeglut-2.6.0-3.mp
 set GLUT_DIR=d:\dev\freeglut-2.6.0-3.mp
 
+set LIBXML2_DIR=C:\Utils\libxml2-2.7.7.win32
+
 set BUILD_TYPE=Release
 set BUILD_TYPE=Debug
 
@@ -26,6 +28,9 @@
     -DWITH_LASZIP=ON ^
     -DWITH_LIBLAS=ON ^
     -DWITH_FREEGLUT=ON ^
+    -DWITH_LIBXML2=ON ^
+    -DLIBXML2_LIBRARIES=%LIBXML2_DIR%\lib\libxml2.lib ^
+    -DLIBXML2_INCLUDE_DIR=%LIBXML2_DIR%\include ^
     -DFREEGLUT_LIBRARY=%FREEGLUT_DIR%\lib\freeglut.lib ^
     -DFREEGLUT_INCLUDE_DIR=%FREEGLUT_DIR%\include ^
     -DGLUT_LIBRARY=%FREEGLUT_DIR%\lib ^
diff -r a21269125167 -r e3718039465f src/Utils.cpp
--- a/src/Utils.cpp	Fri Apr 15 14:14:28 2011 -0700
+++ b/src/Utils.cpp	Fri Apr 15 16:36:50 2011 -0700
@@ -79,7 +79,7 @@
     if (!Utils::fileExists(filename))
         throw libpc_error("File not found: " + filename);
 
-    std::ios::openmode mode = std::ios::out;
+    std::ios::openmode mode = std::ios::in;
     if (asBinary)
       mode |= std::ios::binary;
 
@@ -93,7 +93,7 @@
 
 std::ostream* Utils::createFile(std::string const& filename, bool asBinary)
 {
-    std::ios::openmode mode = std::ios::in;
+    std::ios::openmode mode = std::ios::out;
     if (asBinary)
       mode  |= std::ios::binary;
 
diff -r a21269125167 -r e3718039465f src/drivers/las/Iterator.cpp
--- a/src/drivers/las/Iterator.cpp	Fri Apr 15 14:14:28 2011 -0700
+++ b/src/drivers/las/Iterator.cpp	Fri Apr 15 16:36:50 2011 -0700
@@ -34,6 +34,8 @@
 
 #include <libpc/drivers/las/Iterator.hpp>
 
+#include <iostream>
+
 #include <libpc/drivers/las/Reader.hpp>
 #include <libpc/exceptions.hpp>
 #include <libpc/Utils.hpp>
@@ -48,6 +50,7 @@
     , m_istream(NULL)
 {
     m_istream = Utils::openFile(m_reader.getFileName());
+    m_istream->seekg(m_reader.getPointDataOffset());
     return;
 }
 
@@ -61,7 +64,9 @@
 
 boost::uint64_t SequentialIterator::skipImpl(boost::uint64_t count)
 {
-    return naiveSkipImpl(count);
+    boost::uint64_t delta = Support::getPointDataSize(m_reader.getPointFormat());
+    m_istream->seekg(delta * count, std::ios::cur);
+    return count;
 }
 
 
@@ -84,6 +89,7 @@
     , m_istream(NULL)
 {
     m_istream = Utils::openFile(m_reader.getFileName());
+    m_istream->seekg(m_reader.getPointDataOffset());
     return;
 }
 
@@ -95,9 +101,11 @@
 }
 
 
-boost::uint64_t RandomIterator::seekImpl(boost::uint64_t)
+boost::uint64_t RandomIterator::seekImpl(boost::uint64_t count)
 {
-    throw not_yet_implemented("LasReader seeking not supported yet");
+    boost::uint64_t delta = Support::getPointDataSize(m_reader.getPointFormat());
+    m_istream->seekg(m_reader.getPointDataOffset() + delta * count);
+    return count;
 }
 
 
diff -r a21269125167 -r e3718039465f src/drivers/las/LasHeaderReader.cpp
--- a/src/drivers/las/LasHeaderReader.cpp	Fri Apr 15 14:14:28 2011 -0700
+++ b/src/drivers/las/LasHeaderReader.cpp	Fri Apr 15 16:36:50 2011 -0700
@@ -212,16 +212,20 @@
     }  
 
     // 21-23. Scale factors
-    Utils::read_n(x1, m_istream, sizeof(x1));
-    Utils::read_n(y1, m_istream, sizeof(y1));
-    Utils::read_n(z1, m_istream, sizeof(z1));
-    m_header.SetScale(x1, y1, z1);
+    double xScale, yScale, zScale;
+    Utils::read_n(xScale, m_istream, sizeof(xScale));
+    Utils::read_n(yScale, m_istream, sizeof(yScale));
+    Utils::read_n(zScale, m_istream, sizeof(zScale));
+    m_header.SetScale(xScale, yScale, zScale);
 
     // 24-26. Offsets
-    Utils::read_n(x1, m_istream, sizeof(x1));
-    Utils::read_n(y1, m_istream, sizeof(y1));
-    Utils::read_n(z1, m_istream, sizeof(z1));
-    m_header.SetOffset(x1, y1, z1);
+    double xOffset, yOffset, zOffset;
+    Utils::read_n(xOffset, m_istream, sizeof(xOffset));
+    Utils::read_n(yOffset, m_istream, sizeof(yOffset));
+    Utils::read_n(zOffset, m_istream, sizeof(zOffset));
+    m_header.SetOffset(xOffset, yOffset, zOffset);
+
+    Support::setScaling(schema, xScale, yScale, zScale, xOffset, yOffset, zOffset);
 


More information about the Liblas-commits mailing list