[Liblas-commits] hg-1.6: defer all laszip validation to the laszip
library itself
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Apr 4 10:30:21 EDT 2011
details: http://hg.liblas.orghg-1.6/rev/e0ae15027f61
changeset: 2859:e0ae15027f61
user: Michael P. Gerlek <mpg at flaxen.com>
date: Fri Mar 25 08:33:57 2011 -0700
description:
defer all laszip validation to the laszip library itself
diffstat:
src/detail/zippoint.cpp | 93 +------------------------------------------------
1 files changed, 1 insertions(+), 92 deletions(-)
diffs (103 lines):
diff -r 0058891eaee5 -r e0ae15027f61 src/detail/zippoint.cpp
--- a/src/detail/zippoint.cpp Mon Mar 07 11:42:38 2011 -0600
+++ b/src/detail/zippoint.cpp Fri Mar 25 08:33:57 2011 -0700
@@ -279,98 +279,7 @@
if (laszip_recordid != vlr.GetRecordId())
return false;
- // note we don't bother validating the Description field
-
- boost::uint16_t record_length_after_header = vlr.GetRecordLength();
- if (record_length_after_header != 34 + 6 * m_num_items)
- return false;
-
- boost::uint8_t* data = new boost::uint8_t[record_length_after_header];
- boost::uint8_t* p = data;
-
- const std::vector<boost::uint8_t>& vdata = vlr.GetData();
- for (boost::uint32_t i=0; i<record_length_after_header; i++)
- {
- data[i] = vdata[i];
- }
-
- // the data following the header of the variable length record is
- // U32 compression 4 bytes
- // U8 version_major 1 byte
- // U8 version_minor 1 byte
- // U16 version_revision 2 bytes
- // U32 options 4 bytes
- // U32 num_chunks 4 bytes
- // I64 num_points 8 bytes
- // I64 num_bytes 8 bytes
- // U16 num_items 2 bytes
- // U16 type 2 bytes * num_items
- // U16 size 2 bytes * num_items
- // U16 version 2 bytes * num_items
- // which totals 34+6*num_items
-
- // the header doesn't know what kind of compression the zipwriter
- // will be doing, but since we only ever use the default we'll just
- // use that for now
- boost::uint32_t compression_type = 0;
- p = GetBytes<boost::uint32_t>(p, compression_type);
- if (compression_type != LASzip::DEFAULT_COMPRESSION)
- return false;
-
- boost::uint8_t version_major = 0;
- p = GetBytes<boost::uint8_t>(p, version_major);
- if (version_major != LASZIP_VERSION_MAJOR)
- return false;
- boost::uint8_t version_minor = 0;
- p = GetBytes<boost::uint8_t>(p, version_minor);
- if (version_minor != LASZIP_VERSION_MINOR)
- return false;
- boost::uint16_t version_revision = 0;
- p = GetBytes<boost::uint16_t>(p, version_revision);
- if (version_revision > LASZIP_VERSION_REVISION)
- return false;
-
- boost::uint32_t options = 0;
- p = GetBytes<boost::uint32_t>(p, options);
- if (options != 0)
- return false;
- boost::uint32_t num_chunks = 0;
- p = GetBytes<boost::uint32_t>(p, num_chunks);
- if (num_chunks != 1)
- return false;
- boost::int64_t num_points = 0;
- p = GetBytes<boost::int64_t>(p, num_points);
- if (num_points != -1) // BUG: or allow it to match header
- return false;
- boost::int64_t num_bytes = 0;
- p = GetBytes<boost::int64_t>(p, num_bytes);
- if (num_bytes != -1) // BUG: or allow it to match header
- return false;
- boost::uint16_t num_items = 0;
- p = GetBytes<boost::uint16_t>(p, num_items);
- if (num_items != (boost::uint16_t)m_num_items)
- return false;
-
- for (boost::uint32_t i = 0; i < num_items; i++)
- {
- boost::uint16_t type = 0;
- p = GetBytes<boost::uint16_t>(p, type);
- if (type != (boost::uint16_t)m_items[i].type)
- return false;
- boost::uint16_t size = 0;
- p = GetBytes<boost::uint16_t>(p, size);
- if (size != (boost::uint16_t)m_items[i].size)
- return false;
- boost::uint16_t version = 0;
- p = GetBytes<boost::uint16_t>(p, version);
- if (version != (boost::uint16_t)m_items[i].version)
- return false;
- }
-
- assert(p == data + record_length_after_header);
-
- if (data != 0 )
- delete[] data;
+ // (all validation checking is now done inside the liblas library)
return true;
}
More information about the Liblas-commits
mailing list