Updated to use max_image_area as a datasource parameter for GDAL plugin
This commit is contained in:
parent
25e4bb3f6c
commit
a217b38fd5
6 changed files with 23 additions and 14 deletions
|
@ -84,6 +84,13 @@ gdal_datasource::gdal_datasource(parameters const& params)
|
||||||
|
|
||||||
shared_dataset_ = *params.get<mapnik::boolean_type>("shared", false);
|
shared_dataset_ = *params.get<mapnik::boolean_type>("shared", false);
|
||||||
band_ = *params.get<mapnik::value_integer>("band", -1);
|
band_ = *params.get<mapnik::value_integer>("band", -1);
|
||||||
|
|
||||||
|
// Maximum memory limitation for image will be simply based on the maximum
|
||||||
|
// area we allow for an image. The true memory footprint therefore will vary based
|
||||||
|
// on the type of imagery that exists. This is not the maximum size of an image
|
||||||
|
// on disk but rather the maximum size we will load into mapnik from GDAL.
|
||||||
|
// max_im_area based on 50 mb limit for RGBA
|
||||||
|
max_image_area_ = *params.get<mapnik::value_integer>("max_image_area", (50*1024*1024) / 4);
|
||||||
|
|
||||||
#if GDAL_VERSION_NUM >= 1600
|
#if GDAL_VERSION_NUM >= 1600
|
||||||
if (shared_dataset_)
|
if (shared_dataset_)
|
||||||
|
@ -237,7 +244,8 @@ featureset_ptr gdal_datasource::features(query const& q) const
|
||||||
dx_,
|
dx_,
|
||||||
dy_,
|
dy_,
|
||||||
nodata_value_,
|
nodata_value_,
|
||||||
nodata_tolerance_);
|
nodata_tolerance_,
|
||||||
|
max_image_area_);
|
||||||
}
|
}
|
||||||
|
|
||||||
featureset_ptr gdal_datasource::features_at_point(coord2d const& pt, double tol) const
|
featureset_ptr gdal_datasource::features_at_point(coord2d const& pt, double tol) const
|
||||||
|
@ -256,5 +264,6 @@ featureset_ptr gdal_datasource::features_at_point(coord2d const& pt, double tol)
|
||||||
dx_,
|
dx_,
|
||||||
dy_,
|
dy_,
|
||||||
nodata_value_,
|
nodata_value_,
|
||||||
nodata_tolerance_);
|
nodata_tolerance_,
|
||||||
|
max_image_area_);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ private:
|
||||||
bool shared_dataset_;
|
bool shared_dataset_;
|
||||||
boost::optional<double> nodata_value_;
|
boost::optional<double> nodata_value_;
|
||||||
double nodata_tolerance_;
|
double nodata_tolerance_;
|
||||||
|
int64_t max_image_area_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GDAL_DATASOURCE_HPP
|
#endif // GDAL_DATASOURCE_HPP
|
||||||
|
|
|
@ -89,7 +89,8 @@ gdal_featureset::gdal_featureset(GDALDataset& dataset,
|
||||||
double dx,
|
double dx,
|
||||||
double dy,
|
double dy,
|
||||||
boost::optional<double> const& nodata,
|
boost::optional<double> const& nodata,
|
||||||
double nodata_tolerance)
|
double nodata_tolerance,
|
||||||
|
int64_t max_image_area)
|
||||||
: dataset_(dataset),
|
: dataset_(dataset),
|
||||||
ctx_(std::make_shared<mapnik::context_type>()),
|
ctx_(std::make_shared<mapnik::context_type>()),
|
||||||
band_(band),
|
band_(band),
|
||||||
|
@ -102,6 +103,7 @@ gdal_featureset::gdal_featureset(GDALDataset& dataset,
|
||||||
nbands_(nbands),
|
nbands_(nbands),
|
||||||
nodata_value_(nodata),
|
nodata_value_(nodata),
|
||||||
nodata_tolerance_(nodata_tolerance),
|
nodata_tolerance_(nodata_tolerance),
|
||||||
|
max_image_area_(max_image_area),
|
||||||
first_(true)
|
first_(true)
|
||||||
{
|
{
|
||||||
ctx_->push("nodata");
|
ctx_->push("nodata");
|
||||||
|
@ -278,16 +280,11 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maximum memory limitation for image will be simply based on the maximum
|
|
||||||
// area we allow for an image. The true memory footprint therefore will vary based
|
|
||||||
// on the type of imagery that exists.
|
|
||||||
// max_im_area based on 50 mb limit for RGBA
|
|
||||||
constexpr int64_t max_im_area = (50*1024*1024) / 4;
|
|
||||||
int64_t im_area = (int64_t)im_width * (int64_t)im_height;
|
int64_t im_area = (int64_t)im_width * (int64_t)im_height;
|
||||||
if (im_area > max_im_area)
|
if (im_area > max_image_area_)
|
||||||
{
|
{
|
||||||
int adjusted_width = static_cast<int>(std::round(std::sqrt(max_im_area * ((double)im_width / (double)im_height))));
|
int adjusted_width = static_cast<int>(std::round(std::sqrt(max_image_area_ * ((double)im_width / (double)im_height))));
|
||||||
int adjusted_height = static_cast<int>(std::round(std::sqrt(max_im_area * ((double)im_height / (double)im_width))));
|
int adjusted_height = static_cast<int>(std::round(std::sqrt(max_image_area_ * ((double)im_height / (double)im_width))));
|
||||||
if (adjusted_width < 1)
|
if (adjusted_width < 1)
|
||||||
{
|
{
|
||||||
adjusted_width = 1;
|
adjusted_width = 1;
|
||||||
|
|
|
@ -66,7 +66,8 @@ public:
|
||||||
double dx,
|
double dx,
|
||||||
double dy,
|
double dy,
|
||||||
boost::optional<double> const& nodata,
|
boost::optional<double> const& nodata,
|
||||||
double nodata_tolerance);
|
double nodata_tolerance,
|
||||||
|
int64_t max_image_area);
|
||||||
virtual ~gdal_featureset();
|
virtual ~gdal_featureset();
|
||||||
mapnik::feature_ptr next();
|
mapnik::feature_ptr next();
|
||||||
|
|
||||||
|
@ -85,6 +86,7 @@ private:
|
||||||
int nbands_;
|
int nbands_;
|
||||||
boost::optional<double> nodata_value_;
|
boost::optional<double> nodata_value_;
|
||||||
double nodata_tolerance_;
|
double nodata_tolerance_;
|
||||||
|
int64_t max_image_area_;
|
||||||
bool first_;
|
bool first_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3a636431ab189285378686c596be16a440c0808f
|
Subproject commit a44457cc063249e0d204cde7249d37706bf8844c
|
|
@ -1 +1 @@
|
||||||
Subproject commit a6ec8c0919eda8ac2f34ede5c4a53240d0bb275a
|
Subproject commit c113ce13267124332cc2ecd049d7d2d7397f9a51
|
Loading…
Add table
Reference in a new issue