[Liblas-commits] hg-main-tree: some support for QUERY_SDO_PC_BLK_TYPE queries, bu...

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Jun 9 09:27:32 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/8ec3b1d75d97
changeset: 761:8ec3b1d75d97
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jun 09 08:27:21 2011 -0500
description:
some support for QUERY_SDO_PC_BLK_TYPE queries, but it doesn't really work yet

diffstat:

 include/libpc/drivers/oci/Common.hpp    |    3 +-
 include/libpc/drivers/oci/Reader.hpp    |    1 +
 include/libpc/drivers/oci/oci_wrapper.h |   21 ++---
 src/drivers/oci/Reader.cpp              |  110 +++++++------------------------
 src/drivers/oci/oci_wrapper.cpp         |   25 ++++++-
 5 files changed, 62 insertions(+), 98 deletions(-)

diffs (274 lines):

diff -r f25b3be0a0cd -r 8ec3b1d75d97 include/libpc/drivers/oci/Common.hpp
--- a/include/libpc/drivers/oci/Common.hpp	Mon Jun 06 16:58:08 2011 -0500
+++ b/include/libpc/drivers/oci/Common.hpp	Thu Jun 09 08:27:21 2011 -0500
@@ -120,8 +120,7 @@
 enum QueryType
 {
     QUERY_SDO_PC,
-    QUERY_SDO_PC_BLK,
-    QUERY_BLK_TABLE,
+    QUERY_SDO_PC_BLK_TYPE,
     QUERY_UNKNOWN
 };
 
diff -r f25b3be0a0cd -r 8ec3b1d75d97 include/libpc/drivers/oci/Reader.hpp
--- a/include/libpc/drivers/oci/Reader.hpp	Mon Jun 06 16:58:08 2011 -0500
+++ b/include/libpc/drivers/oci/Reader.hpp	Thu Jun 09 08:27:21 2011 -0500
@@ -97,6 +97,7 @@
     // BlockPtr m_block;
     Schema m_schema;
     sdo_pc* m_pc;
+    sdo_pc_blk* m_pc_block;
 
 };
 
diff -r f25b3be0a0cd -r 8ec3b1d75d97 include/libpc/drivers/oci/oci_wrapper.h
--- a/include/libpc/drivers/oci/oci_wrapper.h	Mon Jun 06 16:58:08 2011 -0500
+++ b/include/libpc/drivers/oci/oci_wrapper.h	Thu Jun 09 08:27:21 2011 -0500
@@ -255,17 +255,14 @@
 
 struct sdo_pc_blk
 {
-    OCINumber           obj_id;
-    OCINumber           blk_id;
-    SDO_GEOMETRY_TYPE   blk_extent;
-    SDO_ORGSCL_TYPE     blk_domain;
-    OCINumber           pcblk_min_res;
-    OCINumber           pcblk_max_res;
-    OCINumber           num_points;
-    OCINumber           num_unsorted_points;
-    OCINumber           pt_sort_dim;
-    void*               points;
+    SDO_PC_TYPE              inp;
+    SDO_GEOMETRY_TYPE   ind_dimqry;
+    SDO_MBR_TYPE     other_dimqry;
+    OCINumber           qry_min_res;
+    OCINumber           qry_max_res;
+    OCINumber           blkno;
 };
+
 typedef struct sdo_pc_blk SDO_PC_BLK_TYPE;
 
 struct sdo_pc_blk_type_ind
@@ -349,6 +346,8 @@
     void                DestroyType( sdo_geometry** pphData );
     void                CreateType( sdo_pc** pphData );
     void                DestroyType( sdo_pc** pphData );
+    void                CreateType( sdo_pc_blk** pphData );
+    void                DestroyType( sdo_pc_blk** pphData );
     void                CreateType( sdo_orgscl_type** pphData );
     void                DestroyType( sdo_orgscl_type** pphData );
     void                CreateType( OCIArray** phData , OCIType* type);
@@ -438,8 +437,8 @@
     void                Define( sdo_georaster** pphData );
     void                Define( sdo_geometry** pphData );
     void                Define( sdo_pc** pphData );
