[Liblas-commits] hg-main-tree: update OCI wrapper to match latest in SVN

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Mar 29 13:22:14 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/9da4f8c71b52
changeset: 482:9da4f8c71b52
user:      Howard Butler <hobu.inc at gmail.com>
date:      Tue Mar 29 12:20:33 2011 -0500
description:
update OCI wrapper to match latest in SVN
Subject: hg-main-tree: use libPC include path for oci_wrapper.h

details:   http://hg.libpc.orghg-main-tree/rev/15222bf9fb8f
changeset: 483:15222bf9fb8f
user:      Howard Butler <hobu.inc at gmail.com>
date:      Tue Mar 29 12:21:28 2011 -0500
description:
use libPC include path for oci_wrapper.h
Subject: hg-main-tree: more oci reader scaffolding

details:   http://hg.libpc.orghg-main-tree/rev/55dd6b15eee2
changeset: 484:55dd6b15eee2
user:      Howard Butler <hobu.inc at gmail.com>
date:      Tue Mar 29 12:22:08 2011 -0500
description:
more oci reader scaffolding

diffstat:

 apps/pc2pc.cpp                          |    2 +
 include/libpc/drivers/oci/Iterator.hpp  |    1 -
 include/libpc/drivers/oci/Reader.hpp    |    8 +-
 include/libpc/drivers/oci/oci_wrapper.h |    5 +-
 src/drivers/oci/Iterator.cpp            |    9 --
 src/drivers/oci/Reader.cpp              |   63 +++++++++++++++++++
 src/drivers/oci/common.cpp              |    1 +
 src/drivers/oci/oci_wrapper.cpp         |  103 +++++++++++++++++++++++--------
 8 files changed, 147 insertions(+), 45 deletions(-)

diffs (truncated from 382 to 300 lines):

diff -r 1824f942e387 -r 55dd6b15eee2 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Mon Mar 28 15:09:11 2011 -0500
+++ b/apps/pc2pc.cpp	Tue Mar 29 12:22:08 2011 -0500
@@ -90,6 +90,7 @@
         ("output,o", po::value<std::string>(&m_outputFile), "output file name")
         ("native", "use native LAS classes (not liblas)")
         ("oracle", "oracle test")
+        ("oracle-reader", "oracle test")
         ;
 
     addOptionSet(file_options);
@@ -153,6 +154,7 @@
             tree.put("connection", "lidar/lidar at oracle.hobu.biz/crrel");
             tree.put("debug", true);
             tree.put("verbose", true);
+            tree.put("select_sql", "select * from output");
 
             libpc::drivers::oci::Reader reader(options);
 
diff -r 1824f942e387 -r 55dd6b15eee2 include/libpc/drivers/oci/Iterator.hpp
--- a/include/libpc/drivers/oci/Iterator.hpp	Mon Mar 28 15:09:11 2011 -0500
+++ b/include/libpc/drivers/oci/Iterator.hpp	Tue Mar 29 12:22:08 2011 -0500
@@ -60,7 +60,6 @@
 
 private:
     const Reader& m_reader;
-    Statement m_statement;
     
     IteratorBase& operator=(const IteratorBase&); // not implemented
     IteratorBase(const IteratorBase&); // not implemented};
