[Liblas-commits] hg-main-tree: push the XML schema stuff up into a more public area

liblas-commits at liblas.org liblas-commits at liblas.org
Thu May 12 15:38:58 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/3a1f587526b6
changeset: 720:3a1f587526b6
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu May 12 14:01:37 2011 -0500
description:
push the XML schema stuff up into a more public area
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/47f1757b7ba8
changeset: 721:47f1757b7ba8
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu May 12 14:01:47 2011 -0500
description:
merge

diffstat:

 include/libpc/Schema.hpp               |    3 +
 include/libpc/XMLSchema.hpp            |  161 ++++++++
 include/libpc/drivers/las/Iterator.hpp |   38 +-
 include/libpc/drivers/las/Reader.hpp   |    6 +-
 include/libpc/drivers/las/Writer.hpp   |    2 +
 include/libpc/drivers/oci/Common.hpp   |   31 -
 include/libpc/drivers/oci/Schema.hpp   |  126 ------
 src/CMakeLists.txt                     |   12 +-
 src/Schema.cpp                         |    4 +
 src/XMLSchema.cpp                      |  595 +++++++++++++++++++++++++++++++++
 src/drivers/las/Iterator.cpp           |  143 +++++++-
 src/drivers/las/LasHeaderWriter.cpp    |    4 +-
 src/drivers/las/Reader.cpp             |   41 ++-
 src/drivers/las/Writer.cpp             |  107 ++++-
 src/drivers/las/ZipPoint.cpp           |  160 ++++----
 src/drivers/las/ZipPoint.hpp           |   11 +-
 src/drivers/oci/Schema.cpp             |  595 ---------------------------------
 test/data/1.2-with-color.laz           |    0 
 test/data/simple.laz                   |    0 
 test/unit/CMakeLists.txt               |    1 +
 test/unit/LasReaderTest.cpp            |   48 ++
 test/unit/LasWriterTest.cpp            |    2 +-
 test/unit/LiblasReaderTest.cpp         |   47 ++
 test/unit/LiblasWriterTest.cpp         |    2 +-
 test/unit/OCITest.cpp                  |   38 --
 test/unit/QFITReaderTest.cpp           |    2 +
 test/unit/Support.cpp                  |    7 +-
 test/unit/TerraSolidTest.cpp           |    3 +-
 test/unit/XMLSchemaTest.cpp            |  119 ++++++
 29 files changed, 1369 insertions(+), 939 deletions(-)

diffs (truncated from 2864 to 300 lines):

diff -r 9f91166cbf42 -r 47f1757b7ba8 include/libpc/Schema.hpp
--- a/include/libpc/Schema.hpp	Wed May 11 12:05:38 2011 -0500
+++ b/include/libpc/Schema.hpp	Thu May 12 14:01:47 2011 -0500
@@ -93,6 +93,9 @@
     boost::property_tree::ptree getPTree() const;
 
     void dump() const;
+    
+    static Schema from_xml(std::istream* stream);
+    static std::ostream* to_xml(Schema const& schema);
 
 private:
     std::vector<Dimension> m_dimensions;
