[Liblas-commits] r1194 - trunk/src/detail
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Apr 9 13:15:55 EDT 2009
Author: hobu
Date: Thu Apr 9 13:15:55 2009
New Revision: 1194
URL: http://liblas.org/changeset/1194
Log:
clean up logic and allow pad bytes to be both directions #124 #125
Modified:
trunk/src/detail/reader.cpp
Modified: trunk/src/detail/reader.cpp
==============================================================================
--- trunk/src/detail/reader.cpp (original)
+++ trunk/src/detail/reader.cpp Thu Apr 9 13:15:55 2009
@@ -284,15 +284,23 @@
detail::read_n(pad1, m_ifs, sizeof(uint8_t));
detail::read_n(pad2, m_ifs, sizeof(uint8_t));
+ LIBLAS_SWAP_BYTES(pad1);
+ LIBLAS_SWAP_BYTES(pad2);
+
// FIXME: we have to worry about swapping issues
- // for now, just check oppositely
- if (! (sgn1 == pad2 && sgn2 == pad1))
+ // but some people write the pad bytes backwards
+ // anyway. Let's check both ways.
+ bool found = false;
+ if (sgn1 == pad2 && sgn2 == pad1) found = true;
+ if (sgn1 == pad1 && sgn2 == pad2) found = true;
+ if (!found)
{
// If the two bytes we read weren't signature bytes
// we'll throw an exception. Depending on the version
// we may want ot throw an error to the user or
// silently continue on.
throw std::domain_error("point data signature (1.0's 0xCC and 0xDD padding) not found");
+
}
}
More information about the Liblas-commits
mailing list