[Liblas-commits] hg-main-tree: support overwrite for OCI

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Apr 7 16:29:09 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/b5eca2c7b053
changeset: 507:b5eca2c7b053
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Apr 07 15:28:20 2011 -0500
description:
support overwrite for OCI
Subject: hg-main-tree: support table deletion and PC object creation

details:   http://hg.libpc.orghg-main-tree/rev/76304ef6213f
changeset: 508:76304ef6213f
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Apr 07 15:29:00 2011 -0500
description:
support table deletion and PC object creation

diffstat:

 apps/pc2pc.cpp                       |   3 ++-
 include/libpc/drivers/oci/Writer.hpp |   1 +
 src/drivers/oci/Writer.cpp           |  34 ++++++++++++++++++++++------------
 src/drivers/oci/common.cpp           |   3 ++-
 4 files changed, 27 insertions(+), 14 deletions(-)

diffs (138 lines):

diff -r 68912ea61235 -r 76304ef6213f apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Thu Apr 07 13:06:22 2011 -0500
+++ b/apps/pc2pc.cpp	Thu Apr 07 15:29:00 2011 -0500
@@ -131,8 +131,9 @@
         libpc::drivers::oci::Options options;
         boost::property_tree::ptree& tree = options.GetPTree();
         
-        boost::uint32_t capacity = 12;
+        boost::uint32_t capacity = 1000;
         tree.put("capacity", capacity);
+        tree.put("overwrite", true);
         tree.put("connection", "lidar/lidar at 192.168.56.101/orcl");
         // tree.put("connection", "lidar/lidar at oracle.hobu.biz/crrel");
         tree.put("debug", true);
diff -r 68912ea61235 -r 76304ef6213f include/libpc/drivers/oci/Writer.hpp
--- a/include/libpc/drivers/oci/Writer.hpp	Thu Apr 07 13:06:22 2011 -0500
+++ b/include/libpc/drivers/oci/Writer.hpp	Thu Apr 07 15:29:00 2011 -0500
@@ -108,6 +108,7 @@
     libpc::Bounds<double> m_bounds; // Bounds of the entire point cloud
     Connection m_connection;
     bool m_verbose;
+    bool m_doCreateIndex;
 };
 
 }}} // namespace libpc::driver::oci
diff -r 68912ea61235 -r 76304ef6213f src/drivers/oci/Writer.cpp
--- a/src/drivers/oci/Writer.cpp	Thu Apr 07 13:06:22 2011 -0500
+++ b/src/drivers/oci/Writer.cpp	Thu Apr 07 15:29:00 2011 -0500
@@ -49,6 +49,7 @@
     , m_stage(prevStage)
     , m_options(options)
     , m_verbose(false)
+    , m_doCreateIndex(false)
 {
 
     
@@ -130,7 +131,7 @@
     run(oss);
     oss.str("");
     
-    oss << "DROP TABLE" << block_table_name;
+    oss << "DROP TABLE " << block_table_name;
     run(oss);
     oss.str("");
 
@@ -479,8 +480,6 @@
 
 
     std::ostringstream s_srid;
-    std::ostringstream s_gtype;
-    std::ostringstream s_eleminfo;
     std::ostringstream s_geom;
 
 
@@ -496,14 +495,13 @@
     }
 
     long gtype = GetGType();
-    s_gtype << gtype;
     
     std::string eleminfo = CreatePCElemInfo();
 
     libpc::Bounds<double> e = m_bounds;
 
-    s_geom << "           mdsys.sdo_geometry("<<s_gtype.str() <<", "<<s_srid.str()<<", null,\n"
-"              mdsys.sdo_elem_info_array"<< s_eleminfo.str() <<",\n"
+    s_geom << "           mdsys.sdo_geometry("<< gtype <<", "<<s_srid.str()<<", null,\n"
+"              mdsys.sdo_elem_info_array"<< eleminfo <<",\n"
 "              mdsys.sdo_ordinate_array(\n";
 
     s_geom << e.getMinimum(0) << "," << e.getMinimum(1) << ",";
@@ -553,12 +551,12 @@
     Statement statement = Statement(m_connection->CreateStatement(oss.str().c_str()));
 
     statement->Bind(&pc_id);
-    if (header_data->size() != 0) 
-    {
-        OCILobLocator** locator =(OCILobLocator**) VSIMalloc( sizeof(OCILobLocator*) * 1 );
-        statement->Define( locator, 1 ); 
-        statement->Bind((char*)&(header_data[0]),(long)header_data->size());
-    }
+    // if (header_data->size() != 0) 
+    // {
+    //     OCILobLocator** locator =(OCILobLocator**) VSIMalloc( sizeof(OCILobLocator*) * 1 );
+    //     statement->Define( locator, 1 ); 
+    //     statement->Bind((char*)&(header_data[0]),(long)header_data->size());
+    // }
 
     char* wkt = (char*) malloc(base_table_boundary_wkt.size() * sizeof(char));
     strncpy(wkt, base_table_boundary_wkt.c_str(), base_table_boundary_wkt.size());
@@ -603,9 +601,16 @@
     
     m_connection = Connect(m_options);
     
+    if (m_options.GetPTree().get<bool>("overwrite"))
+        WipeBlockTable();
     RunFileSQL("pre_sql");
     if (!BlockTableExists())
+    {
+        m_doCreateIndex = true;
         CreateBlockTable();
+    }
+        
+    CreatePCEntry(0);
     
     return;
 }
@@ -614,6 +619,11 @@
 void Writer::writeEnd()
 {
 
+    if (m_doCreateIndex)
+    {
+        CreateSDOEntry();
+        CreateBlockIndex();
+    }
     return;
 }
 
diff -r 68912ea61235 -r 76304ef6213f src/drivers/oci/common.cpp
--- a/src/drivers/oci/common.cpp	Thu Apr 07 13:06:22 2011 -0500
+++ b/src/drivers/oci/common.cpp	Thu Apr 07 15:29:00 2011 -0500
@@ -57,13 +57,14 @@
     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("header"));
+    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(""));


More information about the Liblas-commits mailing list