[Liblas-commits] hg-main-tree: oracle-read is now a pipeline-enabled activity -- ...

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Aug 4 16:30:07 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/1aec184e9220
changeset: 1009:1aec184e9220
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Aug 04 15:28:25 2011 -0500
description:
oracle-read is now a pipeline-enabled activity -- use pcpipeline
Subject: hg-main-tree: enable drivers.oci.reader to use the new options stuff.  nice work mpg.  basic pcpipeline works with oracle reader

details:   http://hg.libpc.orghg-main-tree/rev/653acabaa3e5
changeset: 1010:653acabaa3e5
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Aug 04 15:30:00 2011 -0500
description:
enable drivers.oci.reader to use the new options stuff.  nice work mpg.  basic pcpipeline works with oracle reader

diffstat:

 apps/pc2pc.cpp                      |  177 ++++++++++++++++++-----------------
 include/pdal/drivers/oci/Reader.hpp |    7 +-
 src/drivers/oci/Reader.cpp          |   78 +++++++++------
 3 files changed, 137 insertions(+), 125 deletions(-)

diffs (truncated from 370 to 300 lines):

diff -r 33d6b15f9dd9 -r 653acabaa3e5 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Thu Aug 04 14:01:23 2011 -0500
+++ b/apps/pc2pc.cpp	Thu Aug 04 15:30:00 2011 -0500
@@ -102,7 +102,6 @@
         ("output,o", po::value<std::string>(&m_outputFile), "output file name")
         ("native", "use native LAS classes (not liblas)")
         ("oracle-writer", "Read data from LAS file and write to Oracle")
-        ("oracle-reader", "Read data from Oracle and write to LAS")
         ("a_srs", po::value<std::string>(&m_srs)->default_value(""), "Assign output coordinate system")
         ("compress", po::value<bool>(&m_bCompress)->zero_tokens()->implicit_value(true),"Compress output data if available")
         ("xml", po::value<std::string>(&m_xml)->default_value("log.xml"), "XML file to load process (OCI only right now)")
@@ -205,92 +204,96 @@
         throw configuration_error("PDAL not compiled with Oracle support");
 #endif
     }