+    void                Define( sdo_pc_blk** pphData );
     void                Define( sdo_orgscl_type** pphData );
-    void                Define( sdo_pc_blk** pphData );
     void                Define( OCILobLocator** pphLocator, long nIterations );
     void                DefineClob( OCILobLocator** pphLocator, long nIterations );
     void                BindName( const char* pszName, int* pnData );
diff -r f25b3be0a0cd -r 8ec3b1d75d97 src/drivers/oci/Reader.cpp
--- a/src/drivers/oci/Reader.cpp	Mon Jun 06 16:58:08 2011 -0500
+++ b/src/drivers/oci/Reader.cpp	Thu Jun 09 08:27:21 2011 -0500
@@ -79,9 +79,22 @@
         Schema& schema = getSchemaRef(); 
         schema = fetchSchema(m_pc);
     }
+    else if (m_querytype == QUERY_SDO_PC_BLK_TYPE)
+    {
+        m_connection->CreateType(&m_pc_block);
+        // m_connection->CreateType(&(m_pc_block->inp));
+        m_statement->Define(&m_pc_block);
+
+        bool bDidRead = m_statement->Fetch(); 
+    
+        if (!bDidRead) throw libpc_error("Unable to fetch a point cloud entry entry!");
+        Schema& schema = getSchemaRef(); 
+        schema = fetchSchema(m_pc);
+        
+    }
     
     else 
-        throw libpc_error("SQL statement does not define a SDO_PC or CLIP_CP block");
+        throw libpc_error("SQL statement does not define a SDO_PC or CLIP_PC block");
 
 
 
@@ -334,95 +347,24 @@
     int   nPrecision = 0;
     signed short nScale = 0;
     char szTypeName[OWNAME];
-    
-    bool isPCObject = false;
-    bool isBlockTableQuery = false;
-    bool isBlockTableType = false;
-    
-    
-    const int columns_size = 10;
-    std::string block_columns[columns_size];
-    block_columns[0] = "OBJ_ID";
-    block_columns[1] = "BLK_ID";
-    block_columns[2] = "BLK_EXTENT";
-    block_columns[3] = "BLK_DOMAIN";
-    block_columns[4] = "PCBLK_MIN_RES";
-    block_columns[5] = "PCBLK_MAX_RES";
-    block_columns[6] = "NUM_POINTS";
-    block_columns[7] = "NUM_UNSORTED_POINTS";
-    block_columns[8] = "PT_SORT_DIM";
-    block_columns[9] = "POINTS";
-    
-    std::map<std::string, bool> columns_map;
 
-    for(int i = 0; i < columns_size; ++i)
-    {
-        columns_map.insert(std::pair<std::string, bool>(block_columns[i], false));
-    }
-    
     while( m_statement->GetNextField(iCol, szFieldName, &hType, &nSize, &nPrecision, &nScale, szTypeName) )
     {
-        std::string name = to_upper(std::string(szFieldName));
-        
-        std::map<std::string, bool>::iterator it = columns_map.find(name);
-        if (it != columns_map.end())
-        {
-            // std::cout << "setting columns to true for " << it->first << std::endl;
-            (*it).second = true;
-            
-        }
 
         if ( hType == SQLT_NTY)
         {
-                
+                // std::cout << "Field " << szFieldName << " is SQLT_NTY with type name " << szTypeName  << std::endl;
                 if (compare_no_case(szTypeName, "SDO_PC") == 0)
-                    isPCObject = true;
+                    return QUERY_SDO_PC;
                 if (compare_no_case(szTypeName, "SDO_PC_BLK_TYPE") == 0)
-                    isBlockTableType = true;
-                // std::cout << "Field " << szFieldName << " is SQLT_NTY with type name " << szTypeName  << std::endl;
+                    return QUERY_SDO_PC_BLK_TYPE;
         }
-
-        iCol++;
     }
 
