[Liblas-commits] libpc: improve liblaswriter
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Feb 28 19:15:19 EST 2011
details: http://hg.liblas.orglibpc/rev/17fff2474d04
changeset: 122:17fff2474d04
user: Michael P. Gerlek <mpg at flaxen.com>
date: Mon Feb 28 16:15:15 2011 -0800
description:
improve liblaswriter
diffstat:
src/drivers/liblas/writer.cpp | 51 ++++++++++++++++++++++++++++++++++++----
src/drivers/liblas/writer.hpp | 8 ++++++
test/data/simple.las | 0
test/unit/LiblasWriterTest.cpp | 2 +
4 files changed, 56 insertions(+), 5 deletions(-)
diffs (135 lines):
diff -r d9188caa4f11 -r 17fff2474d04 src/drivers/liblas/writer.cpp
--- a/src/drivers/liblas/writer.cpp Mon Feb 28 15:34:21 2011 -0800
+++ b/src/drivers/liblas/writer.cpp Mon Feb 28 16:15:15 2011 -0800
@@ -40,6 +40,7 @@
#include <liblas/Writer.hpp>
#include <libpc/exceptions.hpp>
+#include <libpc/libpc_config.hpp>
namespace libpc
@@ -54,15 +55,12 @@
m_externalHeader = new liblas::Header;
m_externalHeader->SetCompressed(false);
- setFormatVersion(1,2);
- setPointFormat(0);
+ setupExternalHeader();
// make our own header
LiblasHeader* internalHeader = new LiblasHeader;
setHeader(internalHeader);
- //myHeader->setNumPoints( extHeader.GetPointRecordsCount() );
-
//const liblas::Bounds<double>& extBounds = extHeader.GetExtent();
//const Bounds<double> bounds(extBounds.minx(), extBounds.miny(), extBounds.minz(), extBounds.maxx(), extBounds.maxy(), extBounds.maxz());
//myHeader->setBounds(bounds);
@@ -78,6 +76,27 @@
}
+void LiblasWriter::setupExternalHeader()
+{
+ setFormatVersion(1,2);
+ setPointFormat(0);
+
+ setSystemIdentifier("libPC");
+ setGeneratingSoftware(GetVersionString());
+
+ std::size_t indexX = getHeader().getSchema().getDimensionIndex(Dimension::Field_X);
+ std::size_t indexY = getHeader().getSchema().getDimensionIndex(Dimension::Field_Y);
+ std::size_t indexZ = getHeader().getSchema().getDimensionIndex(Dimension::Field_Z);
+ const Dimension& dimX = getHeader().getSchema().getDimension(indexX);
+ const Dimension& dimY = getHeader().getSchema().getDimension(indexY);
+ const Dimension& dimZ = getHeader().getSchema().getDimension(indexZ);
+ m_externalHeader->SetScale(dimX.getNumericScale(), dimY.getNumericScale(), dimZ.getNumericScale());
+ m_externalHeader->SetOffset(dimX.getNumericOffset(), dimY.getNumericOffset(), dimZ.getNumericOffset());
+
+ return;
+}
+
+
void LiblasWriter::setFormatVersion(boost::uint8_t majorVersion, boost::uint8_t minorVersion)
{
m_externalHeader->SetVersionMajor(majorVersion);
@@ -98,9 +117,22 @@
}
+void LiblasWriter::setSystemIdentifier(const std::string& systemId)
+{
+ m_externalHeader->SetSystemId(systemId);
+}
+
+
+void LiblasWriter::setGeneratingSoftware(const std::string& softwareId)
+{
+ m_externalHeader->SetSoftwareId(softwareId);
+}
+
+
void LiblasWriter::writeBegin()
{
- m_externalHeader->SetPointRecordsCount(99);
+ m_externalHeader->SetPointRecordsCount(99); // BUG
+
m_externalWriter = new liblas::Writer(m_ostream, *m_externalHeader);
return;
}
@@ -201,6 +233,15 @@
const boost::uint8_t scanAngleRank = pointData.getField<boost::uint8_t>(i, indexScanAngleRank);
const boost::uint8_t userData = pointData.getField<boost::uint8_t>(i, indexUserData);
const boost::uint16_t pointSourceId = pointData.getField<boost::uint16_t>(i, indexPointSourceId);
+ pt.SetIntensity(intensity);
+ pt.SetReturnNumber(returnNumber);
+ pt.SetNumberOfReturns(numberOfReturns);
+ pt.SetScanDirection(scanDirFlag);
+ pt.SetFlightLineEdge(edgeOfFlightLine);
+ pt.SetClassification(classification);
+ pt.SetScanAngleRank(scanAngleRank);
+ pt.SetUserData(userData);
+ pt.SetPointSourceID(pointSourceId);
if (hasTimeData)
{
diff -r d9188caa4f11 -r 17fff2474d04 src/drivers/liblas/writer.hpp
--- a/src/drivers/liblas/writer.hpp Mon Feb 28 15:34:21 2011 -0800
+++ b/src/drivers/liblas/writer.hpp Mon Feb 28 16:15:15 2011 -0800
@@ -57,6 +57,12 @@
void setFormatVersion(boost::uint8_t majorVersion, boost::uint8_t minorVersion);
void setPointFormat(boost::int8_t pointFormat);
void setDate(boost::uint16_t dayOfYear, boost::uint16_t year);
+
+ // up to 32 chars (default is "libPC")
+ void setSystemIdentifier(const std::string& systemId);
+
+ // up to 32 chars (default is "libPC x.y.z")
+ void setGeneratingSoftware(const std::string& softwareId);
protected:
// this is called once before the loop with the writeBuffer calls
@@ -69,6 +75,8 @@
virtual void writeEnd();
private:
+ void setupExternalHeader();
+
std::ostream& m_ostream;
liblas::Writer* m_externalWriter;
liblas::Header* m_externalHeader;
diff -r d9188caa4f11 -r 17fff2474d04 test/data/simple.las
Binary file test/data/simple.las has changed
diff -r d9188caa4f11 -r 17fff2474d04 test/unit/LiblasWriterTest.cpp
--- a/test/unit/LiblasWriterTest.cpp Mon Feb 28 15:34:21 2011 -0800
+++ b/test/unit/LiblasWriterTest.cpp Mon Feb 28 16:15:15 2011 -0800
@@ -63,6 +63,8 @@
writer.setDate(0, 0);
writer.setPointFormat(3);
+ writer.setSystemIdentifier("");
+ writer.setGeneratingSoftware("TerraScan");
writer.write(numPoints);
}
More information about the Liblas-commits
mailing list