[Liblas-commits] hg-main-tree: have oci::Reader iterator create a statement using...

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Mar 28 16:09:17 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/1824f942e387
changeset: 481:1824f942e387
user:      Howard Butler <hobu.inc at gmail.com>
date:      Mon Mar 28 15:09:11 2011 -0500
description:
have oci::Reader iterator create a statement using the shared connection

diffstat:

 apps/pc2pc.cpp                         |  29 +++++++++++++++++++++++++++--
 include/libpc/drivers/oci/Iterator.hpp |   4 +++-
 include/libpc/drivers/oci/Reader.hpp   |   4 +++-
 src/drivers/oci/Iterator.cpp           |  17 +++++++++++------
 src/drivers/oci/Reader.cpp             |   3 +++
 5 files changed, 47 insertions(+), 10 deletions(-)

diffs (138 lines):

diff -r 8d8a83b2635e -r 1824f942e387 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Mon Mar 28 14:04:55 2011 -0500
+++ b/apps/pc2pc.cpp	Mon Mar 28 15:09:11 2011 -0500
@@ -32,7 +32,8 @@
 #include <libpc/drivers/liblas/reader.hpp>
 
 #ifdef LIBPC_HAVE_ORACLE
-#include <libpc/drivers/oci/writer.hpp>
+#include <libpc/drivers/oci/Writer.hpp>
+#include <libpc/drivers/oci/Reader.hpp>
 #endif
 
 #include "Application.hpp"
@@ -142,7 +143,31 @@
 #else
         throw configuration_error("libPC not compiled with Oracle support");
 #endif
-    }    
+    }
+        else if (hasOption("oracle-reader"))
+        {
+    #ifdef LIBPC_HAVE_ORACLE
+            libpc::drivers::oci::Options options;
+            boost::property_tree::ptree& tree = options.GetPTree();
+            tree.put("capacity", 12);
+            tree.put("connection", "lidar/lidar at oracle.hobu.biz/crrel");
+            tree.put("debug", true);
+            tree.put("verbose", true);
+
+            libpc::drivers::oci::Reader reader(options);
+
+            const boost::uint64_t numPoints = reader.getNumPoints();
+
+
+
+            libpc::drivers::liblas::LiblasWriter writer(reader, *ofs);
+            writer.setPointFormat( 3);
+            writer.write(numPoints);
+    #else
+            throw configuration_error("libPC not compiled with Oracle support");
+    #endif
+        }
+
     else
     {
         libpc::drivers::liblas::LiblasReader reader(m_inputFile);
diff -r 8d8a83b2635e -r 1824f942e387 include/libpc/drivers/oci/Iterator.hpp
--- a/include/libpc/drivers/oci/Iterator.hpp	Mon Mar 28 14:04:55 2011 -0500
+++ b/include/libpc/drivers/oci/Iterator.hpp	Mon Mar 28 15:09:11 2011 -0500
@@ -39,13 +39,14 @@
 
 #include <libpc/Iterator.hpp>
 
+#include <libpc/drivers/oci/Common.hpp>
+
 #include <string>
 
 namespace libpc { namespace drivers { namespace oci {
 
 class Reader;
 
-
 class IteratorBase
 {
 public:
@@ -59,6 +60,7 @@
 
 private:
     const Reader& m_reader;
+    Statement m_statement;
     
     IteratorBase& operator=(const IteratorBase&); // not implemented
     IteratorBase(const IteratorBase&); // not implemented};
diff -r 8d8a83b2635e -r 1824f942e387 include/libpc/drivers/oci/Reader.hpp
--- a/include/libpc/drivers/oci/Reader.hpp	Mon Mar 28 14:04:55 2011 -0500
+++ b/include/libpc/drivers/oci/Reader.hpp	Mon Mar 28 15:09:11 2011 -0500
@@ -66,7 +66,9 @@
     }
 
     libpc::SequentialIterator* createSequentialIterator() const;
-
+    Connection getConnection () const { return m_connection;}
+    Options& getOptions() const { return m_options; }
+    
 private:
 
     Reader& operator=(const Reader&); // not implemented
diff -r 8d8a83b2635e -r 1824f942e387 src/drivers/oci/Iterator.cpp
--- a/src/drivers/oci/Iterator.cpp	Mon Mar 28 14:04:55 2011 -0500
+++ b/src/drivers/oci/Iterator.cpp	Mon Mar 28 15:09:11 2011 -0500
@@ -44,16 +44,19 @@
 namespace libpc { namespace drivers { namespace oci {
 
 
-//---------------------------------------------------------------------------
-//
-// LiblasIteratorBase
-//
-//---------------------------------------------------------------------------
-
 
 IteratorBase::IteratorBase(const Reader& reader)
     : m_reader(reader)
 {
+    oci::Options& options = m_reader.getOptions();
+    
+    Connection conn = m_reader.getConnection();
+    
+    std::string sql = options.GetPTree().get<std::string>("sql");
+    
+    m_statement = Statement(conn->CreateStatement(sql.c_str()));
+    
+    
     return;
 }
 
@@ -73,6 +76,8 @@
 boost::uint32_t IteratorBase::readBuffer(PointBuffer& data)
 {
     boost::uint32_t numPoints = data.getCapacity();
+    
+    
     // boost::uint32_t i = 0;
     // 
     // const Schema& schema = data.getSchema();
diff -r 8d8a83b2635e -r 1824f942e387 src/drivers/oci/Reader.cpp
--- a/src/drivers/oci/Reader.cpp	Mon Mar 28 14:04:55 2011 -0500
+++ b/src/drivers/oci/Reader.cpp	Mon Mar 28 15:09:11 2011 -0500
@@ -48,6 +48,9 @@
     , m_verbose(false)
 {
 
+    Debug();
+    
+    m_connection = Connect(m_options);
     
 }    
 


More information about the Liblas-commits mailing list