diff --git a/src/tiff_reader.cpp b/src/tiff_reader.cpp index b07004865..e34c536e9 100644 --- a/src/tiff_reader.cpp +++ b/src/tiff_reader.cpp @@ -113,11 +113,13 @@ struct tiff_io_traits using input_stream_type = std::istream; }; +#if defined(MAPNIK_MEMORY_MAPPED_FILE) template <> struct tiff_io_traits { using input_stream_type = boost::interprocess::ibufferstream; }; +#endif } template @@ -208,8 +210,11 @@ namespace image_reader* create_tiff_reader(std::string const& filename) { - //return new tiff_reader(filename); +#if defined(MAPNIK_MEMORY_MAPPED_FILE) return new tiff_reader(filename); +#else + return new tiff_reader(filename); +#endif } image_reader* create_tiff_reader2(char const * data, std::size_t size) @@ -224,23 +229,29 @@ const bool registered2 = register_image_reader("tiff", create_tiff_reader2); template tiff_reader::tiff_reader(std::string const& filename) - : source_(), - stream_(),//&source_), - tif_(nullptr), - read_method_(generic), - rows_per_strip_(0), - tile_width_(0), - tile_height_(0), - width_(0), - height_(0), - bps_(0), - sample_format_(SAMPLEFORMAT_UINT), - photometric_(0), - bands_(1), - planar_config_(PLANARCONFIG_CONTIG), - compression_(COMPRESSION_NONE), - has_alpha_(false), - is_tiled_(false) + : +#if defined(MAPNIK_MEMORY_MAPPED_FILE) + stream_(), +#else + source_(), + stream_(&source_), +#endif + + tif_(nullptr), + read_method_(generic), + rows_per_strip_(0), + tile_width_(0), + tile_height_(0), + width_(0), + height_(0), + bps_(0), + sample_format_(SAMPLEFORMAT_UINT), + photometric_(0), + bands_(1), + planar_config_(PLANARCONFIG_CONTIG), + compression_(COMPRESSION_NONE), + has_alpha_(false), + is_tiled_(false) { #if defined(MAPNIK_MEMORY_MAPPED_FILE) diff --git a/test/unit/imaging/tiff_io.cpp b/test/unit/imaging/tiff_io.cpp index a92b0e322..4145285fa 100644 --- a/test/unit/imaging/tiff_io.cpp +++ b/test/unit/imaging/tiff_io.cpp @@ -14,8 +14,14 @@ #include #include "../../../src/tiff_reader.cpp" +#if defined(MAPNIK_MEMORY_MAPPED_FILE) +using source_type = boost::interprocess::ibufferstream; +#else +using source_type = std::filebuf; +#endif + #define TIFF_ASSERT(filename) \ - mapnik::tiff_reader tiff_reader(filename); \ + mapnik::tiff_reader tiff_reader(filename); \ REQUIRE( tiff_reader.width() == 256 ); \ REQUIRE( tiff_reader.height() == 256 ); \ REQUIRE( tiff_reader.planar_config() == PLANARCONFIG_CONTIG ); \ @@ -141,7 +147,7 @@ void test_tiff_reader(std::string const& pattern) if (boost::iends_with(path,".tif") && boost::istarts_with(mapnik::util::basename(path), pattern)) { - mapnik::tiff_reader< boost::interprocess::ibufferstream> tiff_reader(path); + mapnik::tiff_reader tiff_reader(path); auto width = tiff_reader.width(); auto height = tiff_reader.height(); { @@ -180,7 +186,7 @@ TEST_CASE("tiff io") SECTION("scan rgb8 striped") { std::string filename("./test/data/tiff/scan_512x512_rgb8_striped.tif"); - mapnik::tiff_reader< boost::interprocess::ibufferstream> tiff_reader(filename); + mapnik::tiff_reader tiff_reader(filename); REQUIRE( tiff_reader.width() == 512 ); REQUIRE( tiff_reader.height() == 512 ); REQUIRE( tiff_reader.planar_config() == PLANARCONFIG_CONTIG ); @@ -210,7 +216,7 @@ TEST_CASE("tiff io") SECTION("scan rgb8 tiled") { std::string filename("./test/data/tiff/scan_512x512_rgb8_tiled.tif"); - mapnik::tiff_reader< boost::interprocess::ibufferstream> tiff_reader(filename); + mapnik::tiff_reader tiff_reader(filename); REQUIRE( tiff_reader.width() == 512 ); REQUIRE( tiff_reader.height() == 512 ); REQUIRE( tiff_reader.planar_config() == PLANARCONFIG_CONTIG );