[Liblas-commits] hg-1.6: fix #207 extra work in files with invalid
point counts
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Feb 17 13:43:25 EST 2011
details: http://hg.liblas.orghg-1.6/rev/a9289ac44e6a
changeset: 2846:a9289ac44e6a
user: Howard Butler <hobu.inc at gmail.com>
date: Mon Feb 14 13:07:06 2011 -0600
description:
fix #207 extra work in files with invalid point counts
Subject: hg-1.6: fix #208 display of header summary in lasinfo
details: http://hg.liblas.orghg-1.6/rev/3b86b3eaafd4
changeset: 2847:3b86b3eaafd4
user: Howard Butler <hobu.inc at gmail.com>
date: Mon Feb 14 13:10:19 2011 -0600
description:
fix #208 display of header summary in lasinfo
Subject: hg-1.6: output of a single point's XML is not valid XML #210
details: http://hg.liblas.orghg-1.6/rev/7bc6b2de480c
changeset: 2848:7bc6b2de480c
user: Howard Butler <hobu.inc at gmail.com>
date: Thu Feb 17 11:33:38 2011 -0600
description:
output of a single point's XML is not valid XML #210
Subject: hg-1.6: fix #213, liblas::Cleanup methods no using the proper cast to determine if they have a file-based stream
details: http://hg.liblas.orghg-1.6/rev/d3de717cd0b7
changeset: 2849:d3de717cd0b7
user: Howard Butler <hobu.inc at gmail.com>
date: Thu Feb 17 12:41:02 2011 -0600
description:
fix #213, liblas::Cleanup methods no using the proper cast to determine if they have a file-based stream
diffstat:
apps/lasinfo.cpp | 4 ++--
include/liblas/liblas.hpp | 35 +++++++++++++++++++++++++++++++----
src/detail/reader/reader.cpp | 3 ++-
3 files changed, 35 insertions(+), 7 deletions(-)
diffs (92 lines):
diff -r 12230c12cca9 -r d3de717cd0b7 apps/lasinfo.cpp
--- a/apps/lasinfo.cpp Tue Feb 01 13:40:39 2011 -0600
+++ b/apps/lasinfo.cpp Thu Feb 17 12:41:02 2011 -0600
@@ -204,7 +204,7 @@
liblas::Point const& p = reader.GetPoint();
if (output_xml) {
liblas::property_tree::ptree tree;
- tree = p.GetPTree();
+ tree.add_child("points.point", p.GetPTree());
liblas::property_tree::write_xml(std::cout, tree);
exit(0);
}
@@ -236,7 +236,7 @@
verbose
);
- liblas::Header const& header = reader.GetHeader();
+ header = reader.GetHeader();
// Add the header to the summary so we can get more detailed
// info
diff -r 12230c12cca9 -r d3de717cd0b7 include/liblas/liblas.hpp
--- a/include/liblas/liblas.hpp Tue Feb 01 13:40:39 2011 -0600
+++ b/include/liblas/liblas.hpp Thu Feb 17 12:41:02 2011 -0600
@@ -166,11 +166,25 @@
// An ofstream is closeable and deletable, but
// an ostream like &std::cout isn't.
if (!ofs) return;
- if (static_cast<std::ofstream&>(*ofs))
+#ifdef USE_BOOST_IO
+ namespace io = boost::iostreams;
+ namespace io = boost::iostreams;
+ io::stream<io::file_sink>* source = dynamic_cast<io::stream<io::file_sink>*>(ofs);
+ if (source)
{
- static_cast<std::ofstream&>(*ofs).close();
+ source->close();
delete ofs;
}
+
+#else
+ std::ofstream* source = dynamic_cast<std::ofstream*>(ofs);
+ if (source)
+ {
+ source->close();
+ delete ofs;
+ }
+
+#endif
}
inline void Cleanup(std::istream* ifs)
@@ -178,11 +192,24 @@
// An ifstream is closeable and deletable, but
// an istream like &std::cin isn't.
if (!ifs) return;
- if (static_cast<std::ifstream&>(*ifs))
+#ifdef USE_BOOST_IO
+ namespace io = boost::iostreams;
+ io::stream<io::file_source>* source = dynamic_cast<io::stream<io::file_source>*>(ifs);
+ if (source)
{
- static_cast<std::ifstream&>(*ifs).close();
+ source->close();
delete ifs;
}
+#else
+ std::ifstream* source = dynamic_cast<std::ifstream*>(ifs);
+ if (source)
+ {
+ source->close();
+ delete ifs;
+ }
+
+
+#endif
}
class ReaderI
diff -r 12230c12cca9 -r d3de717cd0b7 src/detail/reader/reader.cpp
--- a/src/detail/reader/reader.cpp Tue Feb 01 13:40:39 2011 -0600
+++ b/src/detail/reader/reader.cpp Thu Feb 17 12:41:02 2011 -0600
@@ -172,7 +172,8 @@
} catch (std::runtime_error&)
{
// If the stream is no good anymore, we're done reading points
- return;
+ throw std::out_of_range("ReadNextPoint: file has no more points to read, end of file reached");
+
}
// Filter the points and continue reading until we either find
More information about the Liblas-commits
mailing list