[Liblas-commits] hg-main-tree: tweak logic for ByteSwapFilter to do something spe...

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Jun 6 16:47:43 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/e444762e1822
changeset: 749:e444762e1822
user:      Howard Butler <hobu.inc at gmail.com>
date:      Mon Jun 06 15:40:07 2011 -0500
description:
tweak logic for ByteSwapFilter to do something special when a chipper is in front of it.  I'm going to add another mode to the SequentialFilter to have it control the returned buffer size in addition to the fill-the-buffer-all-the-way-up mode
Subject: hg-main-tree: It is possible to use the XML without validation. If dimensions do not have a name, just start ticking them off from the first user-defined dimension number

details:   http://hg.libpc.orghg-main-tree/rev/8eeb37da1452
changeset: 750:8eeb37da1452
user:      Howard Butler <hobu.inc at gmail.com>
date:      Mon Jun 06 15:41:04 2011 -0500
description:
It is possible to use the XML without validation. If dimensions do not have a name, just start ticking them off from the first user-defined dimension number
Subject: hg-main-tree: add a setAllData method to allow the user to copy in an array of data directly

details:   http://hg.libpc.orghg-main-tree/rev/9bce14ec0e8a
changeset: 751:9bce14ec0e8a
user:      Howard Butler <hobu.inc at gmail.com>
date:      Mon Jun 06 15:41:59 2011 -0500
description:
add a setAllData method to allow the user to copy in an array of data directly
Subject: hg-main-tree: It is possible to use the XML without validation. If dimensions do not have a name, just start ticking them off from the first user-defined dimension number

details:   http://hg.libpc.orghg-main-tree/rev/b15603667d4e
changeset: 752:b15603667d4e
user:      Howard Butler <hobu.inc at gmail.com>
date:      Mon Jun 06 15:42:19 2011 -0500
description:
It is possible to use the XML without validation. If dimensions do not have a name, just start ticking them off from the first user-defined dimension number
Subject: hg-main-tree: as a stage, the chipper has an unknown but fixed point count.  This could be made smarter in the future to know what the point count is based on the previous stage, however

details:   http://hg.libpc.orghg-main-tree/rev/3ee1bdf5eb7c
changeset: 753:3ee1bdf5eb7c
user:      Howard Butler <hobu.inc at gmail.com>
date:      Mon Jun 06 15:45:19 2011 -0500
description:
as a stage, the chipper has an unknown but fixed point count.  This could be made smarter in the future to know what the point count is based on the previous stage, however
Subject: hg-main-tree: make the oracle reader/writer use the ByteSwapFilter

details:   http://hg.libpc.orghg-main-tree/rev/950d77aa8188
changeset: 754:950d77aa8188
user:      Howard Butler <hobu.inc at gmail.com>
date:      Mon Jun 06 15:46:57 2011 -0500
description:
make the oracle reader/writer use the ByteSwapFilter
Subject: hg-main-tree: mostly working full service reader/writer for Oracle

details:   http://hg.libpc.orghg-main-tree/rev/41bdc454e090
changeset: 755:41bdc454e090
user:      Howard Butler <hobu.inc at gmail.com>
date:      Mon Jun 06 15:47:23 2011 -0500
description:
mostly working full service reader/writer for Oracle

diffstat:

 apps/pc2pc.cpp                         |   10 +-
 include/libpc/PointBuffer.hpp          |    2 +
 include/libpc/XMLSchema.hpp            |    2 +
 include/libpc/drivers/oci/Common.hpp   |   19 +--
 include/libpc/drivers/oci/Iterator.hpp |    2 +
 include/libpc/drivers/oci/Reader.hpp   |    9 +-
 include/libpc/filters/Chipper.hpp      |    5 +-
 src/PointBuffer.cpp                    |    4 +
 src/XMLSchema.cpp                      |   76 +++++++++--------
 src/drivers/oci/Iterator.cpp           |  133 ++++++++++++++++++++++++++------
 src/drivers/oci/Reader.cpp             |  103 +++++++++++++++++++++---
 src/drivers/oci/Writer.cpp             |   26 ++---
 src/drivers/oci/common.cpp             |   14 +--
 src/filters/ByteSwapFilterIterator.cpp |   32 ++++++-
 14 files changed, 302 insertions(+), 135 deletions(-)

diffs (truncated from 801 to 300 lines):