diff -r 9f91166cbf42 -r 47f1757b7ba8 include/libpc/XMLSchema.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/XMLSchema.hpp	Thu May 12 14:01:47 2011 -0500
@@ -0,0 +1,161 @@
+/******************************************************************************
+* Copyright (c) 2011, Howard Butler, hobu.inc at gmail.com
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following
+* conditions are met:
+*
+*     * Redistributions of source code must retain the above copyright
+*       notice, this list of conditions and the following disclaimer.
+*     * Redistributions in binary form must reproduce the above copyright
+*       notice, this list of conditions and the following disclaimer in
+*       the documentation and/or other materials provided
+*       with the distribution.
+*     * Neither the name of Hobu, Inc. or Flaxen Geo Consulting nor the
+*       names of its contributors may be used to endorse or promote
+*       products derived from this software without specific prior
+*       written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+* OF SUCH DAMAGE.
+****************************************************************************/
+
+#ifndef INCLUDED_XMLSCHEMA_HPP
+#define INCLUDED_XMLSCHEMA_HPP
+
+#include <libpc/libpc.hpp>
+#include <libpc/Schema.hpp>
+#include <libpc/SchemaLayout.hpp>
+#include <libpc/Dimension.hpp>
+#include <libpc/DimensionLayout.hpp>
+
+#include <libpc/drivers/oci/Common.hpp>
+#include <libpc/drivers/oci/Reader.hpp>
+
+#include <string>
+#include <stdarg.h>
+#include <functional>
+
+#include <libxml/parser.h>
+#include <libxml/xmlschemas.h>
+
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xinclude.h>
+#include <libxml/xmlIO.h>
+#include <libxml/encoding.h>
+#include <libxml/xmlwriter.h>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/function.hpp>
+
+namespace libpc { 
+
+
+void OCISchemaGenericErrorHandler (void * ctx, const char* message, ...);
+void OCISchemaStructuredErrorHandler (void * userData, xmlErrorPtr error);
+
+class schema_error : public libpc_error
+{
+public:
+    schema_error(std::string const& msg)
+        : libpc_error(msg)
+    {}
+};
+
+
+
+class schema_validation_error : public libpc_error
+{
+public:
+    schema_validation_error(std::string const& msg)
+        : libpc_error(msg)
+    {}
+};
+
+class schema_parsing_error : public libpc_error
+{
+public:
+    schema_parsing_error(std::string const& msg)
+        : libpc_error(msg)
+    {}
+};
+
+class schema_generic_error : public libpc_error
+{
+public:
+    schema_generic_error(std::string const& msg)
+        : libpc_error(msg)
+    {}
+};
+
+
+class LIBPC_DLL XMLSchema
+{
+public:
+    XMLSchema(std::string const& xml, std::string const& xmlschema);
+    ~XMLSchema();
+
+
+
+protected:
+
+    void LoadSchema();
+    Dimension::DataType GetDimensionType(std::string const& interpretation);
+    Dimension::Field GetDimensionField(std::string const& name, boost::uint32_t position);
+    
+private:
+    
+    XMLSchema& operator=(const XMLSchema&); // not implemented
+    XMLSchema(const XMLSchema&); // not implemented;
+
+
+    
+    // We're going to put all of our libxml2 primatives into shared_ptrs 
+    // that have custom deleters that clean up after themselves so we 
+    // have a good chance at having clean exception-safe code    
+    typedef boost::shared_ptr<void> DocPtr;
+    typedef boost::shared_ptr<void> SchemaParserCtxtPtr;    
+    typedef boost::shared_ptr<void> SchemaPtr;
+    typedef boost::shared_ptr<void> SchemaValidCtxtPtr;
+    typedef boost::shared_ptr<void> TextWriterPtr;
+
+    TextWriterPtr writeHeader(DocPtr doc);
+
+
+    DocPtr m_doc;
+    DocPtr m_schema_doc;
+    
+    SchemaParserCtxtPtr m_schema_parser_ctx;
+    SchemaPtr m_schema_ptr;
+    SchemaValidCtxtPtr m_schema_valid_ctx;
+    
+    xmlParserOption m_doc_options;
+
+    
+    void* m_global_context;
+    libpc::Schema m_schema;
+    
+    
+    
+
+};
+
+
+
+} // namespaces
+
+#endif
diff -r 9f91166cbf42 -r 47f1757b7ba8 include/libpc/drivers/las/Iterator.hpp
--- a/include/libpc/drivers/las/Iterator.hpp	Wed May 11 12:05:38 2011 -0500
+++ b/include/libpc/drivers/las/Iterator.hpp	Thu May 12 14:01:47 2011 -0500
@@ -40,12 +40,40 @@
 #include <libpc/Iterator.hpp>
 #include <iosfwd>
 
