[Liblas-commits] hg: fix up logic of liblas::Point::SetHeaderPtr
#190
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Oct 12 10:10:34 EDT 2010
changeset 77b861e53603 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=77b861e53603
summary: fix up logic of liblas::Point::SetHeaderPtr #190
diffstat:
src/laspoint.cpp | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
diffs (57 lines):
diff -r 3fecf7d04752 -r 77b861e53603 src/laspoint.cpp
--- a/src/laspoint.cpp Tue Oct 12 12:00:05 2010 +0100
+++ b/src/laspoint.cpp Tue Oct 12 09:10:28 2010 -0500
@@ -190,17 +190,25 @@
void Point::SetHeaderPtr(HeaderPtr header)
{
- boost::uint16_t length;
- if (m_header)
- length = m_header->GetDataRecordLength();
+ boost::uint16_t wanted_length;
+
+ if (header)
+ wanted_length = header->GetDataRecordLength();
else
- length = m_default_header.GetDataRecordLength();
+ wanted_length = m_default_header.GetDataRecordLength();
// This is hopefully faster than copying everything if we don't have
// any data set and nothing to worry about.
boost::uint32_t sum = std::accumulate(m_data.begin(), m_data.end(), 0);
-
- if (length != m_data.size() && sum != 0)
+
+ if (!sum) {
+ m_data.resize(wanted_length);
+ m_data.assign(wanted_length, 0);
+ m_header = header;
+ return;
+ }
+
+ if (wanted_length != m_data.size())
{
// Manually copy everything but the header ptr
// We can't just copy the raw data because its
@@ -208,8 +216,8 @@
// schema change.
Point p(*this);
- m_data.resize(length);
- m_data.assign(length, 0);
+ m_data.resize(wanted_length);
+ m_data.assign(wanted_length, 0);
SetX(p.GetX());
SetY(p.GetY());
@@ -816,7 +824,9 @@
// throw std::runtime_error(msg.str());
return Color(0, 0, 0);
}
-
+
+ assert(!(f == ePointFormat0 || f == ePointFormat1));
+
using liblas::detail::bitsToInt;
std::vector<boost::uint8_t>::size_type red_pos = GetDimensionBytePosition(index_pos);
More information about the Liblas-commits
mailing list