[Liblas-commits] hg: rework CreateWithHeader to use the
liblas::ReaderFactory
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Jan 14 09:26:05 EST 2011
details: http://hg.liblas.orghg/rev/5bdc71863dd0
changeset: 2764:5bdc71863dd0
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Jan 14 08:25:57 2011 -0600
description:
rework CreateWithHeader to use the liblas::ReaderFactory
diffstat:
src/c_api.cpp | 28 +++++++++++-----------------
1 files changed, 11 insertions(+), 17 deletions(-)
diffs (54 lines):
diff -r 3c789f598711 -r 5bdc71863dd0 src/c_api.cpp
--- a/src/c_api.cpp Thu Jan 13 19:24:49 2011 -0500
+++ b/src/c_api.cpp Fri Jan 14 08:25:57 2011 -0600
@@ -138,7 +138,7 @@
#ifdef _MSC_VER
# pragma warning(disable: 4127) // warning C4127: conditional expression is constant
-# pragma warning(disable: 4702) // unreachable code
+# pragma warning(disable: 4702) // unreachable code
#endif
#define VALIDATE_LAS_POINTER0(ptr, func) \
@@ -247,25 +247,19 @@
try {
- std::istream* istrm = OpenInput(std::string(filename));
+ liblas::ReaderFactory f;
+ std::istream* istrm = liblas::ReaderFactory::FileOpen(filename);
+ liblas::Reader* reader = new liblas::Reader(f.CreateWithStream(*istrm));
+ liblas::Header const& current_header = reader->GetHeader();
+
+ // If the original data were compressed, we need to override whatever value
+ // our incoming header has for that value
liblas::Header* header = ((liblas::Header*) hHeader);
- liblas::Reader* reader = NULL;
-
- if (header->Compressed())
+ if (current_header.Compressed())
{
-#ifdef HAVE_LASZIP
- ReaderIPtr r = ReaderIPtr(new liblas::detail::ZipReaderImpl(*istrm) );
- reader = new liblas::Reader(r);
-#else
- throw configuration_error("Compression support not enabled in liblas configuration");
-#endif
+ header->SetCompressed(true);
}
- else {
- ReaderIPtr r = ReaderIPtr(new liblas::detail::ReaderImpl(*istrm) );
- reader = new liblas::Reader(r);
- }
-
reader->SetHeader(*header);
readers.insert(std::pair<liblas::Reader*, std::istream*>(reader, istrm));
return (LASReaderH) reader;
@@ -2172,5 +2166,5 @@
#ifdef _MSC_VER
# pragma warning(default: 4127) // enable warning C4127: conditional expression is constant
-# pragma warning(default: 4702) // unreachable code
+# pragma warning(default: 4702) // unreachable code
#endif
More information about the Liblas-commits
mailing list