[Liblas-commits] libpc: more OCI block construction work

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Mar 11 18:12:06 EST 2011


details:   http://hg.liblas.orglibpc/rev/a49ba245c385
changeset: 216:a49ba245c385
user:      Howard Butler <hobu.inc at gmail.com>
date:      Fri Mar 11 17:12:01 2011 -0600
description:
more OCI block construction work

diffstat:

 src/drivers/oci/writer.cpp |  75 ++++++++++++++++++++++++++++++++++++++++++++++
 src/drivers/oci/writer.hpp |   2 +
 2 files changed, 77 insertions(+), 0 deletions(-)

diffs (101 lines):

diff -r 44076c9385ab -r a49ba245c385 src/drivers/oci/writer.cpp
--- a/src/drivers/oci/writer.cpp	Fri Mar 11 14:56:11 2011 -0800
+++ b/src/drivers/oci/writer.cpp	Fri Mar 11 17:12:01 2011 -0600
@@ -685,10 +685,85 @@
     return;
 }
 
+bool Writer::FillOraclePointData(PointData const& buffer, std::vector<boost::uint8_t>& point_data)
+{
+
+
+    libpc::Schema const& schema = buffer.getSchema();
+
+    bool hasTimeData = schema.hasDimension(Dimension::Field_GpsTime);
+    
+    boost::uint64_t count = buffer.getNumPoints();
+
+    const int indexX = schema.getDimensionIndex(Dimension::Field_X);
+    const int indexY = schema.getDimensionIndex(Dimension::Field_Y);
+    const int indexZ = schema.getDimensionIndex(Dimension::Field_Z);
+    const int indexClassification = schema.getDimensionIndex(Dimension::Field_Classification);
+    const int indexTime = schema.getDimensionIndex(Dimension::Field_GpsTime);
+    
+    Dimension const& dimX = schema.getDimension(indexX);
+    Dimension const& dimY = schema.getDimension(indexY);
+    Dimension const& dimZ = schema.getDimension(indexZ);
+
+    double xscale = dimX.getNumericScale();
+    double yscale = dimY.getNumericScale();
+    double zscale = dimY.getNumericScale();
+        
+    double xoffset = dimX.getNumericOffset();
+    double yoffset = dimY.getNumericOffset();
+    double zoffset = dimZ.getNumericOffset();
+    
+    boost::uint32_t counter = 0;
+    while (counter < count)
+    {
+
+        const double x = (buffer.getField<boost::int32_t>(counter, indexX) * xscale) + xoffset;
+        const double y = (buffer.getField<boost::int32_t>(counter, indexY) * yscale) + yoffset;
+        const double z = (buffer.getField<boost::int32_t>(counter, indexZ) * zscale) + zoffset;
+        
+        double t = 0.0;
+        if (hasTimeData)
+            t = buffer.getField<double>(counter, indexTime);
+            
+        counter++;
+    }
+    
+    return true;
+}
+
 
 boost::uint32_t Writer::writeBuffer(const PointData& pointData)
 {
     boost::uint32_t numPoints = pointData.getNumPoints();
+
+    libpc::Header const& header = m_stage.getHeader();
+    libpc::Schema const& schema = header.getSchema();
+
+    PointData buffer(schema, 1);
+
+    
+    for ( boost::uint32_t i = 0; i < m_chipper.GetBlockCount(); ++i )
+    {
+        const chipper::Block& b = m_chipper.GetBlock(i);
+        
+        PointData block(schema, m_options.GetPTree().get<boost::uint32_t>("capacity"));
+        std::vector<boost::uint32_t> ids = b.GetIDs();
+        
+        std::vector<boost::uint32_t>::const_iterator it;
+        
+        boost::uint32_t count = 0;
+        for (it = ids.begin(); it != ids.end(); it++)
+        {
+            m_stage.seekToPoint(*it);
+            m_stage.read(buffer);
+            
+            block.copyPointsFast(static_cast<std::size_t>(count), static_cast<std::size_t>(0), buffer, 1); // put single point onto our block
+
+            count++;
+
+        }
+        
+    }
     // bool hasTimeData = false;
     // bool hasColorData = false;
     // bool hasWaveData = false;
diff -r 44076c9385ab -r a49ba245c385 src/drivers/oci/writer.hpp
--- a/src/drivers/oci/writer.hpp	Fri Mar 11 14:56:11 2011 -0800
+++ b/src/drivers/oci/writer.hpp	Fri Mar 11 17:12:01 2011 -0600
@@ -127,6 +127,8 @@
     bool IsGeographic(boost::int32_t srid);
     std::string LoadSQLData(std::string const& filename);
     
+    bool FillOraclePointData(PointData const& buffer, std::vector<boost::uint8_t>& point_data);
+    
     Stage& m_stage;
     chipper::Chipper m_chipper;
     


More information about the Liblas-commits mailing list