diff -r b537b4c8ab21 -r 41bdc454e090 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Thu May 26 13:15:52 2011 -0500
+++ b/apps/pc2pc.cpp	Mon Jun 06 15:47:23 2011 -0500
@@ -182,15 +182,11 @@
         libpc::Options options(oracle_options);
 
         libpc::drivers::oci::Reader reader(options);
-
+        libpc::filters::ByteSwapFilter swapper(reader);
         const boost::uint64_t numPoints = reader.getNumPoints();
-
-        libpc::filters::ByteSwapFilter swapper(reader);
-
-
-
         libpc::drivers::las::LasWriter writer(swapper, *ofs);
-
+        
+        writer.setChunkSize(options.GetPTree().get<boost::uint32_t>("capacity"));
 
         if (hasOption("a_srs"))
         {
diff -r b537b4c8ab21 -r 41bdc454e090 include/libpc/PointBuffer.hpp
--- a/include/libpc/PointBuffer.hpp	Thu May 26 13:15:52 2011 -0500
+++ b/include/libpc/PointBuffer.hpp	Mon Jun 06 15:47:23 2011 -0500
@@ -161,6 +161,8 @@
     
     // copy in raw data
     void setData(boost::uint8_t* data, std::size_t pointIndex);
+    
+    void setAllData(boost::uint8_t* data, boost::uint32_t byteCount);
 
     // access to the raw memory
     void getData(boost::uint8_t** data, std::size_t* array_size) const;
diff -r b537b4c8ab21 -r 41bdc454e090 include/libpc/XMLSchema.hpp
--- a/include/libpc/XMLSchema.hpp	Thu May 26 13:15:52 2011 -0500
+++ b/include/libpc/XMLSchema.hpp	Mon Jun 06 15:47:23 2011 -0500
@@ -169,6 +169,8 @@
     std::string m_xml;
     std::string m_xsd;
     
+    boost::uint32_t m_field_position;
+    
     
 
 };
diff -r b537b4c8ab21 -r 41bdc454e090 include/libpc/drivers/oci/Common.hpp
--- a/include/libpc/drivers/oci/Common.hpp	Thu May 26 13:15:52 2011 -0500
+++ b/include/libpc/drivers/oci/Common.hpp	Mon Jun 06 15:47:23 2011 -0500
@@ -44,7 +44,9 @@
 
 #include <boost/shared_ptr.hpp>
 #include <boost/scoped_ptr.hpp>
+#include <boost/tokenizer.hpp>
 
+typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
 
 #include <cpl_port.h>
 
@@ -130,19 +132,12 @@
     Cloud(Connection connection);
     ~Cloud();
     
-    OCIString* base_table;
-    OCIString* base_column;
-    OCINumber pc_id;
-    OCIString* blk_table;
-    OCIString* ptn_params;
+    std::string base_table;
+    std::string base_column;
+    boost::int32_t pc_id;
+    std::string blk_table;
     sdo_geometry* pc_geometry;
-    OCINumber pc_tol;
-    OCINumber pc_tot_dimensions;
-    sdo_orgscl_type* pc_domain;
-    OCIString* pc_val_attr_tables;
-    boost::scoped_ptr<std::vector<uint8_t> > schema;
-    OCILobLocator           *locator;
-    Connection              m_connection;
+    Connection              connection;
         
 };
 typedef boost::shared_ptr<Cloud> CloudPtr;
diff -r b537b4c8ab21 -r 41bdc454e090 include/libpc/drivers/oci/Iterator.hpp
--- a/include/libpc/drivers/oci/Iterator.hpp	Thu May 26 13:15:52 2011 -0500
+++ b/include/libpc/drivers/oci/Iterator.hpp	Mon Jun 06 15:47:23 2011 -0500
@@ -58,10 +58,12 @@
     
     boost::uint32_t readBuffer(PointBuffer& data);
     boost::uint32_t unpackOracleData(PointBuffer& data);
+    BlockPtr defineBlock(Statement statement);
 
     Statement m_statement;
     bool m_at_end;
     QueryType m_querytype;
+    CloudPtr m_cloud;
     BlockPtr m_block;
 
 
diff -r b537b4c8ab21 -r 41bdc454e090 include/libpc/drivers/oci/Reader.hpp
--- a/include/libpc/drivers/oci/Reader.hpp	Thu May 26 13:15:52 2011 -0500
+++ b/include/libpc/drivers/oci/Reader.hpp	Mon Jun 06 15:47:23 2011 -0500
@@ -72,7 +72,7 @@
     Connection getConnection () const { return m_connection;}
     Statement getStatement () const { return m_statement;}
     Options& getOptions() const { return m_options; }
