[Liblas-commits] hg-main-tree: a good stopping point
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Apr 6 23:16:16 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/82cabe497436
changeset: 504:82cabe497436
user: Howard Butler <hobu.inc at gmail.com>
date: Wed Apr 06 21:19:59 2011 -0500
description:
a good stopping point
diffstat:
include/libpc/drivers/oci/Common.hpp | 7 +-
include/libpc/drivers/oci/Iterator.hpp | 4 +-
src/drivers/oci/Iterator.cpp | 133 +++++++++++++++++++++++++-------
src/drivers/oci/common.cpp | 18 ++++
4 files changed, 129 insertions(+), 33 deletions(-)
diffs (278 lines):
diff -r 8f814eb3342f -r 82cabe497436 include/libpc/drivers/oci/Common.hpp
--- a/include/libpc/drivers/oci/Common.hpp Tue Apr 05 15:10:07 2011 -0700
+++ b/include/libpc/drivers/oci/Common.hpp Wed Apr 06 21:19:59 2011 -0500
@@ -40,6 +40,8 @@
#include "oci_wrapper.h"
#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
+
#include <boost/property_tree/ptree.hpp>
#include <cpl_port.h>
@@ -77,7 +79,8 @@
public:
- Block() {};
+ Block(Connection connection);
+ ~Block() ;
boost::int32_t obj_id;
boost::int32_t blk_id;
@@ -89,6 +92,8 @@
boost::int32_t num_points;
boost::int32_t num_unsorted_points;
boost::int32_t pt_sort_dim;
+ boost::scoped_ptr<std::vector<uint8_t> > chunk;
+ Connection m_connection;
private:
diff -r 8f814eb3342f -r 82cabe497436 include/libpc/drivers/oci/Iterator.hpp
--- a/include/libpc/drivers/oci/Iterator.hpp Tue Apr 05 15:10:07 2011 -0700
+++ b/include/libpc/drivers/oci/Iterator.hpp Wed Apr 06 21:19:59 2011 -0500
@@ -57,6 +57,7 @@
const Reader& getReader() const;
boost::uint32_t readBuffer(PointBuffer& data);
+ boost::uint32_t unpackOracleData(PointBuffer& data);
Statement m_statement;
bool m_at_end;
@@ -66,8 +67,7 @@
sdo_pc* m_pc;
sdo_pc_blk* m_block_table_type;
- std::vector<boost::uint8_t> m_points;
- boost::uint32_t m_blob_read_byte_size;
+ std::vector<boost::uint8_t>::size_type m_points;
private:
const Reader& m_reader;
diff -r 8f814eb3342f -r 82cabe497436 src/drivers/oci/Iterator.cpp
--- a/src/drivers/oci/Iterator.cpp Tue Apr 05 15:10:07 2011 -0700
+++ b/src/drivers/oci/Iterator.cpp Wed Apr 06 21:19:59 2011 -0500
@@ -49,6 +49,7 @@
IteratorBase::IteratorBase(const Reader& reader)
: m_at_end(false)
+ , m_block(0)
, m_reader(reader)
{
@@ -70,14 +71,8 @@
else if (m_querytype == QUERY_BLK_TABLE)
{
doBlockTableDefine();
- reader.getConnection()->CreateType(&(m_block->blk_extent));
- reader.getConnection()->CreateType(&(m_block->blk_extent->sdo_ordinates), reader.getConnection()->GetOrdinateType());
- reader.getConnection()->CreateType(&(m_block->blk_extent->sdo_elem_info), reader.getConnection()->GetElemInfoType());
+ }
- }
-
- // setNumPoints(1000);
-
return;
}
@@ -93,35 +88,98 @@
return m_reader;
}
+boost::uint32_t IteratorBase::unpackOracleData(PointBuffer& data)
+{
+
+ return 0;
+}
boost::uint32_t IteratorBase::readBuffer(PointBuffer& data)
{
- boost::uint32_t numPoints = data.getCapacity();
+ boost::uint32_t requestedNumPoints = data.getCapacity();
+ boost::uint32_t numPointsRead = 0;
+ bool bDidRead = false;
- bool bDidRead = m_statement->Fetch();
- if (!bDidRead)
+ std::cout << " Existing block has " << m_block->num_points << " points" << std::endl;
+
+ if (!m_block->num_points)
{
- m_at_end = true;
- return 0;
+ // We still have a block of data from the last readBuffer call
+ // that was partially read.
+ std::cout << "reading because we have no points" << std::endl;
+ bDidRead = m_statement->Fetch();
+ if (!bDidRead)
+ {
+ m_at_end = true;
+ return 0;
+ }
+
+ } else
+ {
+ // Our read was already "done" last readBuffer call, but if we're done,
+ // we're done
+ if (m_at_end) return 0;
+ bDidRead = true;
+ std::cout << "we already had points in our cache, using those" << std::endl;
+
+
}
- std::cout << "This block has " << m_block->num_points << " points" << std::endl;
+
+
+
- boost::uint32_t nAmountRead;
+ while (bDidRead)
+ {
+
+ std::cout << "This block has " << m_block->num_points << " points" << std::endl;
+
+ numPointsRead = numPointsRead + m_block->num_points;
+ if (numPointsRead > requestedNumPoints)
+ {
+ // We're done. We still have more data, but the
+ // user is going to have to request another buffer.
+ // We're not going to fill the buffer up to *exactly*
+ // the number of points the user requested.
+ // If the buffer's capacity isn't large enough to hold
+ // an oracle block, they're just not going to get anything
+ // back right now (FIXME)
+ break;
+ }
+
+ boost::uint32_t nAmountRead;
- std::vector<boost::uint8_t> chunk;// = iterator.getChunk();
- boost::uint32_t blob_length = m_statement->GetBlobLength(m_locator);
+ boost::uint32_t blob_length = m_statement->GetBlobLength(m_locator);
+ std::cout << "blob_length: " << blob_length << std::endl;
- if (chunk.size() < blob_length)
- {
- chunk.resize(blob_length);
- }
- bool read_all_data = m_statement->ReadBlob( m_locator,
- (void*)(&chunk[0]),
- chunk.size(),
- &nAmountRead);
- if (!read_all_data) throw libpc_error("Did not read all blob data!");
- std::cout << "nAmountRead: " << nAmountRead << std::endl;
+ if (m_block->chunk->size() < blob_length)
+ {
+ m_block->chunk->resize(blob_length);
+ }
+ // std::vector<boost::uint8_t> chunk;
+ // if (chunk.size() < blob_length)
+ // {
+ // chunk.resize(blob_length);
+ // }
+ std::cout << " m_block->chunk->size() : " << m_block->chunk->size()<< std::endl;
+
+ bool read_all_data = m_statement->ReadBlob( m_locator,
+ (void*)(&(*m_block->chunk)[0]),
+ m_block->chunk->size(),
+ &nAmountRead);
+ if (!read_all_data) throw libpc_error("Did not read all blob data!");
+ std::cout << "nAmountRead: " << nAmountRead << " m_block->chunk->size() : " << m_block->chunk->size()<< std::endl;
+
+ bDidRead = m_statement->Fetch();
+ if (!bDidRead)
+ {
+ m_at_end = true;
+ return numPointsRead;
+ }
+ }
+
+
+
double x, y, z;
@@ -134,7 +192,17 @@
gtype= m_statement->GetInteger(&(m_block->blk_extent->sdo_gtype));
srid =m_statement->GetInteger(&(m_block->blk_extent->sdo_srid));
+ gtype = 2304;
std::cout << "gtype: " << gtype << std::endl;
+
+ // See http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28400/sdo_objrelschema.htm#g1013735
+
+ boost::uint32_t dimension = gtype / 1000;
+ boost::uint32_t geom_type = gtype % 100;
+ boost::uint32_t referencing= ((gtype % 1000) / 100);
+ std::cout << "dimension: " << dimension << " geometry type: " << geom_type << " referencing " << referencing << std::endl;
+
+
std::cout << "srid: " << srid << std::endl;
std::cout << "elem1, elem2, elem3 " << elem1 << " " << elem2 << " " << elem3 << std::endl;
@@ -255,7 +323,7 @@
//
// }
- return numPoints;
+ return numPointsRead;
}
@@ -269,8 +337,14 @@
int nPrecision = 0;
signed short nScale = 0;
char szTypeName[OWNAME];
+
+ if (!m_block)
+ m_block = new Block(m_reader.getConnection());
- m_block = new Block;
+ m_block->num_points = 0;
+
+
+
// block_columns[0] = "OBJ_ID";
// block_columns[1] = "BLK_ID";
@@ -283,8 +357,7 @@
// block_columns[8] = "PT_SORT_DIM";
// block_columns[9] = "POINTS";
- m_reader.getConnection()->CreateType(&(m_block->blk_extent));
- m_reader.getConnection()->CreateType(&(m_block->blk_domain));
+
while( m_statement->GetNextField(iCol, szFieldName, &hType, &nSize, &nPrecision, &nScale, szTypeName) )
{
diff -r 8f814eb3342f -r 82cabe497436 src/drivers/oci/common.cpp
--- a/src/drivers/oci/common.cpp Tue Apr 05 15:10:07 2011 -0700
+++ b/src/drivers/oci/common.cpp Wed Apr 06 21:19:59 2011 -0500
@@ -132,6 +132,24 @@
}
+Block::Block(Connection connection)
+ : num_points(0)
+ , chunk(new std::vector<boost::uint8_t>)
+ , m_connection(connection)
+{
+ m_connection->CreateType(&blk_extent);
+ m_connection->CreateType(&blk_extent->sdo_ordinates, m_connection->GetOrdinateType());
+ m_connection->CreateType(&blk_extent->sdo_elem_info, m_connection->GetElemInfoType());
+ m_connection->CreateType(&blk_domain);
+}
+
+Block::~Block()
+{
+ m_connection->DestroyType(&blk_extent->sdo_ordinates);
+ m_connection->DestroyType(&blk_extent->sdo_elem_info);
+ m_connection->DestroyType(&blk_extent);
+ m_connection->DestroyType(&blk_domain);
+}
std::string to_upper(const std::string& input)
{
std::string inp = std::string(input);
More information about the Liblas-commits
mailing list