[Liblas-commits] hg-main-tree: move OCI driver's Options thing up into a proper l...

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Apr 25 12:35:09 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/12d9f7fe990f
changeset: 638:12d9f7fe990f
user:      Howard Butler <hobu.inc at gmail.com>
date:      Mon Apr 25 11:35:01 2011 -0500
description:
move OCI driver's Options thing up into a proper library-wide class

diffstat:

 apps/pc2pc.cpp                       |    4 +-
 include/libpc/Options.hpp            |   67 +++++++++++++++
 include/libpc/drivers/oci/Common.hpp |   20 +---
 include/libpc/drivers/oci/Writer.hpp |    2 -
 src/CMakeLists.txt                   |    2 +
 src/Options.cpp                      |  153 +++++++++++++++++++++++++++++++++++
 src/drivers/oci/common.cpp           |  149 +++++++++++++++++----------------
 7 files changed, 303 insertions(+), 94 deletions(-)

diffs (truncated from 500 to 300 lines):

diff -r 7f1b39cf6d36 -r 12d9f7fe990f apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Mon Apr 25 10:49:33 2011 -0500
+++ b/apps/pc2pc.cpp	Mon Apr 25 11:35:01 2011 -0500
@@ -131,7 +131,7 @@
     
         const boost::uint64_t numPoints = reader.getNumPoints();
         
-        libpc::drivers::oci::Options options;
+        libpc::Options options = libpc::drivers::oci::GetDefaultOptions();
         boost::property_tree::ptree& tree = options.GetPTree();
         
         boost::uint32_t capacity = 10000;
