[Liblas-commits] hg-main-tree: add control over version, guid
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Apr 13 19:06:46 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/60c225862c56
changeset: 562:60c225862c56
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Apr 13 16:06:19 2011 -0700
description:
add control over version, guid
Subject: hg-main-tree: added tests for liblas formats
details: http://hg.libpc.orghg-main-tree/rev/b296e60bcafb
changeset: 563:b296e60bcafb
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Apr 13 16:06:33 2011 -0700
description:
added tests for liblas formats
diffstat:
include/libpc/drivers/las/Support.hpp | 11 -----
include/libpc/drivers/liblas/Reader.hpp | 3 +
include/libpc/drivers/liblas/Writer.hpp | 4 +
src/drivers/las/Reader.cpp | 70 ++++++-------------------------
src/drivers/las/Writer.cpp | 65 +++++------------------------
src/drivers/liblas/Reader.cpp | 13 +++++
src/drivers/liblas/Writer.cpp | 10 ++++
test/data/1.0_0.las | 0
test/data/1.0_1.las | 0
test/data/1.1_0.las | 0
test/data/1.1_1.las | 0
test/data/1.2_0.las | 0
test/data/1.2_1.las | 0
test/data/1.2_2.las | 0
test/data/1.2_3.las | 0
test/unit/LiblasReaderTest.cpp | 67 ++++++++++++++++++++++++++++++
test/unit/LiblasWriterTest.cpp | 60 +++++++++++++++++++++++++++
17 files changed, 183 insertions(+), 120 deletions(-)
diffs (truncated from 478 to 300 lines):
diff -r 4de27dfc1ea5 -r b296e60bcafb include/libpc/drivers/las/Support.hpp
--- a/include/libpc/drivers/las/Support.hpp Wed Apr 13 14:45:07 2011 -0700
+++ b/include/libpc/drivers/las/Support.hpp Wed Apr 13 16:06:33 2011 -0700
@@ -53,17 +53,6 @@
};
-/// Number of bytes of point record storage in particular format.
-enum PointSize
-{
- PointSize0 = 20, ///< Size of point record in data format \e 0
- PointSize1 = 28, ///< Size of point record in data format \e 1
- PointSize2 = 26, ///< Size of point record in data format \e 2
- PointSize3 = 34 ///< Size of point record in data format \e 3
- // other formats not supported
-};
-
-
// this struct is used as a means to hold all the las field dimension indexes from a schema
class PointIndexes
{
diff -r 4de27dfc1ea5 -r b296e60bcafb include/libpc/drivers/liblas/Reader.hpp
--- a/include/libpc/drivers/liblas/Reader.hpp Wed Apr 13 14:45:07 2011 -0700
+++ b/include/libpc/drivers/liblas/Reader.hpp Wed Apr 13 16:06:33 2011 -0700
@@ -63,6 +63,9 @@
::libpc::drivers::las::PointFormat getPointFormat() const;
+ boost::uint8_t getVersionMajor() const;
+ boost::uint8_t getVersionMinor() const;
+
bool supportsIterator (StageIteratorType t) const
{
if (t == StageIterator_Sequential ) return true;
diff -r 4de27dfc1ea5 -r b296e60bcafb include/libpc/drivers/liblas/Writer.hpp
--- a/include/libpc/drivers/liblas/Writer.hpp Wed Apr 13 14:45:07 2011 -0700
+++ b/include/libpc/drivers/liblas/Writer.hpp Wed Apr 13 16:06:33 2011 -0700
@@ -41,7 +41,9 @@
#include <libpc/drivers/las/Support.hpp>
#include <liblas/liblas.hpp>
+#include <liblas/guid.hpp>
+#include <boost/uuid/uuid.hpp>
namespace libpc { namespace drivers { namespace liblas {
@@ -59,6 +61,8 @@
void setPointFormat(::libpc::drivers::las::PointFormat);
void setDate(boost::uint16_t dayOfYear, boost::uint16_t year);
+ void setProjectId(const boost::uuids::uuid&);
+
// up to 32 chars (default is "libPC")
void setSystemIdentifier(const std::string& systemId);
diff -r 4de27dfc1ea5 -r b296e60bcafb src/drivers/las/Reader.cpp
--- a/src/drivers/las/Reader.cpp Wed Apr 13 14:45:07 2011 -0700
+++ b/src/drivers/las/Reader.cpp Wed Apr 13 16:06:33 2011 -0700
@@ -98,16 +98,16 @@
const PointIndexes indexes(schema, pointFormat);
+ boost::uint8_t buf[100]; // set to something larger than the largest point format requires
+
for (boost::uint32_t pointIndex=0; pointIndex<numPoints; pointIndex++)
{
- boost::uint8_t buf[34];
+ Utils::read_n(buf, stream, Support::getPointDataSize(pointFormat));
- if (pointFormat == PointFormat0)
+ boost::uint8_t* p = buf;
+
+ // always read the base fields
{
- Utils::read_n(buf, stream, Support::getPointDataSize(pointFormat));
-
- boost::uint8_t* p = buf;
-
const boost::int32_t x = Utils::read_field<boost::int32_t>(p);
const boost::int32_t y = Utils::read_field<boost::int32_t>(p);
const boost::int32_t z = Utils::read_field<boost::int32_t>(p);
@@ -135,65 +135,23 @@
data.setField<boost::int8_t>(pointIndex, indexes.ScanAngleRank, scanAngleRank);
data.setField<boost::uint8_t>(pointIndex, indexes.UserData, user);
data.setField<boost::uint16_t>(pointIndex, indexes.PointSourceId, pointSourceId);
+ }
+ if (Support::hasTime(pointFormat))
+ {
+ const double time = Utils::read_field<double>(p);
+ data.setField<double>(pointIndex, indexes.Time, time);
}
- else if (pointFormat == PointFormat1)
+
+ if (Support::hasColor(pointFormat))
{
- throw;
- //Utils::read_n(buf, m_istream, LasHeader::ePointSize1);
- }
- else if (pointFormat == PointFormat2)
- {
- throw;
- //Utils::read_n(buf, m_istream, LasHeader::ePointSize2);
- }
- else if (pointFormat == PointFormat3)
- {
- Utils::read_n(buf, stream, PointSize3);
-
- boost::uint8_t* p = buf;
-
- const boost::uint32_t x = Utils::read_field<boost::uint32_t>(p);
- const boost::uint32_t y = Utils::read_field<boost::uint32_t>(p);
- const boost::uint32_t z = Utils::read_field<boost::uint32_t>(p);
- const boost::uint16_t intensity = Utils::read_field<boost::uint16_t>(p);
- const boost::uint8_t flags = Utils::read_field<boost::uint8_t>(p);
- const boost::uint8_t classification = Utils::read_field<boost::uint8_t>(p);
- const boost::int8_t scanAngleRank = Utils::read_field<boost::int8_t>(p);
- const boost::uint8_t user = Utils::read_field<boost::uint8_t>(p);
- const boost::uint16_t pointSourceId = Utils::read_field<boost::uint16_t>(p);
- const double time = Utils::read_field<double>(p);
const boost::uint16_t red = Utils::read_field<boost::uint16_t>(p);
const boost::uint16_t green = Utils::read_field<boost::uint16_t>(p);
const boost::uint16_t blue = Utils::read_field<boost::uint16_t>(p);
- const boost::uint8_t returnNum = flags & 0x03;
- const boost::uint8_t numReturns = (flags >> 3) & 0x03;
- const boost::uint8_t scanDirFlag = (flags >> 6) & 0x01;
- const boost::uint8_t flight = (flags >> 7) & 0x01;
-
- data.setField<boost::uint32_t>(pointIndex, indexes.X, x);
- data.setField<boost::uint32_t>(pointIndex, indexes.Y, y);
- data.setField<boost::uint32_t>(pointIndex, indexes.Z, z);
- data.setField<boost::uint16_t>(pointIndex, indexes.Intensity, intensity);
- data.setField<boost::uint8_t>(pointIndex, indexes.ReturnNumber, returnNum);
- data.setField<boost::uint8_t>(pointIndex, indexes.NumberOfReturns, numReturns);
- data.setField<boost::uint8_t>(pointIndex, indexes.ScanDirectionFlag, scanDirFlag);
- data.setField<boost::uint8_t>(pointIndex, indexes.EdgeOfFlightLine, flight);
- data.setField<boost::uint8_t>(pointIndex, indexes.Classification, classification);
- data.setField<boost::int8_t>(pointIndex, indexes.ScanAngleRank, scanAngleRank);
- data.setField<boost::uint8_t>(pointIndex, indexes.UserData, user);
- data.setField<boost::uint16_t>(pointIndex, indexes.PointSourceId, pointSourceId);
- data.setField<double>(pointIndex, indexes.Time, time);
data.setField<boost::uint16_t>(pointIndex, indexes.Red, red);
data.setField<boost::uint16_t>(pointIndex, indexes.Green, green);
- data.setField<boost::uint16_t>(pointIndex, indexes.Blue, blue);
-
- }
-
- else
- {
- throw;
+ data.setField<boost::uint16_t>(pointIndex, indexes.Blue, blue);
}
data.setNumPoints(pointIndex+1);
diff -r 4de27dfc1ea5 -r b296e60bcafb src/drivers/las/Writer.cpp
--- a/src/drivers/las/Writer.cpp Wed Apr 13 14:45:07 2011 -0700
+++ b/src/drivers/las/Writer.cpp Wed Apr 13 16:06:33 2011 -0700
@@ -121,11 +121,10 @@
for (boost::uint32_t pointIndex=0; pointIndex<PointBuffer.getNumPoints(); pointIndex++)
{
+ boost::uint8_t* p = buf;
- if (pointFormat == PointFormat0)
+ // we always write the base fields
{
- boost::uint8_t* p = buf;
-
const boost::uint32_t x = PointBuffer.getField<boost::uint32_t>(pointIndex, indexes.X);
const boost::uint32_t y = PointBuffer.getField<boost::uint32_t>(pointIndex, indexes.Y);
const boost::uint32_t z = PointBuffer.getField<boost::uint32_t>(pointIndex, indexes.Z);
@@ -152,71 +151,31 @@
Utils::write_field<boost::int8_t>(p, scanAngleRank);
Utils::write_field<boost::uint8_t>(p, user);
Utils::write_field<boost::uint16_t>(p, pointSourceId);
+ }
- Utils::write_n(m_ostream, buf, Support::getPointDataSize(pointFormat));
+ if (Support::hasTime(pointFormat))
+ {
+ const double time = PointBuffer.getField<double>(pointIndex, indexes.Time);
+
+ Utils::write_field<double>(p, time);
}
- else if (pointFormat == PointFormat1)
+
+ if (Support::hasColor(pointFormat))
{
- throw;
- //Utils::write_n(m_ostream, buf, LasHeader::ePointSize1);
- }
- else if (pointFormat == PointFormat2)
- {
- throw;
- //Utils::write_n(m_ostream, buf, LasHeader::ePointSize2);
- }
- else if (pointFormat == PointFormat3)
- {
- boost::uint8_t* p = buf;
-
- const boost::uint32_t x = PointBuffer.getField<boost::uint32_t>(pointIndex, indexes.X);
- const boost::uint32_t y = PointBuffer.getField<boost::uint32_t>(pointIndex, indexes.Y);
- const boost::uint32_t z = PointBuffer.getField<boost::uint32_t>(pointIndex, indexes.Z);
- const boost::uint16_t intensity = PointBuffer.getField<boost::uint16_t>(pointIndex, indexes.Intensity);
-
- const boost::uint8_t returnNum = PointBuffer.getField<boost::uint8_t>(pointIndex, indexes.ReturnNumber);
- const boost::uint8_t numReturns = PointBuffer.getField<boost::uint8_t>(pointIndex, indexes.NumberOfReturns);
- const boost::uint8_t scanDirFlag = PointBuffer.getField<boost::uint8_t>(pointIndex, indexes.ScanDirectionFlag);
- const boost::uint8_t flight = PointBuffer.getField<boost::uint8_t>(pointIndex, indexes.EdgeOfFlightLine);
-
- const boost::uint8_t bits = returnNum & (numReturns<<3) & (scanDirFlag << 6) && (flight << 7);
-
- const boost::uint8_t classification = PointBuffer.getField<boost::uint8_t>(pointIndex, indexes.Classification);
- const boost::int8_t scanAngleRank = PointBuffer.getField<boost::int8_t>(pointIndex, indexes.ScanAngleRank);
- const boost::uint8_t user = PointBuffer.getField<boost::uint8_t>(pointIndex, indexes.UserData);
- const boost::uint16_t pointSourceId = PointBuffer.getField<boost::uint16_t>(pointIndex, indexes.PointSourceId);
- const double time = PointBuffer.getField<double>(pointIndex, indexes.Time);
const boost::uint16_t red = PointBuffer.getField<boost::uint16_t>(pointIndex, indexes.Red);
const boost::uint16_t green = PointBuffer.getField<boost::uint16_t>(pointIndex, indexes.Green);
const boost::uint16_t blue = PointBuffer.getField<boost::uint16_t>(pointIndex, indexes.Blue);
- Utils::write_field<boost::uint32_t>(p, x);
- Utils::write_field<boost::uint32_t>(p, y);
- Utils::write_field<boost::uint32_t>(p, z);
- Utils::write_field<boost::uint16_t>(p, intensity);
- Utils::write_field<boost::uint8_t>(p, bits);
- Utils::write_field<boost::uint8_t>(p, classification);
- Utils::write_field<boost::int8_t>(p, scanAngleRank);
- Utils::write_field<boost::uint8_t>(p, user);
- Utils::write_field<boost::uint16_t>(p, pointSourceId);
- Utils::write_field<double>(p, time);
Utils::write_field<boost::uint16_t>(p, red);
Utils::write_field<boost::uint16_t>(p, green);
Utils::write_field<boost::uint16_t>(p, blue);
+ }
- Utils::write_n(m_ostream, buf, PointSize3);
- }
- else
- {
- throw;
- }
+ Utils::write_n(m_ostream, buf, Support::getPointDataSize(pointFormat));
++numValidPoints;
}
- //std::vector<boost::uint8_t> const& data = point.GetData();
- //detail::write_n(m_ofs, data.front(), m_header->GetDataRecordLength());
-
m_numPointsWritten = m_numPointsWritten+numValidPoints;
return numValidPoints;
}
diff -r 4de27dfc1ea5 -r b296e60bcafb src/drivers/liblas/Reader.cpp
--- a/src/drivers/liblas/Reader.cpp Wed Apr 13 14:45:07 2011 -0700
+++ b/src/drivers/liblas/Reader.cpp Wed Apr 13 16:06:33 2011 -0700
@@ -97,6 +97,19 @@
return m_pointFormat;
}
+
+boost::uint8_t LiblasReader::getVersionMajor() const
+{
+ return m_versionMajor;
+}
+
+
+boost::uint8_t LiblasReader::getVersionMinor() const
+{
+ return m_versionMinor;
+}
+
+
void LiblasReader::processExternalHeader(::liblas::Reader& externalReader)
{
const ::liblas::Header& externalHeader = externalReader.GetHeader();
diff -r 4de27dfc1ea5 -r b296e60bcafb src/drivers/liblas/Writer.cpp
--- a/src/drivers/liblas/Writer.cpp Wed Apr 13 14:45:07 2011 -0700
+++ b/src/drivers/liblas/Writer.cpp Wed Apr 13 16:06:33 2011 -0700
@@ -34,6 +34,8 @@
#include <libpc/drivers/liblas/Writer.hpp>
+#include <boost/uuid/uuid_io.hpp>
+
#include <liblas/header.hpp>
#include <liblas/writer.hpp>
@@ -128,6 +130,14 @@
}
+void LiblasWriter::setProjectId(const boost::uuids::uuid& uuid)
+{
+ std::string s = to_string(uuid);
+ ::liblas::guid g(s);
+ m_externalHeader->SetProjectId(g);
+}
More information about the Liblas-commits
mailing list