[Liblas-commits] hg: restore the point count setter;
be suyre and restore the ori...
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Jan 4 15:42:23 EST 2011
details: http://hg.liblas.orghg/rev/eae4c3cfb963
changeset: 2682:eae4c3cfb963
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Jan 04 12:17:12 2011 -0800
description:
restore the point count setter; be suyre and restore the orig pos after updating, although I still don't know why
Subject: hg: turn on the tests
details: http://hg.liblas.orghg/rev/97a8e4b6e3bb
changeset: 2683:97a8e4b6e3bb
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Jan 04 12:18:16 2011 -0800
description:
turn on the tests
Subject: hg: we can't determine the point count manually if we're a compressed file, so as a fallback we'll use the point count we already have -- not clear if this is sufficient, though
details: http://hg.liblas.orghg/rev/20f07b581c9c
changeset: 2684:20f07b581c9c
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Jan 04 12:42:06 2011 -0800
description:
we can't determine the point count manually if we're a compressed file, so as a fallback we'll use the point count we already have -- not clear if this is sufficient, though
diffstat:
src/detail/writer/header.cpp | 29 ++++++++++++++++++-----------
src/detail/writer/zipwriter.cpp | 10 +++++++---
test/unit/zipreader_test.cpp | 2 +-
test/unit/zipwriter_test.cpp | 2 +-
4 files changed, 27 insertions(+), 16 deletions(-)
diffs (113 lines):
diff -r b2b4ee72c615 -r 20f07b581c9c src/detail/writer/header.cpp
--- a/src/detail/writer/header.cpp Tue Jan 04 11:54:33 2011 -0800
+++ b/src/detail/writer/header.cpp Tue Jan 04 12:42:06 2011 -0800
@@ -101,20 +101,27 @@
{
// We're opened in append mode
- ios::off_type points = end - static_cast<ios::off_type>(m_header.GetDataOffset());
- ios::off_type count = points / static_cast<ios::off_type>(m_header.GetDataRecordLength());
+ if (m_header.Compressed())
+ {
+ m_pointCount = m_header.GetPointRecordsCount();
+ }
+ else
+ {
+ ios::off_type points = end - static_cast<ios::off_type>(m_header.GetDataOffset());
+ ios::off_type count = points / static_cast<ios::off_type>(m_header.GetDataRecordLength());
- if (points < 0) {
- std::ostringstream oss;
- oss << "The header's data offset, " << m_header.GetDataOffset()
- <<", is much larger than the size of the file, " << end
- <<", and something is amiss. Did you use the right header"
- <<" offset value?";
- throw std::runtime_error(oss.str());
+ if (points < 0) {
+ std::ostringstream oss;
+ oss << "The header's data offset, " << m_header.GetDataOffset()
+ <<", is much larger than the size of the file, " << end
+ <<", and something is amiss. Did you use the right header"
+ <<" offset value?";
+ throw std::runtime_error(oss.str());
+ }
+
+ m_pointCount = static_cast<uint32_t>(count);
}
- m_pointCount = static_cast<uint32_t>(count);
-
// Position to the beginning of the file to start writing the header
m_ofs.seekp(0, ios::beg);
diff -r b2b4ee72c615 -r 20f07b581c9c src/detail/writer/zipwriter.cpp
--- a/src/detail/writer/zipwriter.cpp Tue Jan 04 11:54:33 2011 -0800
+++ b/src/detail/writer/zipwriter.cpp Tue Jan 04 12:42:06 2011 -0800
@@ -81,6 +81,8 @@
void ZipWriterImpl::UpdatePointCount(boost::uint32_t count)
{
+ std::streamoff orig_pos = m_ofs.tellp();
+
boost::uint32_t out = m_pointCount;
if ( count != 0 ) { out = count; }
@@ -90,6 +92,8 @@
std::streamsize const dataPos = 107;
m_ofs.seekp(dataPos, std::ios::beg);
detail::write_n(m_ofs, out , sizeof(out));
+
+ m_ofs.seekp(orig_pos, std::ios::beg);
}
@@ -123,7 +127,7 @@
if (!ok)
throw liblas_error("Error writing compressed point data");
- /*++m_pointCount;*/
+ ++m_pointCount;
return;
}
@@ -132,14 +136,14 @@
{
// Try to update the point count on our way out, but we don't really
// care if we weren't able to write it.
- /*try
+ try
{
UpdatePointCount(0);
} catch (std::runtime_error const&)
{
- }*/
+ }
delete m_zipper;
delete m_zipPoint;
diff -r b2b4ee72c615 -r 20f07b581c9c test/unit/zipreader_test.cpp
--- a/test/unit/zipreader_test.cpp Tue Jan 04 11:54:33 2011 -0800
+++ b/test/unit/zipreader_test.cpp Tue Jan 04 12:42:06 2011 -0800
@@ -5,7 +5,7 @@
// http://www.opensource.org/licenses/bsd-license.php)
//
-#ifdef HAVE_LASZIPxxx
+#ifdef HAVE_LASZIP
#include <liblas/liblas.hpp>
#include <liblas/variablerecord.hpp>
diff -r b2b4ee72c615 -r 20f07b581c9c test/unit/zipwriter_test.cpp
--- a/test/unit/zipwriter_test.cpp Tue Jan 04 11:54:33 2011 -0800
+++ b/test/unit/zipwriter_test.cpp Tue Jan 04 12:42:06 2011 -0800
@@ -5,7 +5,7 @@
// http://www.opensource.org/licenses/bsd-license.php)
//
-#ifdef HAVE_LASZIPxxx
+#ifdef HAVE_LASZIP
#include <liblas/liblas.hpp>
#include <tut/tut.hpp>
More information about the Liblas-commits
mailing list