@@ -157,7 +157,7 @@
         else if (hasOption("oracle-reader"))
         {
     #ifdef LIBPC_HAVE_ORACLE
-            libpc::drivers::oci::Options options;
+            libpc::Options options = libpc::drivers::oci::GetDefaultOptions();
             boost::property_tree::ptree& tree = options.GetPTree();
             tree.put("capacity", 12);
             tree.put("connection", "lidar/lidar at oracle.hobu.biz/orcl");
diff -r 7f1b39cf6d36 -r 12d9f7fe990f include/libpc/Options.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/Options.hpp	Mon Apr 25 11:35:01 2011 -0500
@@ -0,0 +1,67 @@
+/******************************************************************************
+* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.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_OPTIONS_HPP
+#define INCLUDED_OPTIONS_HPP
+
+#include <libpc/libpc.hpp>
+#include <libpc/Bounds.hpp>
+#include <boost/property_tree/ptree.hpp>
+
+
+namespace libpc
+{
+
+class LIBPC_DLL Options
+{
+
+private:
+    boost::property_tree::ptree m_tree;
+
+public:
+
+    Options();
+    bool IsDebug() const;
+    bool Is3d() const;
+    bool IsSolid() const;
+    boost::property_tree::ptree& GetPTree() {return m_tree; }
+    boost::property_tree::ptree const& GetPTree() const {return m_tree; }
+};
+
+
+LIBPC_DLL std::ostream& operator<<(std::ostream& ostr, const Options&);
+
+} // namespace libpc
+
+#endif
diff -r 7f1b39cf6d36 -r 12d9f7fe990f include/libpc/drivers/oci/Common.hpp
--- a/include/libpc/drivers/oci/Common.hpp	Mon Apr 25 10:49:33 2011 -0500
+++ b/include/libpc/drivers/oci/Common.hpp	Mon Apr 25 11:35:01 2011 -0500
@@ -37,6 +37,7 @@
 
 #include <libpc/libpc.hpp>
 #include <libpc/exceptions.hpp>
+#include <libpc/Options.hpp>
 
 #include "oci_wrapper.h"
 #include "Endian.hpp"
@@ -44,7 +45,6 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/scoped_ptr.hpp>
 
-#include <boost/property_tree/ptree.hpp>
 
 #include <cpl_port.h>
 
@@ -60,6 +60,7 @@
 typedef boost::shared_ptr<OWStatement> Statement ;
 
 
+Options GetDefaultOptions();
 
 class connection_failed : public libpc_error
 {
@@ -206,23 +207,8 @@
 
 typedef boost::shared_ptr<Block> BlockPtr;
 
-class LIBPC_DLL Options
-{
 
-private:
-    boost::property_tree::ptree m_tree;
-
-public:
-
-    Options();
-    bool IsDebug() const;
-    bool Is3d() const;
-    bool IsSolid() const;
-    boost::property_tree::ptree& GetPTree() {return m_tree; }
-    boost::property_tree::ptree const& GetPTree() const {return m_tree; }
-};
-
-LIBPC_DLL Connection Connect(Options const& options);
+LIBPC_DLL Connection Connect(libpc::Options const& options);
 
 std::string to_upper(std::string const& input);
 
diff -r 7f1b39cf6d36 -r 12d9f7fe990f include/libpc/drivers/oci/Writer.hpp
--- a/include/libpc/drivers/oci/Writer.hpp	Mon Apr 25 10:49:33 2011 -0500
+++ b/include/libpc/drivers/oci/Writer.hpp	Mon Apr 25 11:35:01 2011 -0500
@@ -45,8 +45,6 @@
 
 namespace libpc { namespace drivers { namespace oci {
 
-class Options;
-
 
 
 class LIBPC_DLL Writer : public libpc::Writer
diff -r 7f1b39cf6d36 -r 12d9f7fe990f src/CMakeLists.txt
--- a/src/CMakeLists.txt	Mon Apr 25 10:49:33 2011 -0500
+++ b/src/CMakeLists.txt	Mon Apr 25 11:35:01 2011 -0500
@@ -43,6 +43,7 @@
   ${LIBPC_HEADERS_DIR}/Iterator.hpp
   ${LIBPC_HEADERS_DIR}/MetadataRecord.hpp
   ${LIBPC_HEADERS_DIR}/Vector.hpp  
+  ${LIBPC_HEADERS_DIR}/Options.hpp
   ${LIBPC_HEADERS_DIR}/PointBuffer.hpp  
   ${LIBPC_HEADERS_DIR}/PointBufferCache.hpp  
   ${LIBPC_HEADERS_DIR}/Range.hpp
@@ -67,6 +68,7 @@
   Vector.cpp  
   PointBuffer.cpp
   PointBufferCache.cpp
+  Options.cpp
   Schema.cpp
   SchemaLayout.cpp
   Signaller.cpp
diff -r 7f1b39cf6d36 -r 12d9f7fe990f src/Options.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Options.cpp	Mon Apr 25 11:35:01 2011 -0500
@@ -0,0 +1,153 @@
+/******************************************************************************
+* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.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.
+****************************************************************************/
+
+#include <libpc/Options.hpp>
+
+#include <boost/concept_check.hpp> // ignore_unused_variable_warning
+
+#include <iostream>
+
+#include <libpc/exceptions.hpp>
+
+
+namespace libpc
+{
+
+Options::Options()
+{
+    m_tree.put("is3d", false);
+    m_tree.put("solid", false);
+    m_tree.put("overwrite", false);
+    m_tree.put("debug", false);
+    m_tree.put("verbose", false);
+    m_tree.put("srid", 4269);
+    m_tree.put("capacity", 8000);
+    m_tree.put("precision", 8);
+    m_tree.put("cloud_id", -1);
+    m_tree.put("dimensions", 5);
+    m_tree.put("connection", std::string(""));
+    m_tree.put("block_table_name", std::string("output"));
+    m_tree.put("block_table_partition_column", std::string(""));
+    m_tree.put("block_table_partition_value", boost::int32_t(0));
+    m_tree.put("base_table_name", std::string("hobu"));
+    m_tree.put("cloud_column_name", std::string("cloud"));
+    m_tree.put("header_blob_column_name", std::string(""));
+    m_tree.put("base_table_aux_columns", std::string(""));
+    m_tree.put("base_table_aux_values", std::string(""));
+    m_tree.put("base_table_boundary_column", std::string(""));
+    m_tree.put("base_table_boundary_wkt", std::string(""));
+    m_tree.put("pre_block_sql", std::string(""));
+    m_tree.put("pre_sql", std::string(""));
+    m_tree.put("post_block_sql", std::string(""));
+    m_tree.put("select_sql", std::string(""));
+    m_tree.put("base_table_bounds", libpc::Bounds<double>());
+    m_tree.put("blob_read_byte_size", boost::uint32_t(2000));
+    m_tree.put("point_schema_override", "");
+    
+    boost::property_tree::ptree scales;
+    scales.put("x", double(0.01));
+    scales.put("y", double(0.01));
+    scales.put("z", double(0.01));
+
+    boost::property_tree::ptree offsets;
+    offsets.put("x", double(0.0));
+    offsets.put("y", double(0.0));
+    offsets.put("z", double(0.0));
+    
+    m_tree.add_child("scale", scales);
+    m_tree.add_child("offset", offsets);
+}    
+
+bool Options::IsDebug() const
+{
+    bool debug = false;
+    try
+    {
+        debug = m_tree.get<bool>("debug");
+    }
+    catch (boost::property_tree::ptree_bad_path const& e) {
+      ::boost::ignore_unused_variable_warning(e);
+
+    }
+    return debug;
+}
+
+bool Options::Is3d() const
+{
+    bool is3d = false;
+    try
+    {
+        is3d = m_tree.get<bool>("is3d");
+    }
+    catch (boost::property_tree::ptree_bad_path const& e) {
+      ::boost::ignore_unused_variable_warning(e);
+
+    }
+    return is3d;
+}
+
+bool Options::IsSolid() const
+{


More information about the Liblas-commits mailing list