[Liblas-commits] hg-main-tree: added binpath();
make sure paths end in trailing s...
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Aug 12 13:27:51 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/57ac04c35bd7
changeset: 1069:57ac04c35bd7
user: Michael P. Gerlek <mpg at flaxen.com>
date: Fri Aug 12 10:22:14 2011 -0700
description:
added binpath(); make sure paths end in trailing slash
Subject: hg-main-tree: restore app-level catching
details: http://hg.libpc.orghg-main-tree/rev/c6a70eb1a6a9
changeset: 1070:c6a70eb1a6a9
user: Michael P. Gerlek <mpg at flaxen.com>
date: Fri Aug 12 10:22:55 2011 -0700
description:
restore app-level catching
Subject: hg-main-tree: merge
details: http://hg.libpc.orghg-main-tree/rev/e14101254dc5
changeset: 1071:e14101254dc5
user: Michael P. Gerlek <mpg at flaxen.com>
date: Fri Aug 12 10:23:07 2011 -0700
description:
merge
diffstat:
apps/Application.cpp | 28 ++++----
include/pdal/FileUtils.hpp | 4 +
include/pdal/PointBuffer.hpp | 10 +++
include/pdal/drivers/las/Writer.hpp | 2 +
include/pdal/drivers/liblas/Writer.hpp | 4 +-
src/FileUtils.cpp | 20 +++++-
src/drivers/las/LasHeaderWriter.cpp | 11 ++-
src/drivers/las/Writer.cpp | 4 +
src/drivers/liblas/Writer.cpp | 4 +
test/unit/FileUtilsTest.cpp | 12 +-
test/unit/LasWriterTest.cpp | 1 +
test/unit/LiblasWriterTest.cpp | 1 +
test/unit/Support.cpp | 100 ++++++++++++++++++++++++++++++++-
test/unit/Support.hpp | 27 ++++++++-
test/unit/SupportTest.cpp | 16 +++-
test/unit/pcinfoTest.cpp | 6 +-
16 files changed, 212 insertions(+), 38 deletions(-)
diffs (truncated from 517 to 300 lines):
diff -r 812381915e9d -r e14101254dc5 apps/Application.cpp
--- a/apps/Application.cpp Fri Aug 12 09:41:58 2011 -0700
+++ b/apps/Application.cpp Fri Aug 12 10:23:07 2011 -0700
@@ -91,21 +91,21 @@
// call derived function
int status = 0;
- // try
- // {
+ try
+ {
status = execute();
- // }
- // catch (std::exception e)
- // {
- // const std::string s(e.what());
- // runtimeError("Caught exception: " + s);
- // status = 1;
- // }
- // catch (...)
- // {
- // runtimeError("Caught unknown exception");
- // status = 1;
- // }
+ }
+ catch (std::exception e)
+ {
+ const std::string s(e.what());
+ runtimeError("Caught exception: " + s);
+ status = 1;
+ }
+ catch (...)
+ {
+ runtimeError("Caught unknown exception");
+ status = 1;
+ }
if (status == 0 && hasOption("timer"))
{
diff -r 812381915e9d -r e14101254dc5 include/pdal/FileUtils.hpp
--- a/include/pdal/FileUtils.hpp Fri Aug 12 09:41:58 2011 -0700
+++ b/include/pdal/FileUtils.hpp Fri Aug 12 10:23:07 2011 -0700
@@ -66,9 +66,11 @@
static boost::uintmax_t fileSize(const std::string& filename);
// return current working dir
+ // the result will always have a trailing '/'
static std::string getcwd();
// return the directory component of the given path, e.g. "d:/foo/bar/a.c" -> "d:/foo/bar"
+ // the result will always have a trailing '/'
static std::string getDirectory(const std::string& path);
// returns true iff the path is not relative
@@ -85,6 +87,8 @@
static std::string toAbsolutePath(const std::string& filename, const std::string base);
private:
+ static std::string addTrailingSlash(const std::string& path);
+
FileUtils& operator=(const FileUtils&); // not implemented
FileUtils(const FileUtils&); // not implemented;
};
diff -r 812381915e9d -r e14101254dc5 include/pdal/PointBuffer.hpp
--- a/include/pdal/PointBuffer.hpp Fri Aug 12 09:41:58 2011 -0700
+++ b/include/pdal/PointBuffer.hpp Fri Aug 12 10:23:07 2011 -0700
@@ -148,6 +148,16 @@
return;
}
+
+ inline boost::uint64_t getBufferByteLength() const
+ {
+ return m_pointSize*m_numPoints;
+ }
+ inline boost::uint64_t getBufferByteCapacity() const
+ {
+ return m_pointSize*m_capacity;
+ }
+
// access to the raw memory
inline boost::uint8_t* getData(std::size_t pointIndex) const
diff -r 812381915e9d -r e14101254dc5 include/pdal/drivers/las/Writer.hpp
--- a/include/pdal/drivers/las/Writer.hpp Fri Aug 12 09:41:58 2011 -0700
+++ b/include/pdal/drivers/las/Writer.hpp Fri Aug 12 10:23:07 2011 -0700
@@ -73,6 +73,8 @@
// up to 32 chars (default is "PDAL x.y.z")
void setGeneratingSoftware(const std::string& softwareId);
+
+ void setHeaderPadding(boost::uint32_t const& v);
// default false
void setCompressed(bool);
diff -r 812381915e9d -r e14101254dc5 include/pdal/drivers/liblas/Writer.hpp
--- a/include/pdal/drivers/liblas/Writer.hpp Fri Aug 12 09:41:58 2011 -0700
+++ b/include/pdal/drivers/liblas/Writer.hpp Fri Aug 12 10:23:07 2011 -0700
@@ -76,7 +76,9 @@
// default false
void setCompressed(bool);
-
+
+ void setHeaderPadding(boost::uint32_t const& v);
+
protected:
virtual void writeBegin(boost::uint64_t targetNumPointsToWrite);
virtual boost::uint32_t writeBuffer(const PointBuffer&);
diff -r 812381915e9d -r e14101254dc5 src/FileUtils.cpp
--- a/src/FileUtils.cpp Fri Aug 12 09:41:58 2011 -0700
+++ b/src/FileUtils.cpp Fri Aug 12 10:23:07 2011 -0700
@@ -134,10 +134,23 @@
}
+std::string FileUtils::addTrailingSlash(const std::string& path)
+{
+ std::string ret = path;
+
+ if (ret[ret.size() - 1] != '/')
+ ret += "/";
+
+ return ret;
+}
+
+
std::string FileUtils::getcwd()
{
const boost::filesystem::path p = boost::filesystem::current_path();
- return p.generic_string();
+ std::string path = p.generic_string();
+ path = addTrailingSlash(path);
+ return path;
}
@@ -165,8 +178,9 @@
std::string FileUtils::getDirectory(const std::string& path)
{
const boost::filesystem::path dir = boost::filesystem::path(path).parent_path();
- const std::string str = dir.generic_string();
- return str;
+ std::string ret = dir.generic_string();
+ ret = addTrailingSlash(ret);
+ return ret;
}
diff -r 812381915e9d -r e14101254dc5 src/drivers/las/LasHeaderWriter.cpp
--- a/src/drivers/las/LasHeaderWriter.cpp Fri Aug 12 09:41:58 2011 -0700
+++ b/src/drivers/las/LasHeaderWriter.cpp Fri Aug 12 10:23:07 2011 -0700
@@ -109,6 +109,7 @@
}
{
+ boost::uint32_t padding_before_calculations = m_header.GetHeaderPadding();
int32_t existing_padding = m_header.GetDataOffset() -
(m_header.getVLRBlockSize() +
m_header.GetHeaderSize());
@@ -137,12 +138,14 @@
}
}
-
- m_header.SetDataOffset( m_header.GetHeaderSize() +
- m_header.getVLRBlockSize() +
- m_header.GetHeaderPadding());
+
+ m_header.SetDataOffset( m_header.GetHeaderSize() +
+ m_header.getVLRBlockSize() +
+ m_header.GetHeaderPadding() + padding_before_calculations);
}
+
+
// 1. File Signature
std::string const filesig(m_header.GetFileSignature());
diff -r 812381915e9d -r e14101254dc5 src/drivers/las/Writer.cpp
--- a/src/drivers/las/Writer.cpp Fri Aug 12 09:41:58 2011 -0700
+++ b/src/drivers/las/Writer.cpp Fri Aug 12 10:23:07 2011 -0700
@@ -168,6 +168,10 @@
m_spatialReference = srs;
}
+void LasWriter::setHeaderPadding(boost::uint32_t const& v)
+{
+ m_lasHeader.SetHeaderPadding(v);
+}
void LasWriter::writeBegin(boost::uint64_t targetNumPointsToWrite)
{
diff -r 812381915e9d -r e14101254dc5 src/drivers/liblas/Writer.cpp
--- a/src/drivers/liblas/Writer.cpp Fri Aug 12 09:41:58 2011 -0700
+++ b/src/drivers/liblas/Writer.cpp Fri Aug 12 10:23:07 2011 -0700
@@ -129,6 +129,10 @@
m_externalHeader->SetCompressed(v);
}
+void LiblasWriter::setHeaderPadding(boost::uint32_t const& v)
+{
+ m_externalHeader->SetHeaderPadding(v);
+}
void LiblasWriter::setFormatVersion(boost::uint8_t majorVersion, boost::uint8_t minorVersion)
{
diff -r 812381915e9d -r e14101254dc5 test/unit/FileUtilsTest.cpp
--- a/test/unit/FileUtilsTest.cpp Fri Aug 12 09:41:58 2011 -0700
+++ b/test/unit/FileUtilsTest.cpp Fri Aug 12 10:23:07 2011 -0700
@@ -84,7 +84,7 @@
#if 0
// this is hardcoded for mpg's environment
const std::string cwd = FileUtils::getcwd();
- BOOST_CHECK(cwd == "D:/dev/pdal/test/unit");
+ BOOST_CHECK(cwd == "D:/dev/pdal/test/unit/");
#endif
return;
@@ -106,7 +106,7 @@
// check 1-arg version: make absolute when file is relative, via current working dir
const string a = FileUtils::toAbsolutePath("foo.txt");
- BOOST_CHECK_EQUAL(a, root + "/" + "foo.txt");
+ BOOST_CHECK_EQUAL(a, root + "foo.txt");
// check 1-arg version: make absolute when file is already absolute
const string b = FileUtils::toAbsolutePath(drive + "/baz/foo.txt");
@@ -118,11 +118,11 @@
// check 2-arg version: make absolute when file is relative, via given base (which isn't absolute)
const string d = FileUtils::toAbsolutePath("foo.txt", "x/y/z");
- BOOST_CHECK_EQUAL(d, root + "/" + "x/y/z/" + "foo.txt");
+ BOOST_CHECK_EQUAL(d, root + "x/y/z/" + "foo.txt");
// check 1-arg version: make absolute when file is already absolute
const string e = FileUtils::toAbsolutePath(drive+"/baz/foo.txt", drive+"/a/b/c/d");
- BOOST_CHECK_EQUAL(e, drive+"/baz/foo.txt");
+ BOOST_CHECK_EQUAL(e, drive + "/baz/foo.txt");
return;
}
@@ -132,11 +132,11 @@
{
// test absolute case
const std::string a = FileUtils::getDirectory(drive + "/a/b/foo.txt");
- BOOST_CHECK_EQUAL(a, drive+"/a/b");
+ BOOST_CHECK_EQUAL(a, drive + "/a/b/");
// test relative case
const std::string b = FileUtils::getDirectory("a/b/foo.txt");
- BOOST_CHECK_EQUAL(b, "a/b");
+ BOOST_CHECK_EQUAL(b, "a/b/");
return;
}
diff -r 812381915e9d -r e14101254dc5 test/unit/LasWriterTest.cpp
--- a/test/unit/LasWriterTest.cpp Fri Aug 12 09:41:58 2011 -0700
+++ b/test/unit/LasWriterTest.cpp Fri Aug 12 10:23:07 2011 -0700
@@ -109,6 +109,7 @@
writer.setPointFormat(::pdal::drivers::las::PointFormat3);
writer.setSystemIdentifier("");
writer.setGeneratingSoftware("TerraScan");
+ writer.setHeaderPadding(2);
writer.initialize();
diff -r 812381915e9d -r e14101254dc5 test/unit/LiblasWriterTest.cpp
--- a/test/unit/LiblasWriterTest.cpp Fri Aug 12 09:41:58 2011 -0700
+++ b/test/unit/LiblasWriterTest.cpp Fri Aug 12 10:23:07 2011 -0700
@@ -150,6 +150,7 @@
writer.setPointFormat(::pdal::drivers::las::PointFormat3);
writer.setSystemIdentifier("");
writer.setGeneratingSoftware("TerraScan");
+ writer.setHeaderPadding(2);
writer.write(numPoints);
}
diff -r 812381915e9d -r e14101254dc5 test/unit/Support.cpp
--- a/test/unit/Support.cpp Fri Aug 12 09:41:58 2011 -0700
+++ b/test/unit/Support.cpp Fri Aug 12 10:23:07 2011 -0700
@@ -43,24 +43,118 @@
#include <pdal/Schema.hpp>
#include <pdal/Dimension.hpp>
#include <pdal/PointBuffer.hpp>
-
+#include <pdal/StageIterator.hpp>
+#include <pdal/Options.hpp>
+#include <pdal/PointBuffer.hpp>
+#include <pdal/Stage.hpp>
+#include <pdal/SchemaLayout.hpp>
+#include <pdal/exceptions.hpp>
#include "TestConfig.hpp"
+std::string Support::datapath()
+{
+ const std::string s = TestConfig::g_data_path;
+ return s;
+}
More information about the Liblas-commits
mailing list