[Liblas-commits] hg: 2 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Dec 10 15:49:54 EST 2010
changeset cc73e7b29b2a in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=cc73e7b29b2a
summary: Add filtering to CachedReader
changeset c4ea88ef881a in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=c4ea88ef881a
summary: Fix #196 liblas::Header's reserved flags not being preserved
diffstat:
src/detail/reader/cachedreader.cpp | 24 ++++++++++++++++++++++++
src/detail/reader/header.cpp | 2 +-
test/unit/lasheader_test.cpp | 2 ++
test/unit/laswriter_test.cpp | 2 ++
4 files changed, 29 insertions(+), 1 deletions(-)
diffs (78 lines):
diff -r 28fec51dfcd4 -r c4ea88ef881a src/detail/reader/cachedreader.cpp
--- a/src/detail/reader/cachedreader.cpp Thu Dec 09 16:17:11 2010 -0600
+++ b/src/detail/reader/cachedreader.cpp Fri Dec 10 14:49:47 2010 -0600
@@ -233,6 +233,30 @@
// PointPtr ptr = ReadCachedPoint(m_cache_read_position, header);
ReadCachedPoint(m_cache_read_position);
++m_cache_read_position;
+
+ // Filter the points and continue reading until we either find
+ // one to keep or throw an exception.
+
+ bool bLastPoint = false;
+ if (!FilterPoint(*m_point))
+ {
+ ReadCachedPoint(m_cache_read_position);
+ ++m_cache_read_position;
+
+ while (!FilterPoint(*m_point))
+ {
+ ReadCachedPoint(m_cache_read_position);
+ ++m_cache_read_position;
+ if (m_current == m_size)
+ {
+ bLastPoint = true;
+ break;
+ }
+ }
+ }
+
+ if (bLastPoint)
+ throw std::out_of_range("ReadNextPoint: file has no more points to read, end of file reached");
}
diff -r 28fec51dfcd4 -r c4ea88ef881a src/detail/reader/header.cpp
--- a/src/detail/reader/header.cpp Thu Dec 09 16:17:11 2010 -0600
+++ b/src/detail/reader/header.cpp Fri Dec 10 14:49:47 2010 -0600
@@ -90,8 +90,8 @@
m_header->SetFileSourceId(n2);
// 3. Reserved
- // This data must always contain Zeros.
read_n(n2, m_ifs, sizeof(n2));
+ m_header->SetReserved(n2);
// 4-7. Project ID
uint32_t d1 = 0;
diff -r 28fec51dfcd4 -r c4ea88ef881a test/unit/lasheader_test.cpp
--- a/test/unit/lasheader_test.cpp Thu Dec 09 16:17:11 2010 -0600
+++ b/test/unit/lasheader_test.cpp Fri Dec 10 14:49:47 2010 -0600
@@ -138,6 +138,8 @@
{
liblas::Header h;
ensure_equals(h.GetReserved(), 0);
+ h.SetReserved(1);
+ ensure_equals(h.GetReserved(), 1);
}
// Test Set/GetProjectId
diff -r 28fec51dfcd4 -r c4ea88ef881a test/unit/laswriter_test.cpp
--- a/test/unit/laswriter_test.cpp Thu Dec 09 16:17:11 2010 -0600
+++ b/test/unit/laswriter_test.cpp Fri Dec 10 14:49:47 2010 -0600
@@ -202,6 +202,7 @@
test_default_header(hdr_default);
// update some header data and overwrite header block
+ header.SetReserved(1);
header.SetFileSourceId(65535);
header.SetSystemId("Unit Test libLAS System");
header.SetSoftwareId("Unit Test libLAS Software");
@@ -224,6 +225,7 @@
liblas::Reader reader(ifs);
liblas::Header const& header = reader.GetHeader();
+ ensure_equals(header.GetReserved(), 1);
ensure_equals(header.GetFileSourceId(), 65535);
ensure_equals(header.GetSystemId(), std::string("Unit Test libLAS System"));
ensure_equals(header.GetSoftwareId(), std::string("Unit Test libLAS Software"));
More information about the Liblas-commits
mailing list