-    BlockPtr getBlock() const { return m_block; }
+    CloudPtr getCloud() const;
     std::string getQuery() const;
     bool isVerbose() const;
     bool isDebug() const;
@@ -88,17 +88,16 @@
     void fetchPCFields();
     QueryType describeQueryType() const;    
     BlockPtr defineBlock() const;
-    CloudPtr defineCloud();
+    Schema fetchSchema(sdo_pc* pc);
 
     Options& m_options;
     Connection m_connection;
     Statement m_statement;
     QueryType m_querytype;
-    BlockPtr m_block;
-    CloudPtr m_cloud;
+    // BlockPtr m_block;
+    Schema m_schema;
     sdo_pc* m_pc;
 
-
 };
 
 }}} // namespace libpc::driver::oci
diff -r b537b4c8ab21 -r 41bdc454e090 include/libpc/filters/Chipper.hpp
--- a/include/libpc/filters/Chipper.hpp	Thu May 26 13:15:52 2011 -0500
+++ b/include/libpc/filters/Chipper.hpp	Mon Jun 06 15:47:23 2011 -0500
@@ -157,6 +157,8 @@
         m_xvec(chipper::DIR_X), m_yvec(chipper::DIR_Y), m_spare(chipper::DIR_NONE) 
     {
         checkImpedance();
+        setPointCountType(PointCount_Fixed);
+        setNumPoints(0);
     }
 
     void Chip();
@@ -191,7 +193,8 @@
         chipper::RefList& narrow, boost::uint32_t narrowmin, boost::uint32_t narrowmax );
 
     void checkImpedance();
-
+    
+    
     boost::uint32_t m_threshold;
     std::vector<chipper::Block> m_blocks;
     std::vector<boost::uint32_t> m_partitions;
diff -r b537b4c8ab21 -r 41bdc454e090 src/PointBuffer.cpp
--- a/src/PointBuffer.cpp	Thu May 26 13:15:52 2011 -0500
+++ b/src/PointBuffer.cpp	Mon Jun 06 15:47:23 2011 -0500
@@ -108,6 +108,10 @@
     memcpy(m_data.get() + m_pointSize * index, data, getSchemaLayout().getByteSize());
 }
 
