[Liblas-commits] laszip: 3 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Sat Dec 18 15:30:20 EST 2010
changeset 5138579f7a56 in /Volumes/Data/www/liblas.org/laszip
details: http://hg.liblas.orglaszip?cmd=changeset;node=5138579f7a56
summary: comment fix
changeset 7e3afedda8ae in /Volumes/Data/www/liblas.org/laszip
details: http://hg.liblas.orglaszip?cmd=changeset;node=7e3afedda8ae
summary: added LASitem::set helper
changeset b095ef93a1f2 in /Volumes/Data/www/liblas.org/laszip
details: http://hg.liblas.orglaszip?cmd=changeset;node=b095ef93a1f2
summary: pull-merge
diffstat:
include/laszip/lasunzipper.hpp | 2 +-
include/laszip/laszip.hpp | 34 +++++++++++++++++++++++-
src/bytestreamin_file.hpp | 12 ++++----
src/bytestreamin_istream.hpp | 58 +++++++++++++++++++++++------------------
src/bytestreamout.hpp | 8 ++--
src/bytestreamout_file.hpp | 40 ++++++++++++++--------------
src/bytestreamout_ostream.hpp | 28 ++++++++++----------
7 files changed, 110 insertions(+), 72 deletions(-)
diffs (truncated from 418 to 300 lines):
diff -r 0ef60ec2e07c -r b095ef93a1f2 include/laszip/lasunzipper.hpp
--- a/include/laszip/lasunzipper.hpp Fri Dec 17 21:23:16 2010 -0800
+++ b/include/laszip/lasunzipper.hpp Sat Dec 18 12:29:58 2010 -0800
@@ -23,7 +23,7 @@
CONTENTS:
- Writes (optionally compressed) LIDAR points to LAS formats 1.0 - 1.3
+ Reads (optionally compressed) LIDAR points to LAS formats 1.0 - 1.3
PROGRAMMERS:
diff -r 0ef60ec2e07c -r b095ef93a1f2 include/laszip/laszip.hpp
--- a/include/laszip/laszip.hpp Fri Dec 17 21:23:16 2010 -0800
+++ b/include/laszip/laszip.hpp Sat Dec 18 12:29:58 2010 -0800
@@ -63,10 +63,42 @@
{
public:
- enum { BYTE = 0, SHORT, INT, LONG, FLOAT, DOUBLE, POINT10, GPSTIME, RGB, WAVEPACKET } type;
+ enum Type { BYTE = 0, SHORT, INT, LONG, FLOAT, DOUBLE, POINT10, GPSTIME, RGB, WAVEPACKET } type;
unsigned short size;
unsigned short version;
+ // convenience function (not done as a ctor, since these items are usually allocated as an array)
+ void set(LASitem::Type type)
+ {
+ LASitem& x = *this;
+ switch (type)
+ {
+ case LASitem::POINT10:
+ x.type = LASitem::POINT10;
+ x.size = 20;
+ x.version = 0;
+ break;
+ case LASitem::GPSTIME:
+ x.type = LASitem::GPSTIME;
+ x.size = 8;
+ x.version = 0;
+ break;
+ case LASitem::RGB:
+ x.type = LASitem::RGB;
+ x.size = 6;
+ x.version = 0;
+ break;
+ case LASitem::WAVEPACKET:
+ x.type = LASitem::WAVEPACKET;
+ x.size = 29;
+ x.version = 0;
+ break;
+ default:
+ throw 0; // BUG
+ }
+ return;
+ }
+
bool supported_type() const
{
switch (type)
diff -r 0ef60ec2e07c -r b095ef93a1f2 src/bytestreamin_file.hpp
--- a/src/bytestreamin_file.hpp Fri Dec 17 21:23:16 2010 -0800
+++ b/src/bytestreamin_file.hpp Sat Dec 18 12:29:58 2010 -0800
@@ -122,17 +122,17 @@
inline bool ByteStreamInFile::get16bits(unsigned char* bytes)
{
- return (fread(bytes, 1, 2, file) == 2);
+ return getBytes(bytes, 2);
}
inline bool ByteStreamInFile::get32bits(unsigned char* bytes)
{
- return (fread(bytes, 1, 4, file) == 4);
+ return getBytes(bytes, 4);
}
inline bool ByteStreamInFile::get64bits(unsigned char* bytes)
{
- return (fread(bytes, 1, 8, file) == 8);
+ return getBytes(bytes, 8);
}
inline bool ByteStreamInFile::isSeekable() const
@@ -167,7 +167,7 @@
inline bool ByteStreamInFileEndianSwapped::get16bits(unsigned char* bytes)
{
- if (fread(swapped, 1, 2, file) == 2)
+ if (getBytes(swapped, 2))
{
bytes[0] = swapped[1];
bytes[1] = swapped[0];
@@ -178,7 +178,7 @@
inline bool ByteStreamInFileEndianSwapped::get32bits(unsigned char* bytes)
{
- if (fread(swapped, 1, 4, file) == 4)
+ if (getBytes(swapped, 4))
{
bytes[0] = swapped[3];
bytes[1] = swapped[2];
@@ -191,7 +191,7 @@
inline bool ByteStreamInFileEndianSwapped::get64bits(unsigned char* bytes)
{
- if (fread(swapped, 1, 8, file) == 8)
+ if (getBytes(swapped, 8))
{
bytes[0] = swapped[7];
bytes[1] = swapped[6];
diff -r 0ef60ec2e07c -r b095ef93a1f2 src/bytestreamin_istream.hpp
--- a/src/bytestreamin_istream.hpp Fri Dec 17 21:23:16 2010 -0800
+++ b/src/bytestreamin_istream.hpp Sat Dec 18 12:29:58 2010 -0800
@@ -125,20 +125,17 @@
inline bool ByteStreamInIstream::get16bits(unsigned char* bytes)
{
- stream->read((char*)bytes, 2);
- return !!(stream->good());
+ return getBytes(bytes, 2);
}
inline bool ByteStreamInIstream::get32bits(unsigned char* bytes)
{
- stream->read((char*)bytes, 4);
- return !!(stream->good());
+ return getBytes(bytes, 4);
}
inline bool ByteStreamInIstream::get64bits(unsigned char* bytes)
{
- stream->read((char*)bytes, 8);
- return !!(stream->good());
+ return getBytes(bytes, 8);
}
inline bool ByteStreamInIstream::isSeekable() const
@@ -168,34 +165,43 @@
inline bool ByteStreamInIstreamEndianSwapped::get16bits(unsigned char* bytes)
{
- stream->read((char*)swapped, 2);
- bytes[0] = swapped[1];
- bytes[1] = swapped[0];
- return !!(stream->good());
+ if (getBytes(swapped, 2))
+ {
+ bytes[0] = swapped[1];
+ bytes[1] = swapped[0];
+ return true;
+ }
+ return false;
}
inline bool ByteStreamInIstreamEndianSwapped::get32bits(unsigned char* bytes)
{
- stream->read((char*)swapped, 4);
- bytes[0] = swapped[3];
- bytes[1] = swapped[2];
- bytes[2] = swapped[1];
- bytes[3] = swapped[0];
- return !!(stream->good());
+ if (getBytes(swapped, 4))
+ {
+ bytes[0] = swapped[3];
+ bytes[1] = swapped[2];
+ bytes[2] = swapped[1];
+ bytes[3] = swapped[0];
+ return true;
+ }
+ return false;
}
inline bool ByteStreamInIstreamEndianSwapped::get64bits(unsigned char* bytes)
{
- stream->read((char*)swapped, 8);
- bytes[0] = swapped[7];
- bytes[1] = swapped[6];
- bytes[2] = swapped[5];
- bytes[3] = swapped[4];
- bytes[4] = swapped[3];
- bytes[5] = swapped[2];
- bytes[6] = swapped[1];
- bytes[7] = swapped[0];
- return !!(stream->good());
+ if (getBytes(swapped, 8))
+ {
+ bytes[0] = swapped[7];
+ bytes[1] = swapped[6];
+ bytes[2] = swapped[5];
+ bytes[3] = swapped[4];
+ bytes[4] = swapped[3];
+ bytes[5] = swapped[2];
+ bytes[6] = swapped[1];
+ bytes[7] = swapped[0];
+ return true;
+ }
+ return false;
}
#endif
diff -r 0ef60ec2e07c -r b095ef93a1f2 src/bytestreamout.hpp
--- a/src/bytestreamout.hpp Fri Dec 17 21:23:16 2010 -0800
+++ b/src/bytestreamout.hpp Sat Dec 18 12:29:58 2010 -0800
@@ -52,13 +52,13 @@
/* write a single byte */
virtual bool putByte(unsigned char byte) = 0;
/* write an array of bytes */
- virtual bool putBytes(unsigned char* bytes, unsigned int num_bytes) = 0;
+ virtual bool putBytes(const unsigned char* bytes, unsigned int num_bytes) = 0;
/* write 16 bit field (for implementing endian swap) */
- virtual bool put16bits(unsigned char* bytes) = 0;
+ virtual bool put16bits(const unsigned char* bytes) = 0;
/* write 32 bit field (for implementing endian swap) */
- virtual bool put32bits(unsigned char* bytes) = 0;
+ virtual bool put32bits(const unsigned char* bytes) = 0;
/* write 64 bit field (for implementing endian swap) */
- virtual bool put64bits(unsigned char* bytes) = 0;
+ virtual bool put64bits(const unsigned char* bytes) = 0;
/* is the stream seekable (e.g. standard out is not) */
virtual bool isSeekable() const = 0;
/* save position in the stream for (forward) seeking later */
diff -r 0ef60ec2e07c -r b095ef93a1f2 src/bytestreamout_file.hpp
--- a/src/bytestreamout_file.hpp Fri Dec 17 21:23:16 2010 -0800
+++ b/src/bytestreamout_file.hpp Sat Dec 18 12:29:58 2010 -0800
@@ -55,13 +55,13 @@
/* write a single byte */
bool putByte(unsigned char byte);
/* write an array of bytes */
- bool putBytes(unsigned char* bytes, unsigned int num_bytes);
+ bool putBytes(const unsigned char* bytes, unsigned int num_bytes);
/* write 16 bit field (for implementing endian swap) */
- virtual bool put16bits(unsigned char* bytes);
+ virtual bool put16bits(const unsigned char* bytes);
/* write 32 bit field (for implementing endian swap) */
- virtual bool put32bits(unsigned char* bytes);
+ virtual bool put32bits(const unsigned char* bytes);
/* write 64 bit field (for implementing endian swap) */
- virtual bool put64bits(unsigned char* bytes);
+ virtual bool put64bits(const unsigned char* bytes);
/* is the stream seekable (e.g. standard out is not) */
bool isSeekable() const;
/* save position in the stream for (forward) seeking later */
@@ -88,11 +88,11 @@
public:
ByteStreamOutFileEndianSwapped(FILE* file);
/* write 16 bit field (for implementing endian swap) */
- bool put16bits(unsigned char* bytes);
+ bool put16bits(const unsigned char* bytes);
/* write 32 bit field (for implementing endian swap) */
- bool put32bits(unsigned char* bytes);
+ bool put32bits(const unsigned char* bytes);
/* write 64 bit field (for implementing endian swap) */
- bool put64bits(unsigned char* bytes);
+ bool put64bits(const unsigned char* bytes);
private:
unsigned char swapped[8];
};
@@ -109,24 +109,24 @@
return (fputc(byte, file) == byte);
}
-inline bool ByteStreamOutFile::putBytes(unsigned char* bytes, unsigned int num_bytes)
+inline bool ByteStreamOutFile::putBytes(const unsigned char* bytes, unsigned int num_bytes)
{
return (fwrite(bytes, 1, num_bytes, file) == num_bytes);
}
-inline bool ByteStreamOutFile::put16bits(unsigned char* bytes)
+inline bool ByteStreamOutFile::put16bits(const unsigned char* bytes)
{
- return (fwrite(bytes, 1, 2, file) == 2);
+ return putBytes(bytes, 2);
}
-inline bool ByteStreamOutFile::put32bits(unsigned char* bytes)
+inline bool ByteStreamOutFile::put32bits(const unsigned char* bytes)
{
- return (fwrite(bytes, 1, 4, file) == 4);
+ return putBytes(bytes, 4);
}
-inline bool ByteStreamOutFile::put64bits(unsigned char* bytes)
+inline bool ByteStreamOutFile::put64bits(const unsigned char* bytes)
{
- return (fwrite(bytes, 1, 8, file) == 8);
+ return putBytes(bytes, 8);
}
inline bool ByteStreamOutFile::isSeekable() const
@@ -164,23 +164,23 @@
{
}
-inline bool ByteStreamOutFileEndianSwapped::put16bits(unsigned char* bytes)
+inline bool ByteStreamOutFileEndianSwapped::put16bits(const unsigned char* bytes)
{
swapped[0] = bytes[1];
swapped[1] = bytes[0];
- return (fwrite(swapped, 1, 2, file) == 2);
More information about the Liblas-commits
mailing list