[Liblas-commits] hg: add total length output for VLRs
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Jun 28 16:21:59 EDT 2011
details: http://hg.liblas.orghg/rev/67a04c839a8d
changeset: 3030:67a04c839a8d
user: Howard Butler <hobu.inc at gmail.com>
date: Tue Jun 28 13:10:36 2011 -0500
description:
add total length output for VLRs
Subject: hg: turn off header padding preservation for now
details: http://hg.liblas.orghg/rev/0c10f5e95f23
changeset: 3031:0c10f5e95f23
user: Howard Butler <hobu.inc at gmail.com>
date: Tue Jun 28 15:21:05 2011 -0500
description:
turn off header padding preservation for now
Subject: hg: try to consolidate LASzip* creation and management into the ZipPoint class
details: http://hg.liblas.orghg/rev/47fa1baf1aa4
changeset: 3032:47fa1baf1aa4
user: Howard Butler <hobu.inc at gmail.com>
date: Tue Jun 28 15:21:50 2011 -0500
description:
try to consolidate LASzip* creation and management into the ZipPoint class
diffstat:
include/liblas/detail/zippoint.hpp | 2 +-
src/detail/reader/zipreader.cpp | 25 ++++++-------------------
src/detail/writer/header.cpp | 7 +++----
src/detail/writer/zipwriter.cpp | 17 -----------------
src/detail/zippoint.cpp | 31 ++++++++++++++++++++++---------
src/variablerecord.cpp | 2 ++
6 files changed, 34 insertions(+), 50 deletions(-)
diffs (202 lines):
diff -r 3dc7a81a65f8 -r 47fa1baf1aa4 include/liblas/detail/zippoint.hpp
--- a/include/liblas/detail/zippoint.hpp Tue Jun 28 11:20:13 2011 -0500
+++ b/include/liblas/detail/zippoint.hpp Tue Jun 28 15:21:50 2011 -0500
@@ -77,7 +77,7 @@
LASzip* GetZipper() const { return m_zip.get(); }
private:
- void ConstructItems(unsigned char, unsigned short);
+ void ConstructItems();
public: // for now
// LASzip::pack() allocates/sets vlr_data and vlr_num for us, and deletes it for us ["his"]
diff -r 3dc7a81a65f8 -r 47fa1baf1aa4 src/detail/reader/zipreader.cpp
--- a/src/detail/reader/zipreader.cpp Tue Jun 28 11:20:13 2011 -0500
+++ b/src/detail/reader/zipreader.cpp Tue Jun 28 15:21:50 2011 -0500
@@ -95,6 +95,9 @@
m_ifs.clear();
m_ifs.seekg(0);
+ m_zipPoint.reset();
+ m_unzipper.reset();
+
// Reset sizes and set internal cursor to the beginning of file.
m_current = 0;
m_size = m_header->GetPointRecordsCount();
@@ -108,24 +111,6 @@
PointFormatName format = m_header->GetDataFormatId();
boost::scoped_ptr<ZipPoint> z(new ZipPoint(format, m_header->GetVLRs()));
m_zipPoint.swap(z);
-
- bool ok = false;
- ok = m_zipPoint->GetZipper()->setup((unsigned char)format, m_header->GetDataRecordLength());
-
- if (!ok)
- {
- std::ostringstream oss;
- oss << "Error setting up compression engine: " << std::string(m_zipPoint->GetZipper()->get_error());
- throw liblas_error(oss.str());
- }
-
- ok = m_zipPoint->GetZipper()->unpack(m_zipPoint->our_vlr_data.get(), m_zipPoint->our_vlr_num);
- if (!ok)
- {
- std::ostringstream oss;
- oss << "Error unpacking zip VLR data: " << std::string(m_zipPoint->GetZipper()->get_error());
- throw liblas_error(oss.str());
- }
}
if (!m_unzipper)
@@ -211,9 +196,11 @@
void ZipReaderImpl::ReadIdiom()
{
bool ok = false;
+ std::cout << "ReadIdiom pos: " << m_ifs.tellg() << std::endl;
ok = m_unzipper->read(m_zipPoint->m_lz_point);
-
+
+ std::cout << "ReadIdiom pos: " << m_ifs.tellg() << std::endl;
if (!ok)
{
std::ostringstream oss;
diff -r 3dc7a81a65f8 -r 47fa1baf1aa4 src/detail/writer/header.cpp
--- a/src/detail/writer/header.cpp Tue Jun 28 11:20:13 2011 -0500
+++ b/src/detail/writer/header.cpp Tue Jun 28 15:21:50 2011 -0500
@@ -154,7 +154,6 @@
VariableRecord v;
zpd.ConstructVLR(v);
m_header.AddVLR(v);
- m_header.SetDataOffset(m_header.GetDataOffset()+v.GetRecordLength());
#else
throw configuration_error("LASzip compression support not enabled in this libLAS configuration.");
#endif
@@ -169,13 +168,13 @@
if (difference <= 0)
{
int32_t d = abs(difference);
- int32_t padding_from_before = m_header.GetDataOffset() - m_header.GetHeaderSize();
+ // int32_t padding_from_before = m_header.GetDataOffset() - m_header.GetHeaderSize();
if (m_header.GetVersionMinor() == 0)
{
// Add the two extra bytes for the 1.0 pad
d = d + 2;
}
- m_header.SetDataOffset(m_header.GetDataOffset() + d + padding_from_before);
+ m_header.SetDataOffset(m_header.GetDataOffset() + d);
}
}
@@ -243,7 +242,7 @@
detail::write_n(m_ofs, n2, sizeof(n2));
// 14. Offset to data
- n4 = m_header.GetDataOffset();
+ n4 = m_header.GetDataOffset();
detail::write_n(m_ofs, n4, sizeof(n4));
// 15. Number of variable length records
diff -r 3dc7a81a65f8 -r 47fa1baf1aa4 src/detail/writer/zipwriter.cpp
--- a/src/detail/writer/zipwriter.cpp Tue Jun 28 11:20:13 2011 -0500
+++ b/src/detail/writer/zipwriter.cpp Tue Jun 28 15:21:50 2011 -0500
@@ -107,23 +107,6 @@
boost::scoped_ptr<ZipPoint> z(new ZipPoint(format, m_header->GetVLRs()));
m_zipPoint.swap(z);
-
- bool ok = false;
- ok = m_zipPoint->GetZipper()->setup((unsigned char)format, m_header->GetDataRecordLength());
- if (!ok)
- {
- std::ostringstream oss;
- oss << "Error opening compression core: " << std::string(m_zipPoint->GetZipper()->get_error());
- throw liblas_error(oss.str());
- }
-
- ok = m_zipPoint->GetZipper()->pack(m_zipPoint->his_vlr_data, m_zipPoint->his_vlr_num);
- if (!ok)
- {
- std::ostringstream oss;
- oss << "Error packing VLR data for compression: " << std::string(m_zipPoint->GetZipper()->get_error());
- throw liblas_error(oss.str());
- }
}
if (!m_zipper)
diff -r 3dc7a81a65f8 -r 47fa1baf1aa4 src/detail/zippoint.cpp
--- a/src/detail/zippoint.cpp Tue Jun 28 11:20:13 2011 -0500
+++ b/src/detail/zippoint.cpp Tue Jun 28 15:21:50 2011 -0500
@@ -114,9 +114,26 @@
throw liblas_error("point format not supported by laszip");
}
- m_zip->setup(pointFormat, pointSize);
+ if (vlr)
+ {
+ m_zip->unpack(our_vlr_data.get(), our_vlr_num);
+ m_zip->setup((const unsigned short int) m_zip->num_items,
+ (const LASitem*)m_zip->items,
+ LASZIP_COMPRESSOR_DEFAULT);
+ ConstructItems();
+ } else
+ {
- ConstructItems(pointFormat, pointSize);
+ if (!m_zip->setup(pointFormat, pointSize))
+ {
+ std::ostringstream oss;
+ oss << "Error setting up LASzip for format " << pointFormat <<": " << m_zip->get_error();
+ throw liblas_error(oss.str());
+ }
+
+ ConstructItems();
+
+ }
return;
@@ -131,14 +148,9 @@
}
-void ZipPoint::ConstructItems(unsigned char pointFormat, unsigned short size)
+void ZipPoint::ConstructItems()
{
- if (!m_zip->setup(pointFormat, size))
- {
- std::ostringstream oss;
- oss << "Error setting up LASzip for format " << pointFormat <<": " << m_zip->get_error();
- throw liblas_error(oss.str());
- }
+
// construct the object that will hold a laszip point
@@ -159,6 +171,7 @@
point_offset += m_zip->items[i].size;
}
+ assert (point_offset == m_lz_point_size);
return;
}
diff -r 3dc7a81a65f8 -r 47fa1baf1aa4 src/variablerecord.cpp
--- a/src/variablerecord.cpp Tue Jun 28 11:20:13 2011 -0500
+++ b/src/variablerecord.cpp Tue Jun 28 15:21:50 2011 -0500
@@ -220,6 +220,7 @@
vlr.put("description", GetDescription(false));
vlr.put("length", GetRecordLength());
vlr.put("id", GetRecordId());
+ vlr.put("total_length", GetTotalSize());
return vlr;
}
@@ -238,6 +239,7 @@
<< std::endl;
os << " ID: " << tree.get<boost::uint32_t>("id")
<< " Length: " << tree.get<boost::uint32_t>("length")
+ << " Total Size: " << tree.get<boost::uint32_t>("total_length")
<< std::endl;
return os;
More information about the Liblas-commits
mailing list