Merge pull request #3699 from mapnik/fix_filter_factor

Restore Filter Factor in Image Scaling
This commit is contained in:
Blake Thompson 2017-06-13 08:21:33 -05:00 committed by GitHub
commit 2f8485ba89
4 changed files with 13 additions and 8 deletions

View file

@ -149,6 +149,9 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
box2d<double> intersect = raster_extent_.intersect(q.get_bbox()); box2d<double> intersect = raster_extent_.intersect(q.get_bbox());
box2d<double> box = t.forward(intersect); box2d<double> box = t.forward(intersect);
// get the filter factor if it is set
double filter_factor = q.get_filter_factor();
//size of resized output pixel in source image domain //size of resized output pixel in source image domain
double margin_x = 1.0 / (std::fabs(dx_) * std::get<0>(q.resolution())); double margin_x = 1.0 / (std::fabs(dx_) * std::get<0>(q.resolution()));
double margin_y = 1.0 / (std::fabs(dy_) * std::get<1>(q.resolution())); double margin_y = 1.0 / (std::fabs(dy_) * std::get<1>(q.resolution()));
@ -224,7 +227,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{ {
throw datasource_exception(CPLGetLastErrorMsg()); throw datasource_exception(CPLGetLastErrorMsg());
} }
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, 0.0); mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, filter_factor);
// set nodata value to be used in raster colorizer // set nodata value to be used in raster colorizer
if (nodata_value_) raster->set_nodata(*nodata_value_); if (nodata_value_) raster->set_nodata(*nodata_value_);
else raster->set_nodata(raster_nodata); else raster->set_nodata(raster_nodata);
@ -244,7 +247,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{ {
throw datasource_exception(CPLGetLastErrorMsg()); throw datasource_exception(CPLGetLastErrorMsg());
} }
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, 0.0); mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, filter_factor);
// set nodata value to be used in raster colorizer // set nodata value to be used in raster colorizer
if (nodata_value_) raster->set_nodata(*nodata_value_); if (nodata_value_) raster->set_nodata(*nodata_value_);
else raster->set_nodata(raster_nodata); else raster->set_nodata(raster_nodata);
@ -263,7 +266,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{ {
throw datasource_exception(CPLGetLastErrorMsg()); throw datasource_exception(CPLGetLastErrorMsg());
} }
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, 0.0); mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, filter_factor);
// set nodata value to be used in raster colorizer // set nodata value to be used in raster colorizer
if (nodata_value_) raster->set_nodata(*nodata_value_); if (nodata_value_) raster->set_nodata(*nodata_value_);
else raster->set_nodata(raster_nodata); else raster->set_nodata(raster_nodata);
@ -283,7 +286,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{ {
throw datasource_exception(CPLGetLastErrorMsg()); throw datasource_exception(CPLGetLastErrorMsg());
} }
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, 0.0); mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, filter_factor);
// set nodata value to be used in raster colorizer // set nodata value to be used in raster colorizer
if (nodata_value_) raster->set_nodata(*nodata_value_); if (nodata_value_) raster->set_nodata(*nodata_value_);
else raster->set_nodata(raster_nodata); else raster->set_nodata(raster_nodata);
@ -583,7 +586,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
} }
} }
} }
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, 0.0); mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, filter_factor);
// set nodata value to be used in raster colorizer // set nodata value to be used in raster colorizer
if (nodata_value_) raster->set_nodata(*nodata_value_); if (nodata_value_) raster->set_nodata(*nodata_value_);
else raster->set_nodata(raster_nodata); else raster->set_nodata(raster_nodata);

View file

@ -55,7 +55,8 @@ raster_featureset<LookupPolicy>::raster_featureset(LookupPolicy const& policy,
extent_(extent), extent_(extent),
bbox_(q.get_bbox()), bbox_(q.get_bbox()),
curIter_(policy_.begin()), curIter_(policy_.begin()),
endIter_(policy_.end()) endIter_(policy_.end()),
filter_factor_(q.get_filter_factor())
{ {
} }
@ -115,7 +116,7 @@ feature_ptr raster_featureset<LookupPolicy>::next()
rem.maxy() + y_off + height); rem.maxy() + y_off + height);
feature_raster_extent = t.backward(feature_raster_extent); feature_raster_extent = t.backward(feature_raster_extent);
mapnik::image_any data = reader->read(x_off, y_off, width, height); mapnik::image_any data = reader->read(x_off, y_off, width, height);
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, std::move(data), 1.0); mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, std::move(data), filter_factor_);
feature->set_raster(raster); feature->set_raster(raster);
} }
} }

View file

@ -321,6 +321,7 @@ private:
mapnik::box2d<double> bbox_; mapnik::box2d<double> bbox_;
iterator_type curIter_; iterator_type curIter_;
iterator_type endIter_; iterator_type endIter_;
double filter_factor_;
}; };
#endif // RASTER_FEATURESET_HPP #endif // RASTER_FEATURESET_HPP

@ -1 +1 @@
Subproject commit c7507c08a942fe9bffe5916510d3969f765f16c2 Subproject commit dd0c6261afb21d387df21890fd90f2915eea539d