-        else if (hasOption("oracle-reader"))
-        {
-    #ifdef PDAL_HAVE_ORACLE
-        try{
-        boost::property_tree::ptree load_tree;
-        
-        boost::property_tree::read_xml(m_xml, load_tree);
-        
-        boost::property_tree::ptree oracle_options = load_tree.get_child("pdal.drivers.oci.reader");
-
-        boost::property_tree::ptree las_options = load_tree.get_child("pdal.drivers.las");
-        boost::property_tree::ptree srs_options = las_options.get_child("spatialreference");
-        
-        double scalex = las_options.get<double>("scale.x");
-        double scaley = las_options.get<double>("scale.y");
-        double scalez = las_options.get<double>("scale.z");
-
-        double offsetx = las_options.get<double>("offset.x");
-        double offsety = las_options.get<double>("offset.y");
-        double offsetz = las_options.get<double>("offset.z");
-        
-        bool compress = las_options.get<bool>("compress");
-        
-        std::string out_wkt = srs_options.get<std::string>("userinput");
-        pdal::OptionsOld options(oracle_options);
-
-
-        pdal::drivers::oci::Reader reader(options);
-
-        pdal::drivers::las::LasWriter* writer;
-
-        pdal::SpatialReference out_ref(out_wkt);
-        pdal::SpatialReference in_ref(reader.getSpatialReference());
-        if (!(in_ref == out_ref)) 
-        {
-            // pdal::filters::ByteSwapFilter swapper(reader);
-            pdal::filters::ScalingFilter scalingFilter(reader);
-            pdal::filters::ReprojectionFilter reprojectionFilter(scalingFilter, in_ref, out_ref);
-            pdal::filters::DescalingFilter descalingFilter(reprojectionFilter, 
-                                                           scalex, offsetx,
-                                                           scaley, offsety,
-                                                           scalez, offsetz);
-
-            writer = new pdal::drivers::las::LasWriter(descalingFilter, ofs);
-            if (compress)
-                writer->setCompressed(true);
-            writer->setChunkSize(oracle_options.get<boost::uint32_t>("capacity"));
-            writer->setPointFormat(pdal::drivers::las::PointFormat3);
-        
-            writer->initialize();
-
-            writer->write(0);
-            delete writer;
-        }
-        else
-        {
-            writer = new pdal::drivers::las::LasWriter(reader, ofs);
-            if (compress)
-                writer->setCompressed(true);
-            writer->setChunkSize(oracle_options.get<boost::uint32_t>("capacity"));
-            writer->setPointFormat(pdal::drivers::las::PointFormat3);
-        
-            writer->initialize();
-
-            writer->write(0);
-            delete writer;
-        }
-        
-
-
-
-
-            
-        } catch (pdal::pdal_error& e)
-        {
-            std::cerr << "Error reading oracle: " << e.what() << std::endl;
-            return 1;
-            
-        }
-        
-            
-
-    #else
-            throw configuration_error("PDAL not compiled with Oracle support");
-    #endif
-        }
+    //     else if (hasOption("oracle-reader"))
+    //     {
+    // #ifdef PDAL_HAVE_ORACLE
+    //     try{
+    //     boost::property_tree::ptree load_tree;
+    //     
+    //     boost::property_tree::read_xml(m_xml, load_tree);
+    //     
+    //     boost::property_tree::ptree oracle_options = load_tree.get_child("pdal.drivers.oci.reader");
+    // 
+    //     boost::property_tree::ptree las_options = load_tree.get_child("pdal.drivers.las");
+    //     boost::property_tree::ptree srs_options = las_options.get_child("spatialreference");
+    //     
+    //     double scalex = las_options.get<double>("scale.x");
+    //     double scaley = las_options.get<double>("scale.y");
+    //     double scalez = las_options.get<double>("scale.z");
+    // 
+    //     double offsetx = las_options.get<double>("offset.x");
+    //     double offsety = las_options.get<double>("offset.y");
+    //     double offsetz = las_options.get<double>("offset.z");
+    //     
+    //     bool compress = las_options.get<bool>("compress");
+    //     
+    //     std::string out_wkt = srs_options.get<std::string>("userinput");
+    //     pdal::OptionsOld options(oracle_options);
+    // 
+    // 
+    // 
+    //     pdal::drivers::oci::Reader reader_srs(options);
+    //     reader_srs.initialize();
+    //     
+    //     pdal::drivers::oci::Reader reader(options);
+    // 
+    //     pdal::drivers::las::LasWriter* writer;
+    // 
+    //     pdal::SpatialReference out_ref(out_wkt);
+    //     pdal::SpatialReference in_ref(reader_srs.getSpatialReference());
+    //     if (!(in_ref == out_ref)) 
+    //     {
+    //         // pdal::filters::ByteSwapFilter swapper(reader);
+    //         pdal::filters::ScalingFilter scalingFilter(reader);
+    //         pdal::filters::ReprojectionFilter reprojectionFilter(scalingFilter, in_ref, out_ref);
+    //         pdal::filters::DescalingFilter descalingFilter(reprojectionFilter, 
+    //                                                        scalex, offsetx,
+    //                                                        scaley, offsety,
+    //                                                        scalez, offsetz);
+    // 
+    //         writer = new pdal::drivers::las::LasWriter(descalingFilter, ofs);
+    //         if (compress)
+    //             writer->setCompressed(true);
+    //         writer->setChunkSize(oracle_options.get<boost::uint32_t>("capacity"));
+    //         writer->setPointFormat(pdal::drivers::las::PointFormat3);
+    //     
+    //         writer->initialize();
+    // 
+    //         writer->write(0);
+    //         delete writer;
+    //     }
+    //     else
+    //     {
+    //         writer = new pdal::drivers::las::LasWriter(reader, ofs);
+    //         if (compress)
+    //             writer->setCompressed(true);
+    //         writer->setChunkSize(oracle_options.get<boost::uint32_t>("capacity"));
+    //         writer->setPointFormat(pdal::drivers::las::PointFormat3);
+    //     
+    //         writer->initialize();
+    // 
+    //         writer->write(0);
+    //         delete writer;
+    //     }
+    //     
+    // 
+    // 
+    // 
+    // 
+    //         
+    //     } catch (pdal::pdal_error& e)
+    //     {
+    //         std::cerr << "Error reading oracle: " << e.what() << std::endl;
+    //         return 1;
+    //         
+    //     }
+    //     
+    //         
+    // 
+    // #else
+    //         throw configuration_error("PDAL not compiled with Oracle support");
+    // #endif
+    //     }
 
 
 
