[Liblas-commits] hg-main-tree: support compiling without LASzip
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Jun 9 12:21:16 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/da857b7ca85d
changeset: 773:da857b7ca85d
user: Howard Butler <hobu.inc at gmail.com>
date: Thu Jun 09 11:11:45 2011 -0500
description:
support compiling without LASzip
Subject: hg-main-tree: conditionally compile XML schema test
details: http://hg.libpc.orghg-main-tree/rev/9a6b1f50aee9
changeset: 774:9a6b1f50aee9
user: Howard Butler <hobu.inc at gmail.com>
date: Thu Jun 09 11:20:52 2011 -0500
description:
conditionally compile XML schema test
Subject: hg-main-tree: only support setSRSFromVLRs_geotiff when PDAL_SRS_ENABLED
details: http://hg.libpc.orghg-main-tree/rev/5c533adc4b0c
changeset: 775:5c533adc4b0c
user: Howard Butler <hobu.inc at gmail.com>
date: Thu Jun 09 11:21:09 2011 -0500
description:
only support setSRSFromVLRs_geotiff when PDAL_SRS_ENABLED
diffstat:
include/pdal/drivers/las/Iterator.hpp | 6 +-
include/pdal/drivers/las/Writer.hpp | 10 ++++-
src/drivers/las/Iterator.cpp | 34 +++++++++++++++++--
src/drivers/las/Reader.cpp | 4 ++
src/drivers/las/VariableLengthRecord.cpp | 3 +-
src/drivers/las/Writer.cpp | 55 +++++++++++++------------------
test/unit/CMakeLists.txt | 6 ++-
7 files changed, 75 insertions(+), 43 deletions(-)
diffs (truncated from 362 to 300 lines):
diff -r cabdcdbe89c7 -r 5c533adc4b0c include/pdal/drivers/las/Iterator.hpp
--- a/include/pdal/drivers/las/Iterator.hpp Thu Jun 09 10:36:28 2011 -0500
+++ b/include/pdal/drivers/las/Iterator.hpp Thu Jun 09 11:21:09 2011 -0500
@@ -64,12 +64,12 @@
std::istream* m_istream;
public:
+#ifdef PDAL_HAVE_LASZIP
boost::scoped_ptr<LASzip> m_zip;
boost::scoped_ptr<LASunzipper> m_unzipper;
boost::scoped_ptr<ZipPoint> m_zipPoint;
- // LASzip* m_zip;
- // LASunzipper* m_unzipper;
- // ZipPoint* m_zipPoint;
+
+#endif
private:
IteratorBase& operator=(const IteratorBase&); // not implemented
diff -r cabdcdbe89c7 -r 5c533adc4b0c include/pdal/drivers/las/Writer.hpp
--- a/include/pdal/drivers/las/Writer.hpp Thu Jun 09 10:36:28 2011 -0500
+++ b/include/pdal/drivers/las/Writer.hpp Thu Jun 09 11:21:09 2011 -0500
@@ -40,6 +40,7 @@
#include <pdal/Writer.hpp>
#include <pdal/drivers/las/Header.hpp>
#include <pdal/drivers/las/SummaryData.hpp>
+#include <boost/scoped_ptr.hpp>
// liblaszip
class LASzip;
@@ -91,11 +92,14 @@
boost::uint32_t m_numPointsWritten;
bool m_isCompressed;
SummaryData m_summaryData;
- LASzip* m_zip;
- LASzipper* m_zipper;
- ZipPoint* m_zipPoint;
SpatialReference m_spatialReference;
+#ifdef PDAL_HAVE_LASZIP
+ boost::scoped_ptr<LASzip> m_zip;
+ boost::scoped_ptr<LASzipper> m_zipper;
+ boost::scoped_ptr<ZipPoint> m_zipPoint;
+#endif
+
LasWriter& operator=(const LasWriter&); // not implemented
LasWriter(const LasWriter&); // not implemented
};
diff -r cabdcdbe89c7 -r 5c533adc4b0c src/drivers/las/Iterator.cpp
--- a/src/drivers/las/Iterator.cpp Thu Jun 09 10:36:28 2011 -0500
+++ b/src/drivers/las/Iterator.cpp Thu Jun 09 11:21:09 2011 -0500
@@ -50,16 +50,17 @@
IteratorBase::IteratorBase(const LasReader& reader)
: m_reader(reader)
, m_istream(NULL)
- , m_zip(NULL)
- , m_unzipper(NULL)
- , m_zipPoint(NULL)
{
m_istream = Utils::openFile(m_reader.getFileName());
m_istream->seekg(m_reader.getPointDataOffset());
if (m_reader.isCompressed())
{
+#ifdef PDAL_HAVE_LASZIP
initializeZip();
+#else
+ throw pdal_error("LASzip is not enabled for this pdal::drivers::las::IteratorBase!");
+#endif
}
return;
@@ -74,6 +75,8 @@
void IteratorBase::initializeZip()
{
+#ifdef PDAL_HAVE_LASZIP
+
try
{
// Initialize a scoped_ptr and swap it with our member variable
@@ -147,7 +150,7 @@
throw pdal_error("Failed to open laszip decompression engine (3)");
}
}
-
+#endif
return;
}
@@ -168,6 +171,7 @@
boost::uint64_t SequentialIterator::skipImpl(boost::uint64_t count)
{
+#ifdef PDAL_HAVE_LASZIP
if (m_zip)
{
m_unzipper->seek(getIndex() + count);
@@ -177,6 +181,10 @@
boost::uint64_t delta = Support::getPointDataSize(m_reader.getPointFormat());
m_istream->seekg(delta * count, std::ios::cur);
}
+#else
+ boost::uint64_t delta = Support::getPointDataSize(m_reader.getPointFormat());
+ m_istream->seekg(delta * count, std::ios::cur);
+#endif
return count;
}
@@ -189,7 +197,12 @@
boost::uint32_t SequentialIterator::readImpl(PointBuffer& data)
{
+#ifdef PDAL_HAVE_LASZIP
return m_reader.processBuffer(data, *m_istream, getStage().getNumPoints()-this->getIndex(), m_unzipper.get(), m_zipPoint.get());
+#else
+ return m_reader.processBuffer(data, *m_istream, getStage().getNumPoints()-this->getIndex(), NULL, NULL);
+
+#endif
}
@@ -210,6 +223,7 @@
boost::uint64_t RandomIterator::seekImpl(boost::uint64_t count)
{
+#ifdef PDAL_HAVE_LASZIP
if (m_zip)
{
m_unzipper->seek(count);
@@ -219,13 +233,25 @@
boost::uint64_t delta = Support::getPointDataSize(m_reader.getPointFormat());
m_istream->seekg(m_reader.getPointDataOffset() + delta * count);
}
+#else
+
+ boost::uint64_t delta = Support::getPointDataSize(m_reader.getPointFormat());
+ m_istream->seekg(m_reader.getPointDataOffset() + delta * count);
+
+#endif
+
return count;
}
boost::uint32_t RandomIterator::readImpl(PointBuffer& data)
{
+#ifdef PDAL_HAVE_LASZIP
return m_reader.processBuffer(data, *m_istream, getStage().getNumPoints()-this->getIndex(), m_unzipper.get(), m_zipPoint.get());
+#else
+ return m_reader.processBuffer(data, *m_istream, getStage().getNumPoints()-this->getIndex(), NULL, NULL);
+
+#endif
}
diff -r cabdcdbe89c7 -r 5c533adc4b0c src/drivers/las/Reader.cpp
--- a/src/drivers/las/Reader.cpp Thu Jun 09 10:36:28 2011 -0500
+++ b/src/drivers/las/Reader.cpp Thu Jun 09 11:21:09 2011 -0500
@@ -179,6 +179,7 @@
if (zipPoint)
{
+#ifdef PDAL_HAVE_LASZIP
boost::uint8_t* p = buf;
for (boost::uint32_t i=0; i<numPoints; i++)
@@ -200,6 +201,9 @@
memcpy(p, zipPoint->m_lz_point_data, zipPoint->m_lz_point_size);
p += zipPoint->m_lz_point_size;
}
+#else
+ throw pdal_error("LASzip is not enabled for this pdal::drivers::las::Reader::processBuffer");
+#endif
}
else
{
diff -r cabdcdbe89c7 -r 5c533adc4b0c src/drivers/las/VariableLengthRecord.cpp
--- a/src/drivers/las/VariableLengthRecord.cpp Thu Jun 09 10:36:28 2011 -0500
+++ b/src/drivers/las/VariableLengthRecord.cpp Thu Jun 09 11:21:09 2011 -0500
@@ -208,6 +208,7 @@
static bool setSRSFromVLRs_geotiff(const std::vector<VariableLengthRecord>& vlrs, SpatialReference& srs)
{
+#ifdef PDAL_SRS_ENABLED
GeotiffSupport geotiff;
geotiff.resetTags();
@@ -287,7 +288,7 @@
const std::string wkt = geotiff.getWkt(false,false);
srs.setFromUserInput(wkt);
-
+#endif
return true;
}
diff -r cabdcdbe89c7 -r 5c533adc4b0c src/drivers/las/Writer.cpp
--- a/src/drivers/las/Writer.cpp Thu Jun 09 10:36:28 2011 -0500
+++ b/src/drivers/las/Writer.cpp Thu Jun 09 11:21:09 2011 -0500
@@ -40,7 +40,9 @@
#include "ZipPoint.hpp"
// laszip
+#ifdef PDAL_HAVE_LASZIP
#include <laszip/laszipper.hpp>
+#endif
#include <pdal/exceptions.hpp>
#include <pdal/Stage.hpp>
@@ -57,9 +59,6 @@
, m_ostream(ostream)
, m_numPointsWritten(0)
, m_isCompressed(false)
- , m_zip(NULL)
- , m_zipper(NULL)
- , m_zipPoint(NULL)
{
m_spatialReference = prevStage.getSpatialReference();
@@ -69,9 +68,7 @@
LasWriter::~LasWriter()
{
- delete m_zipper;
- delete m_zipPoint;
- delete m_zip;
+
}
@@ -171,16 +168,15 @@
if (m_lasHeader.Compressed())
{
- delete m_zipper;
- delete m_zipPoint;
- m_zipper = NULL;
- m_zipPoint = NULL;
-
- if (m_zip==NULL)
+#ifdef PDAL_HAVE_LASZIP
+ if (!m_zip)
{
try
{
- m_zip = new LASzip();
+ // Initialize a scoped_ptr and swap it with our member variable
+ // that will contain it.
+ boost::scoped_ptr<LASzip> s(new LASzip());
+ m_zip.swap(s);
}
catch(...)
{
@@ -188,8 +184,8 @@
}
PointFormat format = m_lasHeader.getPointFormat();
- delete m_zipPoint;
- m_zipPoint = new ZipPoint(format, m_lasHeader.getVLRs().getAll());
+ boost::scoped_ptr<ZipPoint> z(new ZipPoint(format, m_lasHeader.getVLRs().getAll()));
+ m_zipPoint.swap(z);
bool ok = false;
try
@@ -219,45 +215,38 @@
}
}
- if (m_zipper == NULL)
+ if (!m_zipper)
{
try
{
- m_zipper = new LASzipper();
+ boost::scoped_ptr<LASzipper> z(new LASzipper());
+ m_zipper.swap(z);
}
catch(...)
{
- delete m_zipper;
- m_zipper = NULL;
throw pdal_error("Error opening compression engine (1)");
}
PointFormat format = m_lasHeader.getPointFormat();
- delete m_zipPoint;
- m_zipPoint = new ZipPoint(format, m_lasHeader.getVLRs().getAll());
-
+ boost::scoped_ptr<ZipPoint> z(new ZipPoint(format, m_lasHeader.getVLRs().getAll()));
+ m_zipPoint.swap(z);
unsigned int stat = 1;
try
{
- stat = m_zipper->open(m_ostream, m_zip);
+ stat = m_zipper->open(m_ostream, m_zip.get());
}
catch(...)
{
- delete m_zipper;
More information about the Liblas-commits
mailing list