diff -r 1824f942e387 -r 55dd6b15eee2 include/libpc/drivers/oci/Reader.hpp
--- a/include/libpc/drivers/oci/Reader.hpp	Mon Mar 28 15:09:11 2011 -0500
+++ b/include/libpc/drivers/oci/Reader.hpp	Tue Mar 29 12:22:08 2011 -0500
@@ -44,12 +44,6 @@
 
 namespace libpc { namespace drivers { namespace oci {
 
-
-
-
-
-
-
 class LIBPC_DLL Reader : public libpc::Stage
 {
 
@@ -76,9 +70,11 @@
     // 
     
     void Debug();
+    void registerFields();
 
     Options& m_options;
     Connection m_connection;
+    Statement m_statement;
     bool m_verbose;
 };
 
diff -r 1824f942e387 -r 55dd6b15eee2 include/libpc/drivers/oci/oci_wrapper.h
--- a/include/libpc/drivers/oci/oci_wrapper.h	Mon Mar 28 15:09:11 2011 -0500
+++ b/include/libpc/drivers/oci/oci_wrapper.h	Tue Mar 29 12:22:08 2011 -0500
@@ -382,7 +382,7 @@
     void                Define( long* pnData );
     void                Define( double* pnData );
     void                Define( char* pszData, int nSize = OWNAME );
-    void                Define( OCILobLocator** pphLocator);
+    void                Define( OCILobLocator** pphLocator );
     void                Define( OCIArray** pphData );
     void                Define( sdo_georaster** pphData );
     void                Define( sdo_geometry** pphData );
@@ -400,6 +400,7 @@
     unsigned long       ReadBlob( OCILobLocator* phLocator,
                             void* pBuffer, int nSize );
     char*               ReadCLob( OCILobLocator* phLocator );
+    void                WriteCLob( OCILobLocator** pphLocator, char* pszData );
     bool                WriteBlob( OCILobLocator* phLocator,
                             void* pBuffer, int nSize );
     int                 GetElement( OCIArray** ppoData,
@@ -410,8 +411,6 @@
                             int nValue );
     void                AddElement( OCIArray* ppoData,
                             double dfValue );
-    OWConnection*       GetConnection() {return poConnection;}
-
 };
 
 #endif /* ifndef _ORCL_WRAP_H_INCLUDED */
diff -r 1824f942e387 -r 55dd6b15eee2 src/drivers/oci/Iterator.cpp
--- a/src/drivers/oci/Iterator.cpp	Mon Mar 28 15:09:11 2011 -0500
+++ b/src/drivers/oci/Iterator.cpp	Tue Mar 29 12:22:08 2011 -0500
@@ -43,20 +43,11 @@
 
 namespace libpc { namespace drivers { namespace oci {
 
-
-
 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;
 }
 
diff -r 1824f942e387 -r 55dd6b15eee2 src/drivers/oci/Reader.cpp
--- a/src/drivers/oci/Reader.cpp	Mon Mar 28 15:09:11 2011 -0500
+++ b/src/drivers/oci/Reader.cpp	Tue Mar 29 12:22:08 2011 -0500
@@ -51,7 +51,16 @@
     Debug();
     
     m_connection = Connect(m_options);
+
     
+    
+    std::string sql = options.GetPTree().get<std::string>("select_sql");
+    
+    if (sql.size() == 0 )
+        throw libpc_error("'select_sql' statement is empty. No data can be read from libpc::drivers::oci::Reader");
+    
+    m_statement = Statement(m_connection->CreateStatement(sql.c_str()));
+        
 }    
 
 void Reader::Debug()
@@ -84,6 +93,60 @@
     }
 }
 
+void Reader::registerFields()
+{
+    Schema& schema = getSchemaRef();
+
+    Dimension xDim(Dimension::Field_X, Dimension::Int32);
+    Dimension yDim(Dimension::Field_Y, Dimension::Int32);
+    Dimension zDim(Dimension::Field_Z, Dimension::Int32);
+
+    // xDim.setNumericScale(externalHeader.GetScaleX());
+    //   yDim.setNumericScale(externalHeader.GetScaleY());
+    //   zDim.setNumericScale(externalHeader.GetScaleZ());
+    //   xDim.setNumericOffset(externalHeader.GetOffsetX());
+    //   yDim.setNumericOffset(externalHeader.GetOffsetY());
+    //   zDim.setNumericOffset(externalHeader.GetOffsetZ());
+    // 
+    //   schema.addDimension(xDim);
+    //   schema.addDimension(yDim);
+    //   schema.addDimension(zDim);
+    // 
+    //   schema.addDimension(Dimension(Dimension::Field_Intensity, Dimension::Uint16));
+    //   schema.addDimension(Dimension(Dimension::Field_ReturnNumber, Dimension::Uint8));
+    //   schema.addDimension(Dimension(Dimension::Field_NumberOfReturns, Dimension::Uint8));
+    //   schema.addDimension(Dimension(Dimension::Field_ScanDirectionFlag, Dimension::Uint8));
+    //   schema.addDimension(Dimension(Dimension::Field_EdgeOfFlightLine, Dimension::Uint8));
+    //   schema.addDimension(Dimension(Dimension::Field_Classification, Dimension::Uint8));
+    //   schema.addDimension(Dimension(Dimension::Field_ScanAngleRank, Dimension::Int8));
+    //   schema.addDimension(Dimension(Dimension::Field_UserData, Dimension::Uint8));
+    //   schema.addDimension(Dimension(Dimension::Field_PointSourceId, Dimension::Uint16));
+    // 
+    //   if (m_hasTimeData)
+    //   {
+    //       schema.addDimension(Dimension(Dimension::Field_Time, Dimension::Double));
+    //   }
+    // 
+    //   if (m_hasColorData)
+    //   {
+    //       schema.addDimension(Dimension(Dimension::Field_Red, Dimension::Uint16));
+    //       schema.addDimension(Dimension(Dimension::Field_Green, Dimension::Uint16));
+    //       schema.addDimension(Dimension(Dimension::Field_Blue, Dimension::Uint16));
+    //   }
+    // 
+    //   //if (m_hasWaveData)
+    //   //{
+    //   //    schema.addDimension(Dimension(Dimension::Field_WavePacketDescriptorIndex, Dimension::Uint8));
+    //   //    schema.addDimension(Dimension(Dimension::Field_WaveformDataOffset, Dimension::Uint64));
+    //   //    schema.addDimension(Dimension(Dimension::Field_ReturnPointWaveformLocation, Dimension::Uint32));
+    //   //    schema.addDimension(Dimension(Dimension::Field_WaveformXt, Dimension::Float));
+    //   //    schema.addDimension(Dimension(Dimension::Field_WaveformYt, Dimension::Float));
+    //   //    schema.addDimension(Dimension(Dimension::Field_WaveformZt, Dimension::Float));
+    //   //}
+    //   
+    //   return;
+}
+
 const std::string& Reader::getName() const
 {
     static std::string name("OCI Reader");
diff -r 1824f942e387 -r 55dd6b15eee2 src/drivers/oci/common.cpp
--- a/src/drivers/oci/common.cpp	Mon Mar 28 15:09:11 2011 -0500
+++ b/src/drivers/oci/common.cpp	Tue Mar 29 12:22:08 2011 -0500
@@ -71,6 +71,7 @@
     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>());
 
 }    
