[Liblas-commits] hg-main-tree: add support for ByteSwapper filter
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu May 26 14:16:03 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/f9ad104194ba
changeset: 745:f9ad104194ba
user: Howard Butler <hobu.inc at gmail.com>
date: Thu May 26 13:14:14 2011 -0500
description:
add support for ByteSwapper filter
Subject: hg-main-tree: return the actual number of points swapped instead of the capacity
details: http://hg.libpc.orghg-main-tree/rev/2b385d0bc13d
changeset: 746:2b385d0bc13d
user: Howard Butler <hobu.inc at gmail.com>
date: Thu May 26 13:14:53 2011 -0500
description:
return the actual number of points swapped instead of the capacity
Subject: hg-main-tree: decrufting
details: http://hg.libpc.orghg-main-tree/rev/3977b0274350
changeset: 747:3977b0274350
user: Howard Butler <hobu.inc at gmail.com>
date: Thu May 26 13:15:17 2011 -0500
description:
decrufting
Subject: hg-main-tree: start reworking to be able to use the ByteSwapper filter
details: http://hg.libpc.orghg-main-tree/rev/b537b4c8ab21
changeset: 748:b537b4c8ab21
user: Howard Butler <hobu.inc at gmail.com>
date: Thu May 26 13:15:52 2011 -0500
description:
start reworking to be able to use the ByteSwapper filter
diffstat:
apps/pc2pc.cpp | 14 +++++-
include/libpc/drivers/oci/Writer.hpp | 4 +-
src/drivers/oci/Writer.cpp | 27 ++++++++----
src/filters/ByteSwapFilter.cpp | 4 +-
src/filters/ByteSwapFilterIterator.cpp | 3 +-
src/filters/ChipperIterator.cpp | 74 +---------------------------------
6 files changed, 36 insertions(+), 90 deletions(-)
diffs (274 lines):
diff -r b7891eaf18fe -r b537b4c8ab21 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp Wed May 25 17:04:51 2011 -0500
+++ b/apps/pc2pc.cpp Thu May 26 13:15:52 2011 -0500
@@ -27,6 +27,7 @@
//#include <libpc/LasHeader.hpp>
#include <libpc/drivers/las/Writer.hpp>
#include <libpc/filters/CacheFilter.hpp>
+#include <libpc/filters/ByteSwapFilter.hpp>
#include <libpc/drivers/liblas/Writer.hpp>
#include <libpc/drivers/liblas/Reader.hpp>
@@ -150,9 +151,14 @@
boost::uint32_t capacity = tree.get<boost::uint32_t>("capacity");
- libpc::filters::CacheFilter cache(reader, 1, 1024);
+ libpc::filters::CacheFilter cache(reader, 1, capacity);
libpc::filters::Chipper chipper(cache, capacity);
- libpc::drivers::oci::Writer writer(chipper, options);
+ libpc::filters::ByteSwapFilter swapper(chipper);
+ libpc::drivers::oci::Writer writer(swapper, options);
+
+ // libpc::filters::CacheFilter cache(reader, 1, capacity);
+ // libpc::filters::Chipper chipper(cache, capacity);
+ // libpc::drivers::oci::Writer writer(chipper, options);
writer.write(numPoints);
boost::property_tree::ptree output_tree;
@@ -179,9 +185,11 @@
const boost::uint64_t numPoints = reader.getNumPoints();
+ libpc::filters::ByteSwapFilter swapper(reader);
- libpc::drivers::las::LasWriter writer(reader, *ofs);
+
+ libpc::drivers::las::LasWriter writer(swapper, *ofs);
if (hasOption("a_srs"))
diff -r b7891eaf18fe -r b537b4c8ab21 include/libpc/drivers/oci/Writer.hpp
--- a/include/libpc/drivers/oci/Writer.hpp Wed May 25 17:04:51 2011 -0500
+++ b/include/libpc/drivers/oci/Writer.hpp Thu May 26 13:15:52 2011 -0500
@@ -97,8 +97,7 @@
bool FillOraclePointBuffer(PointBuffer const& buffer,
std::vector<boost::uint8_t>& point_data);
- bool WriteBlock(PointBuffer const& buffer,
- std::vector<boost::uint8_t>& point_data);
+ bool WriteBlock(PointBuffer const& buffer);
void SetOrdinates(Statement statement,
OCIArray* ordinates,
@@ -110,6 +109,7 @@
bool isDebug() const;
bool is3d() const;
bool isSolid() const;
+ // PointBuffer& ConstructBuffer(const PointBuffer& input) const;
Stage& m_stage;
diff -r b7891eaf18fe -r b537b4c8ab21 src/drivers/oci/Writer.cpp
--- a/src/drivers/oci/Writer.cpp Wed May 25 17:04:51 2011 -0500
+++ b/src/drivers/oci/Writer.cpp Thu May 26 13:15:52 2011 -0500
@@ -1150,6 +1150,7 @@
libpc::Bounds<double> const& extent)
{
+ std::cout << extent << std::endl;
statement->AddElement(ordinates, extent.getMinimum(0));
statement->AddElement(ordinates, extent.getMaximum(1));
if (extent.dimensions().size() > 2)
@@ -1163,10 +1164,11 @@
}
-bool Writer::WriteBlock(PointBuffer const& buffer,
- std::vector<boost::uint8_t>& point_data)
+bool Writer::WriteBlock(PointBuffer const& buffer)
{
-
+
+ boost::uint8_t* point_data = buffer.getData(0);
+
boost::property_tree::ptree& tree = m_options.GetPTree();
std::string block_table_name = to_upper(tree.get<std::string>("block_table_name"));
@@ -1181,8 +1183,9 @@
// Pluck the block id out of the first point in the buffer
libpc::Schema const& schema = buffer.getSchema();
const int indexBlockId = schema.getDimensionIndex(Dimension::Field_User2, Dimension::Int32);
- long block_id = buffer.getField<boost::int32_t>(0, indexBlockId);
+ boost::int32_t block_id = buffer.getField<boost::int32_t>(0, indexBlockId);
+ SWAP_ENDIANNESS(block_id); //We've already swapped these data, but we need to write a real number here.
std::ostringstream oss;
std::ostringstream partition;
@@ -1227,6 +1230,8 @@
long* p_num_points = (long*) malloc (1 * sizeof(long));
p_num_points[0] = (long)buffer.getNumPoints();
+ std::cout << "point count on write: " << buffer.getNumPoints() << std::endl;
+
// :1
statement->Bind( p_pc_id );
@@ -1245,7 +1250,7 @@
// bool gotdata = GetResultData(result, reader, data, 3);
// if (! gotdata) throw std::runtime_error("unable to fetch point data byte array");
- statement->Bind((char*)&(point_data[0]),(long)point_data.size());
+ statement->Bind((char*)&(point_data[0]),(long)buffer.getSchemaLayout().getByteSize());
// :5
long* p_gtype = (long*) malloc (1 * sizeof(long));
@@ -1317,10 +1322,14 @@
boost::uint32_t Writer::writeBuffer(const PointBuffer& buffer)
{
boost::uint32_t numPoints = buffer.getNumPoints();
- std::vector<boost::uint8_t> oracle_buffer;
-
- FillOraclePointBuffer(buffer, oracle_buffer);
- WriteBlock(buffer, oracle_buffer);
+ std::cout << buffer.getSchemaLayout().getSchema();
+ // std::vector<boost::uint8_t> oracle_array;
+ //
+ // boost::uint8_t* raw_data = buffer.getData(0)
+ // PointBuffer& output_buffer = ConstructBuffer(buffer)
+ //
+ // FillOraclePointBuffer(output_buffer, oracle_array);
+ WriteBlock(buffer);
return numPoints;
}
diff -r b7891eaf18fe -r b537b4c8ab21 src/filters/ByteSwapFilter.cpp
--- a/src/filters/ByteSwapFilter.cpp Wed May 25 17:04:51 2011 -0500
+++ b/src/filters/ByteSwapFilter.cpp Thu May 26 13:15:52 2011 -0500
@@ -72,7 +72,9 @@
libpc::Schema::Dimensions const& dstDims = dstSchema.getDimensions();
+ dstData.setSpatialBounds(srcData.getSpatialBounds());
dstData.copyPointsFast(0, 0, srcData, srcData.getNumPoints());
+
dstData.setNumPoints(srcData.getNumPoints());
for (boost::uint32_t i = 0; i != dstData.getNumPoints(); ++i)
@@ -136,7 +138,7 @@
//
// assert(dstIndex <= dstData.getCapacity());
- dstData.setNumPoints(dstData.getCapacity());
+ // dstData.setNumPoints(dstData.getCapacity());
return dstData.getNumPoints();
}
diff -r b7891eaf18fe -r b537b4c8ab21 src/filters/ByteSwapFilterIterator.cpp
--- a/src/filters/ByteSwapFilterIterator.cpp Wed May 25 17:04:51 2011 -0500
+++ b/src/filters/ByteSwapFilterIterator.cpp Thu May 26 13:15:52 2011 -0500
@@ -85,9 +85,8 @@
const boost::uint32_t numPointsAchieved = dstData.getNumPoints();
- dstData.setNumPoints(dstData.getCapacity());
- return dstData.getCapacity();
+ return numPointsAchieved;
}
diff -r b7891eaf18fe -r b537b4c8ab21 src/filters/ChipperIterator.cpp
--- a/src/filters/ChipperIterator.cpp Wed May 25 17:04:51 2011 -0500
+++ b/src/filters/ChipperIterator.cpp Thu May 26 13:15:52 2011 -0500
@@ -56,9 +56,6 @@
boost::uint32_t ChipperSequentialIterator::readImpl(PointBuffer& buffer)
{
- // The client has asked us for dstData.getCapacity() points.
- // We will read from our previous stage until we get that amount (or
- // until the previous stage runs out of points).
if (m_currentBlockId == m_chipper.GetBlockCount())
return 0; // we're done.
@@ -76,16 +73,13 @@
throw libpc_error("Buffer not large enough to hold block!");
}
block.GetBuffer(m_chipper.getPrevStage(), buffer, m_currentBlockId);
-
- // FIXME: Set the PointBuffer's Bounds
-
+
buffer.setSpatialBounds(block.GetBounds());
m_currentBlockId++;
return numPointsThisBlock;
}
-
bool ChipperSequentialIterator::atEndImpl() const
{
// we don't have a fixed point point --
@@ -94,70 +88,4 @@
return iter.atEnd();
}
-
-// boost::uint64_t ChipperSequentialIterator::skipImpl(boost::uint64_t count)
-// {
-// getPrevIterator().skip(count);
-// return count;
-// }
-//
-//
-// bool ChipperSequentialIterator::atEndImpl() const
-// {
-// return getPrevIterator().atEnd();
-// }
-//
-//
-// boost::uint32_t ChipperSequentialIterator::readImpl(PointBuffer& data)
-// {
-// const boost::uint32_t numRead = getPrevIterator().read(data);
-// // const boost::uint32_t cacheBlockSize = m_filter.getCacheBlockSize();
-// //
-// // const boost::uint64_t currentPointIndex = getIndex();
-// //
-// // // for now, we only read from the cache if they are asking for one point
-// // // (this avoids the problem of an N-point request needing more than one
-// // // cached block to satisfy it)
-// // if (data.getCapacity() != 1)
-// // {
-// // const boost::uint32_t numRead = getPrevIterator().read(data);
-// //
-// // // if they asked for a full block and we got a full block,
-// // // and the block we got is properly aligned and not already cached,
-// // // then let's cache it!
-// // const bool isCacheable = (data.getCapacity() == cacheBlockSize) &&
-// // (numRead == cacheBlockSize) &&
-// // (currentPointIndex % cacheBlockSize == 0);
-// // if (isCacheable && (m_filter.lookupInCache(currentPointIndex) == NULL))
-// // {
-// // m_filter.addToCache(currentPointIndex, data);
-// // }
-// //
-// // m_filter.updateStats(numRead, data.getCapacity());
-// //
-// // return numRead;
-// // }
-// //
-// // // they asked for just one point -- first, check Mister Cache
-// // const PointBuffer* block = m_filter.lookupInCache(currentPointIndex);
-// // if (block != NULL)
-// // {
-// // // A hit! A palpable hit!
-// // data.copyPointFast(0, currentPointIndex % cacheBlockSize, *block);
-// //
-// // m_filter.updateStats(0, 1);
-// //
-// // return 1;
-// // }
-// //
-// // // Not in the cache, so do a normal read :-(
-// // const boost::uint32_t numRead = getPrevIterator().read(data);
-// // m_filter.updateStats(numRead, numRead);
-//
-// return numRead;
-// }
-//
-
-
-
} } // namespaces
More information about the Liblas-commits
mailing list