+class LASzip;
+class LASunzipper;
 
 namespace libpc { namespace drivers { namespace las {
 
 class LasReader;
+class ZipPoint;
 
-class SequentialIterator : public libpc::SequentialIterator
+
+class IteratorBase
+{
+public:
+    IteratorBase(const LasReader& reader);
+    ~IteratorBase();
+
+private:
+    void initializeZip();
+
+protected:
+    const LasReader& m_reader;
+    std::istream* m_istream;
+
+public:
+    LASzip* m_zip;
+    LASunzipper* m_unzipper;
+    ZipPoint* m_zipPoint;
+
+private:
+    IteratorBase& operator=(const IteratorBase&); // not implemented
+    IteratorBase(const IteratorBase&); // not implemented
+};
+
+
+class SequentialIterator : public IteratorBase, public libpc::SequentialIterator
 {
 public:
     SequentialIterator(const LasReader& reader);
@@ -55,13 +83,10 @@
     boost::uint64_t skipImpl(boost::uint64_t);
     boost::uint32_t readImpl(PointBuffer&);
     bool atEndImpl() const;
-
-    const LasReader& m_reader;
-    std::istream* m_istream;
 };
 
 
-class RandomIterator : public libpc::RandomIterator
+class RandomIterator : public IteratorBase, public libpc::RandomIterator
 {
 public:
     RandomIterator(const LasReader& reader);
@@ -70,9 +95,6 @@
 private:
     boost::uint64_t seekImpl(boost::uint64_t);
     boost::uint32_t readImpl(PointBuffer&);
-
-    const LasReader& m_reader;
-    std::istream* m_istream;
 };
 
 } } } // namespaces
diff -r 9f91166cbf42 -r 47f1757b7ba8 include/libpc/drivers/las/Reader.hpp
--- a/include/libpc/drivers/las/Reader.hpp	Wed May 11 12:05:38 2011 -0500
+++ b/include/libpc/drivers/las/Reader.hpp	Thu May 12 14:01:47 2011 -0500
@@ -41,6 +41,7 @@
 #include <libpc/drivers/las/Header.hpp>
 #include <libpc/drivers/las/ReaderBase.hpp>
 
+class LASunzipper;
 
 namespace libpc
 {
@@ -50,6 +51,7 @@
 namespace libpc { namespace drivers { namespace las {
 
 class LasHeader;
+class ZipPoint;
 
 class LIBPC_DLL LasReader : public LasReaderBase
 {
@@ -73,7 +75,7 @@
     libpc::RandomIterator* createRandomIterator() const;
 
     // this is called by the stage's iterator
-    boost::uint32_t processBuffer(PointBuffer& PointBuffer, std::istream& stream, boost::uint64_t numPointsLeft) const;
+    boost::uint32_t processBuffer(PointBuffer& PointBuffer, std::istream& stream, boost::uint64_t numPointsLeft, LASunzipper* unzipper, ZipPoint* zipPoint) const;
 
     int getMetadataRecordCount() const;
     const MetadataRecord& getMetadataRecord(int index) const;
@@ -87,6 +89,8 @@
     // we shouldn't have to expose this
     const std::vector<VariableLengthRecord>& getVLRs() const;
 
+    bool isCompressed() const;
+
 protected:
     const LasHeader& getLasHeader() const { return m_lasHeader; }
     LasHeader& getLasHeaderRef() { return m_lasHeader; }
diff -r 9f91166cbf42 -r 47f1757b7ba8 include/libpc/drivers/las/Writer.hpp
--- a/include/libpc/drivers/las/Writer.hpp	Wed May 11 12:05:38 2011 -0500
+++ b/include/libpc/drivers/las/Writer.hpp	Thu May 12 14:01:47 2011 -0500
@@ -42,6 +42,7 @@
 #include <libpc/drivers/las/SummaryData.hpp>
 
 // liblaszip
+class LASzip;
 class LASzipper;
 
 namespace libpc { namespace drivers { namespace las {
@@ -90,6 +91,7 @@
     boost::uint32_t m_numPointsWritten;
     bool m_isCompressed;
     SummaryData m_summaryData;


More information about the Liblas-commits mailing list