[Liblas-commits] hg: support LAS 1.3's seven slot return count
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Jul 27 15:59:32 EDT 2010
changeset 5054c86d44ef in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=5054c86d44ef
summary: support LAS 1.3's seven slot return count
diffstat:
include/liblas/lasheader.hpp | 2 +-
src/detail/reader/header.cpp | 24 ++++++++++++++++++------
src/detail/writer/header.cpp | 3 ++-
3 files changed, 21 insertions(+), 8 deletions(-)
diffs (60 lines):
diff -r 96a52b110942 -r 5054c86d44ef include/liblas/lasheader.hpp
--- a/include/liblas/lasheader.hpp Tue Jul 27 10:52:27 2010 -0500
+++ b/include/liblas/lasheader.hpp Tue Jul 27 14:59:27 2010 -0500
@@ -338,7 +338,7 @@
{
eDataSignatureSize = 2,
eFileSignatureSize = 4,
- ePointsByReturnSize = 5,
+ ePointsByReturnSize = 7,
eProjectId4Size = 8,
eSystemIdSize = 32,
eSoftwareIdSize = 32,
diff -r 96a52b110942 -r 5054c86d44ef src/detail/reader/header.cpp
--- a/src/detail/reader/header.cpp Tue Jul 27 10:52:27 2010 -0500
+++ b/src/detail/reader/header.cpp Tue Jul 27 14:59:27 2010 -0500
@@ -192,13 +192,25 @@
m_header->SetPointRecordsCount(n4);
// 20. Number of points by return
- std::vector<uint32_t>::size_type const srbyr = 5;
- uint32_t rbyr[srbyr] = { 0 };
- read_n(rbyr, m_ifs, sizeof(rbyr));
- for (std::size_t i = 0; i < srbyr; ++i)
+ // The committee in its infinite stupidity decided to increase the
+ // size of this array at 1.3. Yay for complex code.
+ std::vector<uint32_t>::size_type return_count_length;
+ if (m_header->GetVersionMinor() > 2) {
+ return_count_length = 7;
+ } else {
+ return_count_length = 5;
+ }
+
+ uint32_t* point_counts = new uint32_t[return_count_length];
+ for (uint32_t i = 0; i < return_count_length; ++i) {
+ point_counts[i] = 0;
+ }
+ read_n(point_counts, m_ifs, return_count_length*sizeof(uint32_t));
+ for (std::size_t i = 0; i < return_count_length; ++i)
{
- m_header->SetPointRecordsByReturnCount(i, rbyr[i]);
- }
+ m_header->SetPointRecordsByReturnCount(i, point_counts[i]);
+ }
+ delete point_counts;
// 21-23. Scale factors
read_n(x1, m_ifs, sizeof(x1));
diff -r 96a52b110942 -r 5054c86d44ef src/detail/writer/header.cpp
--- a/src/detail/writer/header.cpp Tue Jul 27 10:52:27 2010 -0500
+++ b/src/detail/writer/header.cpp Tue Jul 27 14:59:27 2010 -0500
@@ -214,7 +214,8 @@
// 19. Number of points by return
std::vector<uint32_t>::size_type const srbyr = 5;
std::vector<uint32_t> const& vpbr = m_header.GetPointRecordsByReturnCount();
- assert(vpbr.size() <= srbyr);
+ // TODO: fix this for 1.3, which has srbyr = 7; See detail/reader/header.cpp for more details
+ // assert(vpbr.size() <= srbyr);
uint32_t pbr[srbyr] = { 0 };
std::copy(vpbr.begin(), vpbr.end(), pbr);
detail::write_n(GetStream(), pbr, sizeof(pbr));
More information about the Liblas-commits
mailing list