+void PointBuffer::setAllData(boost::uint8_t* data, boost::uint32_t byteCount)
+{
+    memcpy(m_data.get(), data, byteCount);
+}
 
 boost::uint32_t PointBuffer::getNumPoints() const
 {
diff -r b537b4c8ab21 -r 41bdc454e090 src/XMLSchema.cpp
--- a/src/XMLSchema.cpp	Thu May 26 13:15:52 2011 -0500
+++ b/src/XMLSchema.cpp	Mon Jun 06 15:47:23 2011 -0500
@@ -233,7 +233,8 @@
 void Reader::Initialize() 
 {
     if (m_xml.size() == 0) throw schema_generic_error("Inputted XML has no size, is there data there?");
-    if (m_xsd.size() == 0) throw schema_generic_error("Inputted XSD has no size, is there data there?");
+    
+    // if (m_xsd.size() == 0) throw schema_generic_error("Inputted XSD has no size, is there data there?");
 
 
     LIBXML_TEST_VERSION
@@ -245,43 +246,49 @@
     m_doc = DocPtr(
                    xmlReadMemory(m_xml.c_str(), m_xml.size(), NULL, NULL, m_doc_options),
                    XMLDocDeleter());
+                   
+    if (m_xsd.size())
+    {
+        m_schema_doc = DocPtr(
+                            xmlReadMemory(m_xsd.c_str(), m_xsd.size(), NULL, NULL, m_doc_options),
+                             XMLDocDeleter());
 
-    m_schema_doc = DocPtr(
-                        xmlReadMemory(m_xsd.c_str(), m_xsd.size(), NULL, NULL, m_doc_options),
-                         XMLDocDeleter());
+        m_schema_parser_ctx = SchemaParserCtxtPtr(
+                                xmlSchemaNewDocParserCtxt(static_cast<xmlDocPtr>(m_schema_doc.get())),
+                                SchemaParserCtxDeleter());
 
-    m_schema_parser_ctx = SchemaParserCtxtPtr(
-                            xmlSchemaNewDocParserCtxt(static_cast<xmlDocPtr>(m_schema_doc.get())),
-                            SchemaParserCtxDeleter());
+        xmlSchemaSetParserStructuredErrors(static_cast<xmlSchemaParserCtxtPtr>(m_schema_parser_ctx.get()),
+                                            &OCISchemaParserStructuredErrorHandler,
+                                            m_global_context);
 
-    xmlSchemaSetParserStructuredErrors(static_cast<xmlSchemaParserCtxtPtr>(m_schema_parser_ctx.get()),
-                                        &OCISchemaParserStructuredErrorHandler,
-                                        m_global_context);
 
+        m_schema_ptr = SchemaPtr(
+                        xmlSchemaParse(static_cast<xmlSchemaParserCtxtPtr>(m_schema_parser_ctx.get())),
+                        SchemaDeleter());
 
-    m_schema_ptr = SchemaPtr(
-                    xmlSchemaParse(static_cast<xmlSchemaParserCtxtPtr>(m_schema_parser_ctx.get())),
-                    SchemaDeleter());
+        m_schema_valid_ctx = SchemaValidCtxtPtr(
+                                xmlSchemaNewValidCtxt(static_cast<xmlSchemaPtr>(m_schema_ptr.get())),
+                                SchemaValidCtxtDeleter());
 
-    m_schema_valid_ctx = SchemaValidCtxtPtr(
-                            xmlSchemaNewValidCtxt(static_cast<xmlSchemaPtr>(m_schema_ptr.get())),
-                            SchemaValidCtxtDeleter());
+        xmlSchemaSetValidErrors(static_cast<xmlSchemaValidCtxtPtr>(m_schema_valid_ctx.get()),
+                                &OCISchemaValidityError,
+                                &OCISchemaValidityDebug,
+                                m_global_context);
 
-    xmlSchemaSetValidErrors(static_cast<xmlSchemaValidCtxtPtr>(m_schema_valid_ctx.get()),
-                            &OCISchemaValidityError,
-                            &OCISchemaValidityDebug,
-                            m_global_context);
+        int valid_schema = xmlSchemaValidateDoc(static_cast<xmlSchemaValidCtxtPtr>(m_schema_valid_ctx.get()),
+                                                  static_cast<xmlDocPtr>(m_doc.get()));
 
-    int valid_schema = xmlSchemaValidateDoc(static_cast<xmlSchemaValidCtxtPtr>(m_schema_valid_ctx.get()),
-                                              static_cast<xmlDocPtr>(m_doc.get()));
+        if (valid_schema != 0)
+            throw schema_error("Document did not validate against schema!");
+        
+    }
 
-    if (valid_schema != 0)
-        throw schema_error("Document did not validate against schema!");
     
 }
 
 Reader::Reader(std::string const& xml, std::string const &xsd)
 : m_doc_options(XML_PARSE_NONET)
+, m_field_position(512)
 {
     
     m_xml = xml;
@@ -564,17 +571,9 @@
 Dimension::Field Reader::GetDimensionField(std::string const& name, boost::uint32_t position)
 {
 
-    if (name.size() == 0)
-    {
-        // Yes, this is scary.  What else can we do?  The user didn't give us a
-        // name to map to, so we'll just assume the positions are the same as
-        // our dimension positions
-        for (unsigned int i = 1; i < Dimension::Field_INVALID; ++i)
-        {
-            if (i == position)
-                return static_cast<Dimension::Field>(i);
-        }
-    }
+
+
+
 
     if (!compare_no_case(name.c_str(), "X"))
         return Dimension::Field_X;
@@ -640,7 +639,12 @@
     if (!compare_no_case(name.c_str(), "Alpha"))
         return Dimension::Field_Alpha;
 
-    return Dimension::Field_INVALID;
+    // Yes, this is scary.  What else can we do?  The user didn't give us a
+    // name to map to, so we'll just assume the positions are the same as
+    // our dimension positions
+    m_field_position = m_field_position + 1;
+    return static_cast<Dimension::Field>(m_field_position -1 );
+
 }
 
 Writer::Writer(libpc::Schema const& schema)
diff -r b537b4c8ab21 -r 41bdc454e090 src/drivers/oci/Iterator.cpp
--- a/src/drivers/oci/Iterator.cpp	Thu May 26 13:15:52 2011 -0500
+++ b/src/drivers/oci/Iterator.cpp	Mon Jun 06 15:47:23 2011 -0500
@@ -51,29 +51,26 @@
 namespace libpc { namespace drivers { namespace oci {
 
 IteratorBase::IteratorBase(const Reader& reader)
-    : m_statement(reader.getStatement())
+    : m_statement(Statement())
     , m_at_end(false)


More information about the Liblas-commits mailing list