[Liblas-commits] hg: las2oci is working again (but not fast)

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Aug 3 14:37:19 EDT 2010


changeset 97cf289d06da in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=97cf289d06da
summary: las2oci is working again (but not fast)

diffstat:

 apps/kdx_util.cpp  |   112 +++++
 apps/kdx_util.hpp  |     2 +
 apps/las2oci.cpp   |  1158 ++++++++++++++++++++++++++++-----------------------
 apps/las2oci.hpp   |    22 +-
 apps/oci_util.cpp  |    66 ++-
 apps/oci_util.hpp  |     8 +-
 apps/oci_wrapper.h |     2 +
 7 files changed, 833 insertions(+), 537 deletions(-)

diffs (truncated from 1680 to 300 lines):

diff -r 948a7443de1e -r 97cf289d06da apps/kdx_util.cpp
--- a/apps/kdx_util.cpp	Tue Aug 03 11:23:17 2010 -0500
+++ b/apps/kdx_util.cpp	Tue Aug 03 13:37:12 2010 -0500
@@ -53,6 +53,118 @@
     bounds = boost::shared_ptr<liblas::Bounds>(new liblas::Bounds(mins[0], mins[1], maxs[0], maxs[1]));
 }
 
+bool GetPointData(  liblas::Point const& p, 
+                    // bool bTime, 
+                    std::vector<uint8_t>& point_data)
+{
+    // This function returns an array of bytes describing the 
+    // x,y,z and optionally time values for the point.  
+
+    point_data.clear();
+
+    double x = p.GetX();
+    double y = p.GetY();
+    double z = p.GetZ();
+    // double t = p.GetTime();
+
+    uint8_t* x_b =  reinterpret_cast<uint8_t*>(&x);
+    uint8_t* y_b =  reinterpret_cast<uint8_t*>(&y);
+    uint8_t* z_b =  reinterpret_cast<uint8_t*>(&z);
+
+    // liblas::uint8_t* t_b =  reinterpret_cast<liblas::uint8_t*>(&t);
+
+    // doubles are 8 bytes long.  For each double, push back the 
+    // byte.  We do this for all four values (x,y,z,t)
+
+    // // little-endian
+    // for (int i=0; i<sizeof(double); i++) {
+    //     point_data.push_back(y_b[i]);
+    // }
+    // 
+
+    // big-endian
+    for (int i = sizeof(double) - 1; i >= 0; i--) {
+        point_data.push_back(x_b[i]);
+    }
+
+    for (int i = sizeof(double) - 1; i >= 0; i--) {
+        point_data.push_back(y_b[i]);
+    }   
+
+    for (int i = sizeof(double) - 1; i >= 0; i--) {
+        point_data.push_back(z_b[i]);
+    }
+
+    
+    // if (bTime)
+    // {
+    //     for (int i = sizeof(double) - 1; i >= 0; i--) {
+    //         point_data.push_back(t_b[i]);
+    //     }
+    // 
+    // }
+
+    return true;
+}
+
+void IndexResult::GetData(liblas::Reader* reader, std::vector<uint8_t>& data)
+{
+    IDVector const& ids = GetIDs();
+
+
+    // d 8-byte IEEE  big-endian doubles, where d is the PC_TOT_DIMENSIONS value
+    // 4-byte big-endian integer for the BLK_ID value
+    // 4-byte big-endian integer for the PT_ID value
+    
+    
+    data.clear(); 
+    
+    IDVector::const_iterator i;
+    std::vector<uint8_t>::iterator pi;
+    
+    uint32_t block_id = GetID();
+
+    std::vector<uint8_t> point_data;
+    
+    for (i=ids.begin(); i!=ids.end(); ++i) 
+    {
+        uint32_t id = *i;
+
+        bool doRead = reader->ReadPointAt(id);
+        if (doRead) {
+            liblas::Point const& p = reader->GetPoint();
+
+            // d 8-byte IEEE  big-endian doubles, where d is the PC_TOT_DIMENSIONS value
+            
+            
+            bool gotdata = GetPointData(p, point_data);
+            
+            if (!gotdata) { throw std::runtime_error("Unable to fetch Point Data"); exit(1);}
+            std::vector<uint8_t>::const_iterator d;
+            for (d = point_data.begin(); d!=point_data.end(); ++d) {
+                data.push_back(*d);
+            }
+
+            uint8_t* id_b = reinterpret_cast<uint8_t*>(&id);
+            uint8_t* block_b = reinterpret_cast<uint8_t*>(&block_id);
+            
+            // 4-byte big-endian integer for the BLK_ID value
+            for (int i =  sizeof(uint32_t) - 1; i >= 0; i--) {
+                data.push_back(block_b[i]);
+            }
+            
+            // 4-byte big-endian integer for the PT_ID value
+            for (int i =  sizeof(uint32_t) - 1; i >= 0; i--) {
+                data.push_back(id_b[i]);
+            }
+            
+
+        }
+    }
+
+}
+
+
 bool KDTreeIndexExists(std::string& filename)
 {
     struct stat stats;
diff -r 948a7443de1e -r 97cf289d06da apps/kdx_util.hpp
--- a/apps/kdx_util.hpp	Tue Aug 03 11:23:17 2010 -0500
+++ b/apps/kdx_util.hpp	Tue Aug 03 13:37:12 2010 -0500
@@ -27,6 +27,8 @@
     void SetBounds(const liblas::Bounds b) {bounds = b;}
     uint32_t GetID() const {return m_id;}
     void SetID(uint32_t v) {m_id = v;}
+    
+    void GetData(liblas::Reader* reader, std::vector<uint8_t>& data);
 
 private:
 
diff -r 948a7443de1e -r 97cf289d06da apps/las2oci.cpp
--- a/apps/las2oci.cpp	Tue Aug 03 11:23:17 2010 -0500
+++ b/apps/las2oci.cpp	Tue Aug 03 13:37:12 2010 -0500
@@ -11,118 +11,9 @@
 
 
 
-bool DeleteTable(   OWConnection* connection, 
-                    const char* tableName, 
-                    const char* cloudTableName, 
-                    const char* cloudColumnName)
-{
-    ostringstream oss;
-    OWStatement* statement = 0;
 
-    oss << "DELETE from " <<cloudTableName;
-    statement = RunSQL(connection, oss);
-    if (statement != 0) delete statement; else 
-    {
-        // if we failed, try dropping the index
-        std::cout << "Dropping index ..." << std::endl;
-        oss.str("");  
-        oss << "DROP INDEX "<<tableName<<"_cloud_idx" ;
-        statement = RunSQL(connection, oss);
-        if (statement != 0) delete statement; else return false;
-        oss.str("");
-        
-        // redelete from the table
-        oss << "DELETE from " <<cloudTableName;
-        statement = RunSQL(connection, oss);
-        if (statement != 0) delete statement; else return false;
-        oss.str("");
-    }
-    oss.str("");
-    
-    std::string cloudColumnName_u = to_upper(cloudColumnName);
-    std::string cloudTableName_u = to_upper(cloudTableName);
 
 
-oss << "declare\n"
-"begin \n"
-"  mdsys.sdo_pc_pkg.drop_dependencies('"<<cloudTableName_u<<"', '"<<cloudColumnName_u<<"');"
-"end;";
-    statement = RunSQL(connection, oss);
-    if (statement != 0) delete statement; 
-    oss.str("");
-    
-    oss << "DROP TABLE "<< tableName ;
-    statement = RunSQL(connection, oss);
-    if (statement != 0) delete statement; 
-    oss.str("");
-
-    // Oracle upper cases the table name when inserting it in the 
-    // USER_SDO_GEOM_METADATA.  We'll use std::transform to do it. 
-    // See http://forums.devx.com/showthread.php?t=83058 for the 
-    // technique
-    // string table(tableName);
-    std::string table = to_upper(tableName);
-    oss << "DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='"<<table<<"'" ;
-    statement = RunSQL(connection, oss);
-    if (statement != 0) delete statement; else return false;
-    oss.str("");   
-
-    connection->Commit();
-   
-    return true;
-
-}
-
-bool GetResultData( const IndexResult& result, 
-                    liblas::Reader* reader, 
-                    std::vector<double>& data,
-                    int nDimension)
-{
-    IDVector const& ids = result.GetIDs();
-    // list<SpatialIndex::id_type> const& ids = result.GetIDs();
-
-
-    // d 8-byte IEEE  big-endian doubles, where d is the PC_TOT_DIMENSIONS value
-    // 4-byte big-endian integer for the BLK_ID value
-    // 4-byte big-endian integer for the PT_ID value
-    
-    // if (nDimension == 4)
-    // {
-    //     bTime = true;
-    // }
-    
-    data.clear();
-
-    IDVector::const_iterator i;
-    vector<uint8_t>::iterator pi;    
-    
-    // list<SpatialIndex::id_type>::const_iterator i;
-//    vector<uint8_t>::iterator pi;
-    
-//    uint32_t block_id = result.GetID();
-
-    std::vector<uint8_t> point_data;
-    
-    for (i=ids.begin(); i!=ids.end(); ++i) 
-    {
-        uint32_t id = *i;
-        // SpatialIndex::id_type id = *i;
-
-        bool doRead = reader->ReadPointAt(id);
-
-        if (doRead) {
-
-            liblas::Point const& p = reader->GetPoint();
-
-            data.push_back( p.GetX() );
-            data.push_back( p.GetY() );
-            data.push_back( p.GetZ() );
-            data.push_back( p.GetIntensity() );
-        }
-    }
-
-    return true;
-}
 
 void SetElements(   OWStatement* statement,
                     OCIArray* sdo_elem_info, 
@@ -145,48 +36,75 @@
 
 void SetOrdinates(   OWStatement* statement,
                      OCIArray* sdo_ordinates, 
-                     extent* extent)
+                     liblas::Bounds const& extent)
 {
     
-    statement->AddElement(sdo_ordinates, extent->x0);
-    statement->AddElement(sdo_ordinates, extent->y0);
-    if (extent->bUse3d)
-        statement->AddElement(sdo_ordinates, extent->z0);
+    statement->AddElement(sdo_ordinates, extent.min(0));
+    statement->AddElement(sdo_ordinates, extent.min(1));
+    if (extent.dimension() > 2)
+        statement->AddElement(sdo_ordinates, extent.min(2));
     
-    statement->AddElement(sdo_ordinates, extent->x1);
-    statement->AddElement(sdo_ordinates, extent->y1);
-    if (extent->bUse3d)
-        statement->AddElement(sdo_ordinates, extent->z1);
+    statement->AddElement(sdo_ordinates, extent.max(0));
+    statement->AddElement(sdo_ordinates, extent.max(1));
+    if (extent.dimension() > 2)
+        statement->AddElement(sdo_ordinates, extent.max(2));
         
 
 }
 
-extent* GetExtent(  const liblas::Bounds b,
-                    bool bUse3d
-                 )
+
+bool FillBlock( OWStatement* statement,
+                IndexResult& result, 
+                liblas::Reader* reader,
+                blocks* b,
+                long index,
+                int srid, 
+                long pc_id,
+                long gtype,
+                bool bUseSolidGeometry,
+                bool bUse3d,
+                long nDimensions


More information about the Liblas-commits mailing list