[Liblas-commits] hg: keep track of the point count on the writer's
header. repac...
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Jan 25 13:07:27 EST 2011
details: http://hg.liblas.orghg/rev/a1f77b9fe3d6
changeset: 2816:a1f77b9fe3d6
user: Howard Butler <hobu.inc at gmail.com>
date: Tue Jan 25 12:07:21 2011 -0600
description:
keep track of the point count on the writer's header. repack the point in the ZipWriter if the point format of the point doesn't match the point format of the header
diffstat:
src/detail/writer/point.cpp | 1 +
src/detail/writer/writer.cpp | 2 +
src/detail/writer/zipwriter.cpp | 42 ++++++++++++++++++++++++++++++----------
3 files changed, 34 insertions(+), 11 deletions(-)
diffs (93 lines):
diff -r 64c13911e15f -r a1f77b9fe3d6 src/detail/writer/point.cpp
--- a/src/detail/writer/point.cpp Mon Jan 24 10:56:50 2011 -0600
+++ b/src/detail/writer/point.cpp Tue Jan 25 12:07:21 2011 -0600
@@ -93,6 +93,7 @@
detail::write_n(m_ofs, data.front(), m_header->GetDataRecordLength());
m_pointCount++;
+ m_header->SetPointRecordsCount(m_pointCount);
// write in our extra data that the user set on the
// point up to the header's specified DataRecordLength
diff -r 64c13911e15f -r a1f77b9fe3d6 src/detail/writer/writer.cpp
--- a/src/detail/writer/writer.cpp Mon Jan 24 10:56:50 2011 -0600
+++ b/src/detail/writer/writer.cpp Tue Jan 25 12:07:21 2011 -0600
@@ -77,6 +77,8 @@
if ( count != 0 ) { out = count; }
+ m_header->SetPointRecordsCount(out);
+
if (!m_ofs.good() ) return;
// Skip to first byte of number of point records data member
std::streamsize const dataPos = 107;
diff -r 64c13911e15f -r a1f77b9fe3d6 src/detail/writer/zipwriter.cpp
--- a/src/detail/writer/zipwriter.cpp Mon Jan 24 10:56:50 2011 -0600
+++ b/src/detail/writer/zipwriter.cpp Tue Jan 25 12:07:21 2011 -0600
@@ -86,6 +86,7 @@
boost::uint32_t out = m_pointCount;
if ( count != 0 ) { out = count; }
+ m_header->SetPointRecordsCount(out);
if (!m_ofs.good() ) return;
// Skip to first byte of number of point records data member
@@ -133,17 +134,38 @@
}
}
- const std::vector<boost::uint8_t>& v = point.GetData();
- for (unsigned int i=0; i<m_zipPoint->m_lz_point_size; i++)
- {
- m_zipPoint->m_lz_point_data[i] = v[i];
- //printf("%d %d\n", v[i], i);
- }
-
bool ok = false;
try
{
- ok = m_zipper->write(m_zipPoint->m_lz_point);
+ const std::vector<boost::uint8_t>* data;
+
+ data = &point.GetData();
+
+ if (data->size() != m_zipPoint->m_lz_point_size)
+ {
+ // We need to repack the data.
+ liblas::Point p(point);
+ p.SetHeaderPtr(m_header);
+ data = &p.GetData();
+ // m_zipPoint->m_lz_point_data = const_cast<unsigned char*>(&(data->front()));
+ for (unsigned int i=0; i<m_zipPoint->m_lz_point_size; i++)
+ {
+ m_zipPoint->m_lz_point_data[i] = data->at(i);
+ //printf("%d %d\n", v[i], i);
+ }
+ ok = m_zipper->write(m_zipPoint->m_lz_point);
+ } else
+ {
+// m_zipPoint->m_lz_point_data = const_cast<unsigned char*>(&(data->front()));
+ for (unsigned int i=0; i<m_zipPoint->m_lz_point_size; i++)
+ {
+ m_zipPoint->m_lz_point_data[i] = data->at(i);
+ //printf("%d %d\n", v[i], i);
+ }
+
+ ok = m_zipper->write(m_zipPoint->m_lz_point);
+ }
+
}
catch(...)
{
@@ -153,10 +175,8 @@
{
throw liblas_error("Error writing compressed point data (2)");
}
-
++m_pointCount;
-
- return;
+ m_header->SetPointRecordsCount(m_pointCount);
}
ZipWriterImpl::~ZipWriterImpl()
More information about the Liblas-commits
mailing list