Merge branch 'master' of github.com:mapnik/mapnik

This commit is contained in:
Dane Springmeyer 2012-09-25 14:33:54 -07:00
commit d6821e8ce9
3 changed files with 33 additions and 23 deletions

View file

@ -121,7 +121,7 @@ void gdal_datasource::bind() const
double tr[6];
bool bbox_override = false;
boost::optional<std::string> bbox_s = params_.get<std::string>("bbox");
boost::optional<std::string> bbox_s = params_.get<std::string>("extent");
if (bbox_s)
{
MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: BBox Parameter=" << *bbox_s;

View file

@ -45,7 +45,7 @@ using mapnik::image_reader;
DATASOURCE_PLUGIN(raster_datasource)
raster_datasource::raster_datasource(const parameters& params, bool bind)
raster_datasource::raster_datasource(parameters const& params, bool bind)
: datasource(params),
desc_(*params.get<std::string>("type"), "utf-8"),
extent_initialized_(false)
@ -62,8 +62,8 @@ raster_datasource::raster_datasource(const parameters& params, bool bind)
filename_ = *file;
multi_tiles_ = *params_.get<bool>("multi", false);
tile_size_ = *params_.get<unsigned>("tile_size", 256);
tile_stride_ = *params_.get<unsigned>("tile_stride", 1);
tile_size_ = *params_.get<unsigned>("tile-size", 256);
tile_stride_ = *params_.get<unsigned>("tile-stride", 1);
format_ = *params_.get<std::string>("format","tiff");
@ -100,8 +100,8 @@ void raster_datasource::bind() const
if (multi_tiles_)
{
boost::optional<unsigned> x_width = params_.get<unsigned>("x_width");
boost::optional<unsigned> y_width = params_.get<unsigned>("y_width");
boost::optional<unsigned> x_width = params_.get<unsigned>("x-width");
boost::optional<unsigned> y_width = params_.get<unsigned>("y-width");
if (! x_width)
{
@ -201,11 +201,11 @@ featureset_ptr raster_datasource::features(query const& q) const
return boost::make_shared<raster_featureset<tiled_multi_file_policy> >(policy, extent_, q);
}
else if (width * height > 512*512)
else if (width * height > (tile_size_ * tile_size_ << 2))
{
MAPNIK_LOG_DEBUG(raster) << "raster_datasource: Tiled policy";
tiled_file_policy policy(filename_, format_, 256, extent_, q.get_bbox(), width_, height_);
tiled_file_policy policy(filename_, format_, tile_size_, extent_, q.get_bbox(), width_, height_);
return boost::make_shared<raster_featureset<tiled_file_policy> >(policy, extent_, q);
}

View file

@ -23,6 +23,8 @@
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/image_reader.hpp>
// boost
#include <boost/shared_ptr.hpp>
#include <boost/filesystem/operations.hpp>
// stl
@ -41,6 +43,18 @@ using std::max;
class tiff_reader : public image_reader
{
typedef boost::shared_ptr<TIFF> tiff_ptr;
struct tiff_closer
{
void operator() (TIFF * tif)
{
if (tif != 0)
{
TIFFClose(tif);
}
}
};
private:
std::string file_name_;
int read_method_;
@ -49,6 +63,8 @@ private:
int rows_per_strip_;
int tile_width_;
int tile_height_;
tiff_ptr tif_;
public:
enum TiffType {
generic=1,
@ -116,11 +132,9 @@ void tiff_reader::init()
{
read_method_=stripped;
}
TIFFClose(tif);
}
else
{
TIFFClose(tif);
throw image_reader_exception(msg);
}
}
@ -128,7 +142,6 @@ void tiff_reader::init()
tiff_reader::~tiff_reader()
{
//
}
@ -167,8 +180,6 @@ void tiff_reader::read_generic(unsigned /*x*/,unsigned /*y*/,image_data_32& /*im
if (tif)
{
MAPNIK_LOG_DEBUG(tiff_reader) << "tiff_reader: TODO - tiff is not stripped or tiled";
TIFFClose(tif);
}
}
@ -213,7 +224,6 @@ void tiff_reader::read_tiled(unsigned x0,unsigned y0,image_data_32& image)
}
}
_TIFFfree(buf);
TIFFClose(tif);
}
}
@ -254,21 +264,21 @@ void tiff_reader::read_stripped(unsigned x0,unsigned y0,image_data_32& image)
}
}
_TIFFfree(buf);
TIFFClose(tif);
}
}
TIFF* tiff_reader::load_if_exists(std::string const& filename)
{
TIFF * tif = 0;
boost::filesystem::path path(file_name_);
if (exists(path)) // && is_regular(path)) { -- not supported in boost-1.33.*
if (!tif_)
{
// File path is a full file path and does exist
tif = TIFFOpen(filename.c_str(), "rb");
boost::filesystem::path path(file_name_);
if (boost::filesystem::is_regular(path)) // exists and regular file
{
// File path is a full file path and does exist
tif_ = tiff_ptr(TIFFOpen(filename.c_str(), "rb"), tiff_closer());
}
}
return tif;
}
return tif_.get();
}
} // namespace mapnik