diff -r 33d6b15f9dd9 -r 653acabaa3e5 include/pdal/drivers/oci/Reader.hpp
--- a/include/pdal/drivers/oci/Reader.hpp	Thu Aug 04 14:01:23 2011 -0500
+++ b/include/pdal/drivers/oci/Reader.hpp	Thu Aug 04 15:30:00 2011 -0500
@@ -55,7 +55,6 @@
 
 public:
     Reader(const Options&);
-    Reader(OptionsOld& options);
     ~Reader();
     virtual void initialize();
  
@@ -71,11 +70,8 @@
     
     Connection getConnection () const { return m_connection;}
     Statement getStatement () const { return m_statement;}
-    OptionsOld& getOptionsOld() const { return m_optionsOld; }
     CloudPtr getCloud() const;
     std::string getQuery() const;
-    bool isVerbose() const;
-    bool isDebug() const;
 
 private:
 
@@ -89,8 +85,8 @@
     QueryType describeQueryType() const;    
     BlockPtr defineBlock() const;
     Schema fetchSchema(sdo_pc* pc);
+    Connection Connect();
 
-    OptionsOld& m_optionsOld;
     Connection m_connection;
     Statement m_statement;
     QueryType m_querytype;
@@ -98,6 +94,7 @@
     Schema m_schema;
     sdo_pc* m_pc;
     sdo_pc_blk* m_pc_block;
+    boost::uint32_t m_capacity;
 
 };
 
diff -r 33d6b15f9dd9 -r 653acabaa3e5 src/drivers/oci/Reader.cpp
--- a/src/drivers/oci/Reader.cpp	Thu Aug 04 14:01:23 2011 -0500
+++ b/src/drivers/oci/Reader.cpp	Thu Aug 04 15:30:00 2011 -0500
@@ -38,6 +38,11 @@
 #include <pdal/exceptions.hpp>
 #include <pdal/FileUtils.hpp>
 
+#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
+#include <boost/tokenizer.hpp>
+#include <boost/make_shared.hpp>
+
 #include <iostream>
 #include <map>
 
@@ -47,24 +52,54 @@
 
 IMPLEMENT_STATICS(Reader, "drivers.oci.reader", "OCI Reader")
 
-static OptionsOld dummy;
 Reader::Reader(const Options& options)
     : pdal::Reader(options)
-    , m_optionsOld(dummy)
+    , m_querytype(QUERY_UNKNOWN)
+    , m_capacity(0)
 {
-    throw not_yet_implemented("options ctor"); 
+
+
+
 }
 
+pdal::drivers::oci::Connection Reader::Connect()
+{
+    std::string connection  = getOptions().getValueOrThrow<std::string>("connection");
 
-Reader::Reader(OptionsOld& optionsOld)
-    : pdal::Reader(Options::none())
-    , m_optionsOld(optionsOld)
-    , m_querytype(QUERY_UNKNOWN)
+    
+    if (connection.empty())
+        throw pdal_error("Oracle connection string empty! Unable to connect");
+
+    
+    std::string::size_type slash_pos = connection.find("/",0);
+    std::string username = connection.substr(0,slash_pos);
+    std::string::size_type at_pos = connection.find("@",slash_pos);
+
+    std::string password = connection.substr(slash_pos+1, at_pos-slash_pos-1);
+    std::string instance = connection.substr(at_pos+1);
+    
+    Connection con = boost::make_shared<OWConnection>(username.c_str(),password.c_str(),instance.c_str());
+    
+    if (con->Succeeded())
+    {
+        if (isVerbose())
+            std::cout << "Oracle connection succeeded" << std::endl;        
+    }
+    else
+        throw connection_failed("Oracle connection failed");
+        
+    return con;
+    
+}


More information about the Liblas-commits mailing list