diff -r 1824f942e387 -r 55dd6b15eee2 src/drivers/oci/oci_wrapper.cpp
--- a/src/drivers/oci/oci_wrapper.cpp	Mon Mar 28 15:09:11 2011 -0500
+++ b/src/drivers/oci/oci_wrapper.cpp	Tue Mar 29 12:22:08 2011 -0500
@@ -30,7 +30,6 @@
 
 #include <libpc/drivers/oci/oci_wrapper.h>
 
-
 static const OW_CellDepth ahOW_CellDepth[] = {
     {"8BIT_U",          GDT_Byte},
     {"16BIT_U",         GDT_UInt16},
@@ -149,7 +148,7 @@
     }
 
     if( CheckError( OCIAttrSet((dvoid *) hSession, (ub4) OCI_HTYPE_SESSION,
-        (dvoid *) pszUserId, (ub4) strlen((const char *) pszUserId),
+        (dvoid *) pszUserId, (ub4) strlen( pszUserId),
         (ub4) OCI_ATTR_USERNAME, hError), hError ) )
     {
         return;
@@ -227,9 +226,13 @@
     hNumArrayTDO    = DescribeType( SDO_NUMBER_ARRAY );
     hGeometryTDO    = DescribeType( SDO_GEOMETRY );
     hGeoRasterTDO   = DescribeType( SDO_GEORASTER );
-    hPCTDO          = DescribeType( SDO_PC );
     hElemArrayTDO   = DescribeType( SDO_ELEM_INFO_ARRAY);
     hOrdnArrayTDO   = DescribeType( SDO_ORDINATE_ARRAY);
+
+    if( nVersion > 10 )
+    {
+        hPCTDO      = DescribeType( SDO_PC );
+    }
 }
 
 OWConnection::~OWConnection()
@@ -253,13 +256,6 @@
 
     if( hSession )
         OCIHandleFree((dvoid *) hSession, (ub4) OCI_HTYPE_SESSION);
-    
-    if (pszUser)
-        CPLFree(pszUser);
-    if (pszPassword)
-        CPLFree(pszPassword);
-    if (pszServer)
-        CPLFree(pszServer);
 }
 
 OCIType* OWConnection::DescribeType( const char *pszTypeName )
@@ -566,7 +562,7 @@
 
     if( nStmtType != OCI_STMT_SELECT )
     {
-        nStmtMode = OCI_DEFAULT;// OCI_COMMIT_ON_SUCCESS; //?? Transaction ??//
+        nStmtMode = OCI_DEFAULT;
     }
 
     CPLDebug("PL/SQL","\n%s\n", pszStatement);
@@ -753,6 +749,29 @@
 
 }
 
+void OWStatement::Bind( OCILobLocator** pphLocator )
+{
+    OCIBind* hBind = NULL;
+
+    nNextBnd++;
+
+    CheckError( OCIBindByPos(
+        hStmt,
+        &hBind,
+        hError,
+        (ub4) nNextBnd,
+        (dvoid*) pphLocator,
+        (sb4) -1,
+        (ub2) SQLT_CLOB,
+        (void*) NULL,
+        (ub2*) NULL,
+        (ub2*) NULL,
+        (ub4) NULL,
+        (ub4) NULL,
+        (ub4) OCI_DEFAULT ),
+        hError );
+}
+
 void OWStatement::Bind( OCIArray** pphData, OCIType* type )
 {
     OCIBind* hBind = NULL;
@@ -917,6 +936,49 @@
         hError );
 }
 
+void OWStatement::WriteCLob( OCILobLocator** pphLocator, char* pszData )
+{
+    nNextCol++;
+
+    CheckError( OCIDescriptorAlloc(


More information about the Liblas-commits mailing list