[Liblas-commits] hg: 2 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Oct 25 11:40:20 EDT 2010
changeset 6d1f843f300b in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=6d1f843f300b
summary: keep stream buffer setting experiment
changeset 02df82d848f4 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=02df82d848f4
summary: ignore unused
diffstat:
apps/las2las.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++++++++------
src/laspoint.cpp | 2 +-
2 files changed, 63 insertions(+), 9 deletions(-)
diffs (151 lines):
diff -r e5200e060709 -r 02df82d848f4 apps/las2las.cpp
--- a/apps/las2las.cpp Mon Oct 25 08:44:40 2010 -0600
+++ b/apps/las2las.cpp Mon Oct 25 10:40:08 2010 -0500
@@ -20,6 +20,50 @@
using namespace liblas;
using namespace std;
+// 0, 4, 16, 64, 256
+//std::size_t const default_buffer_size = 0;
+//std::size_t const default_buffer_size = 4 * 1024;
+//std::size_t const default_buffer_size = 16 * 1024;
+//std::size_t const default_buffer_size = 64 * 1024;
+//std::size_t const default_buffer_size = 256 * 1024;
+std::size_t const default_buffer_size = 1024 * 1024;
+std::vector<char> ofs_buffer;
+std::vector<char> ifs_buffer;
+
+std::ofstream& set_ofstream_buffer(std::ofstream& ofs, std::size_t buffer_size)
+{
+ char* buffer = 0; // unbuffered;
+ if (buffer_size > 0)
+ {
+ std::vector<char>(buffer_size).swap(ofs_buffer);
+ buffer = &ofs_buffer[0];
+ }
+
+ std::streambuf* sb = ofs.rdbuf()->pubsetbuf(buffer, buffer_size);
+ if (0 != buffer && 0 == sb)
+ {
+ throw std::runtime_error("failed to attach non-null buffer to input file stream");
+ }
+ return ofs;
+}
+
+std::ifstream& set_ifstream_buffer(std::ifstream& ifs, std::size_t buffer_size)
+{
+ char* buffer = 0; // unbuffered;
+ if (buffer_size > 0)
+ {
+ std::vector<char>(buffer_size).swap(ifs_buffer);
+ buffer = &ifs_buffer[0];
+ }
+
+ std::streambuf* sb = ifs.rdbuf()->pubsetbuf(buffer, buffer_size);
+ if (0 != buffer && 0 == sb)
+ {
+ throw std::runtime_error("failed to attach non-null buffer to input file stream");
+ }
+ return ifs;
+}
+
liblas::Writer* start_writer( std::ofstream* strm,
std::string const& output,
liblas::Header const& header)
@@ -30,13 +74,15 @@
std::ostringstream oss;
oss << "Cannot create " << output << "for write. Exiting...";
throw std::runtime_error(oss.str());
- }
+ }
+
+ // set_ofstream_buffer(*strm, default_buffer_size);
+
liblas::Writer* writer = new liblas::Writer(*strm, header);
return writer;
}
-
bool process( std::string const& input,
std::string const& output,
liblas::Header & header,
@@ -48,14 +94,14 @@
bool min_offset)
{
-
-
std::ifstream ifs;
if (!liblas::Open(ifs, input.c_str()))
{
std::cerr << "Cannot open " << input << "for read. Exiting...";
return false;
}
+ // set_ifstream_buffer(ifs, default_buffer_size);
+
liblas::Reader reader(ifs);
liblas::Summary* summary = new liblas::Summary;
@@ -74,9 +120,11 @@
tree.get<double>("minimum.z"));
- } catch (liblas::property_tree::ptree_bad_path const& e)
+ }
+ catch (liblas::property_tree::ptree_bad_path const& e)
{
std::cerr << "Unable to write minimum header info. Does the outputted file have any points?";
+ e.what();
return false;
}
if (verbose)
@@ -287,14 +335,18 @@
if (vm.count("input"))
{
input = vm["input"].as< string >();
- std::ifstream ifs;
+
if (verbose)
std::cout << "Opening " << input << " to fetch Header" << std::endl;
+
+ std::ifstream ifs;
if (!liblas::Open(ifs, input.c_str()))
{
std::cerr << "Cannot open " << input << "for read. Exiting...";
return 1;
}
+ // set_ifstream_buffer(ifs, default_buffer_size);
+
liblas::Reader reader(ifs);
header = reader.GetHeader();
} else {
@@ -332,11 +384,13 @@
}
}
- catch(std::exception& e) {
+ catch(std::exception& e)
+ {
std::cerr << "error: " << e.what() << "\n";
return 1;
}
- catch(...) {
+ catch(...)
+ {
std::cerr << "Exception of unknown type!\n";
}
diff -r e5200e060709 -r 02df82d848f4 src/laspoint.cpp
--- a/src/laspoint.cpp Mon Oct 25 08:44:40 2010 -0600
+++ b/src/laspoint.cpp Mon Oct 25 10:40:08 2010 -0500
@@ -866,8 +866,8 @@
boost::any Point::GetValue(Dimension const& d) const
{
boost::any output;
+ boost::ignore_unused_variable_warning(d);
-
return output;
}
More information about the Liblas-commits
mailing list