-    // Assume we're a block table until we say we aren't.  Loop through all of 
-    // the required columns that make up a block table and if we find one that 
-    // wasn't marked in the loop above, we're not a block table.
-    isBlockTableQuery = true;
-    std::map<std::string, bool>::iterator it = columns_map.begin();
-    while (it != columns_map.end())
-    {   
-        if (it->second == false) 
-        {
-            isBlockTableQuery = false; 
-            break;
-        }
-        ++it;
-    }
-    
-    // If we have all of the block table columns + some extras, we aren't a block table for now
-    if (iCol != 10 && isBlockTableQuery) {
-        isBlockTableQuery = false;
-    }
-    
-    if (!isBlockTableQuery && !isPCObject) 
-    {
-        std::ostringstream oss;
-        oss << "Select statement '" << getQuery() << "' does not fetch an SDO_PC object" 
-              " or one that is equivalent to SDO_PC_BLK_TYPE";
-        throw libpc_error(oss.str());
-    }
-
-    if (isBlockTableQuery) 
-        return QUERY_BLK_TABLE;
-    
-    if (isPCObject)
-        return QUERY_SDO_PC;
-    
-    if (isBlockTableType)
-        return QUERY_SDO_PC_BLK;
-    
-    return QUERY_UNKNOWN;
+    std::ostringstream oss;
+    oss << "Select statement '" << getQuery() << "' does not fetch an SDO_PC object" 
+          " or SDO_PC_BLK_TYPE";
+    throw libpc_error(oss.str());
 }
 
 BlockPtr Reader::defineBlock() const
@@ -534,9 +476,9 @@
     Statement get_schema(m_connection->CreateStatement(select_schema.str().c_str()));
     get_schema->BindName( ":metadata", &metadata );
     
-    int capacity_length = 1024;
-    char* capacity = (char*) malloc (sizeof(char*) * capacity_length);
-    get_schema->BindName( ":capacity", capacity, capacity_length );
+    int ptn_params_length = 1024;
+    char* ptn_params = (char*) malloc (sizeof(char*) * ptn_params_length);
+    get_schema->BindName( ":capacity", ptn_params, ptn_params_length );
     get_schema->Execute();
     
     char* pc_schema = get_schema->ReadCLob(metadata);
@@ -551,7 +493,7 @@
     boost::char_separator<char> sep_space(" ");
     boost::char_separator<char> sep_equal("=");
 
-    std::string s_cap(capacity);
+    std::string s_cap(ptn_params);
     tokenizer parameters(s_cap, sep_space);
     for (tokenizer::iterator t = parameters.begin(); t != parameters.end(); ++t) {
         tokenizer parameter((*t), sep_equal);
@@ -577,7 +519,7 @@
     
     std::string pc_schema_xml(pc_schema);
     CPLFree(pc_schema);
-    free(capacity);
+    free(ptn_params);
     Schema schema = Schema::from_xml(pc_schema_xml);
 
     return schema;
diff -r f25b3be0a0cd -r 8ec3b1d75d97 src/drivers/oci/oci_wrapper.cpp
--- a/src/drivers/oci/oci_wrapper.cpp	Mon Jun 06 16:58:08 2011 -0500
+++ b/src/drivers/oci/oci_wrapper.cpp	Thu Jun 09 08:27:21 2011 -0500
@@ -352,6 +352,30 @@
         (ub2) 0), NULL );
 }
 
+void OWConnection::CreateType( sdo_pc_blk** pphData )
+{
+    CheckError( OCIObjectNew(
+        hEnv,
+        hError,
+        hSvcCtx,
+        OCI_TYPECODE_OBJECT,
+        hPC_BLK_TDO,
+        (dvoid *) 0,
+        OCI_DURATION_CALL,
+        TRUE,
+        (dvoid **) pphData), hError );
+}
+
+void OWConnection::DestroyType( sdo_pc_blk** pphData )
+{
+    CheckError( OCIObjectFree(
+        hEnv,
+        hError,
+        (dvoid*) *pphData,
+        (ub2) 0), NULL );
+}
+
+
 void OWConnection::CreateType( sdo_orgscl_type** pphData )
 {
     CheckError( OCIObjectNew(
@@ -1409,7 +1433,6 @@
         (ub4*) NULL ), hError );
 }
 
-
 void OWStatement::Define( sdo_orgscl_type** pphData )
 {
     OCIDefine* hDefine = NULL;


More information about the Liblas-commits mailing list