From 5da0f6494968b573d01293b1e4924b3c4c9d7384 Mon Sep 17 00:00:00 2001
From: Tobias Schmidt <tobias.schmidt@unibas.ch>
Date: Thu, 26 Jan 2012 12:32:12 +0100
Subject: [PATCH] DX handler can now read gzipped files

---
 modules/io/src/img/map_io_dx_handler.cc | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/modules/io/src/img/map_io_dx_handler.cc b/modules/io/src/img/map_io_dx_handler.cc
index 70303c97a..e25e95ab0 100644
--- a/modules/io/src/img/map_io_dx_handler.cc
+++ b/modules/io/src/img/map_io_dx_handler.cc
@@ -24,6 +24,8 @@
 #include <sstream>
 
 #include <ost/log.hh>
+#include <boost/iostreams/filter/gzip.hpp>
+#include <boost/iostreams/filtering_stream.hpp>
 #include <boost/filesystem/fstream.hpp>
 #include <boost/filesystem/convenience.hpp>
 #include <boost/lexical_cast.hpp>
@@ -68,8 +70,12 @@ void MapIODxHandler::Import(img::MapHandle& mh, const bf::path& loc,const ImageF
   {
     throw IOException("could not open "+loc.string());
   }
-
-  this->Import(mh,infile,form);
+  boost::iostreams::filtering_stream<boost::iostreams::input> in;
+  if (boost::iequals(".gz", boost::filesystem::extension(loc))) {
+    in.push(boost::iostreams::gzip_decompressor());
+  }
+  in.push(infile);
+  this->Import(mh,in,form);
   infile.close();
 }
 
@@ -266,10 +272,10 @@ bool MapIODxHandler::MatchType(const ImageFormatBase& formatstruct)
 }
 bool MapIODxHandler::MatchSuffix(const String& loc)
 {
-	if(detail::FilenameEndsWith(loc,".dx") ) {
-      return true;
-    }
-    return false;
+	if(detail::FilenameEndsWith(loc,".dx") || detail::FilenameEndsWith(loc,".dx.gz")) {
+    return true;
+  }
+  return false;
 }
 
 }} // ns
-- 
GitLab