From 061b29f108b56a9042f21cc916b8e35091b84787 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Wed, 7 Jun 2017 14:03:09 -0500 Subject: [PATCH 1/2] Restoring the way filter factors operate so that select algorithms still are passed variables in the form of filter factor to change their operation. Added this operation to raster plugin where it never existed prior. Additionally added a test that was created for #3698 proving that it is not currently an issue --- plugins/input/gdal/gdal_featureset.cpp | 13 ++++++++----- plugins/input/raster/raster_featureset.cpp | 5 +++-- plugins/input/raster/raster_featureset.hpp | 1 + test/data-visual | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/plugins/input/gdal/gdal_featureset.cpp b/plugins/input/gdal/gdal_featureset.cpp index f71535fd6..8f755fdda 100644 --- a/plugins/input/gdal/gdal_featureset.cpp +++ b/plugins/input/gdal/gdal_featureset.cpp @@ -149,6 +149,9 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q) box2d intersect = raster_extent_.intersect(q.get_bbox()); box2d 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 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())); @@ -224,7 +227,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q) { throw datasource_exception(CPLGetLastErrorMsg()); } - mapnik::raster_ptr raster = std::make_shared(feature_raster_extent, intersect, image, 0.0); + mapnik::raster_ptr raster = std::make_shared(feature_raster_extent, intersect, image, filter_factor); // set nodata value to be used in raster colorizer if (nodata_value_) raster->set_nodata(*nodata_value_); else raster->set_nodata(raster_nodata); @@ -244,7 +247,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q) { throw datasource_exception(CPLGetLastErrorMsg()); } - mapnik::raster_ptr raster = std::make_shared(feature_raster_extent, intersect, image, 0.0); + mapnik::raster_ptr raster = std::make_shared(feature_raster_extent, intersect, image, filter_factor); // set nodata value to be used in raster colorizer if (nodata_value_) raster->set_nodata(*nodata_value_); else raster->set_nodata(raster_nodata); @@ -263,7 +266,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q) { throw datasource_exception(CPLGetLastErrorMsg()); } - mapnik::raster_ptr raster = std::make_shared(feature_raster_extent, intersect, image, 0.0); + mapnik::raster_ptr raster = std::make_shared(feature_raster_extent, intersect, image, filter_factor); // set nodata value to be used in raster colorizer if (nodata_value_) raster->set_nodata(*nodata_value_); else raster->set_nodata(raster_nodata); @@ -283,7 +286,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q) { throw datasource_exception(CPLGetLastErrorMsg()); } - mapnik::raster_ptr raster = std::make_shared(feature_raster_extent, intersect, image, 0.0); + mapnik::raster_ptr raster = std::make_shared(feature_raster_extent, intersect, image, filter_factor); // set nodata value to be used in raster colorizer if (nodata_value_) raster->set_nodata(*nodata_value_); 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(feature_raster_extent, intersect, image, 0.0); + mapnik::raster_ptr raster = std::make_shared(feature_raster_extent, intersect, image, filter_factor); // set nodata value to be used in raster colorizer if (nodata_value_) raster->set_nodata(*nodata_value_); else raster->set_nodata(raster_nodata); diff --git a/plugins/input/raster/raster_featureset.cpp b/plugins/input/raster/raster_featureset.cpp index 3e004c89a..adaf65526 100644 --- a/plugins/input/raster/raster_featureset.cpp +++ b/plugins/input/raster/raster_featureset.cpp @@ -55,7 +55,8 @@ raster_featureset::raster_featureset(LookupPolicy const& policy, extent_(extent), bbox_(q.get_bbox()), curIter_(policy_.begin()), - endIter_(policy_.end()) + endIter_(policy_.end()), + filter_factor_(q.get_filter_factor()) { } @@ -115,7 +116,7 @@ feature_ptr raster_featureset::next() rem.maxy() + y_off + height); feature_raster_extent = t.backward(feature_raster_extent); mapnik::image_any data = reader->read(x_off, y_off, width, height); - mapnik::raster_ptr raster = std::make_shared(feature_raster_extent, intersect, std::move(data), 1.0); + mapnik::raster_ptr raster = std::make_shared(feature_raster_extent, intersect, std::move(data), filter_factor_); feature->set_raster(raster); } } diff --git a/plugins/input/raster/raster_featureset.hpp b/plugins/input/raster/raster_featureset.hpp index 007689275..6daa89831 100644 --- a/plugins/input/raster/raster_featureset.hpp +++ b/plugins/input/raster/raster_featureset.hpp @@ -321,6 +321,7 @@ private: mapnik::box2d bbox_; iterator_type curIter_; iterator_type endIter_; + double filter_factor_; }; #endif // RASTER_FEATURESET_HPP diff --git a/test/data-visual b/test/data-visual index c7507c08a..35ebee7a6 160000 --- a/test/data-visual +++ b/test/data-visual @@ -1 +1 @@ -Subproject commit c7507c08a942fe9bffe5916510d3969f765f16c2 +Subproject commit 35ebee7a653a48ca33501636bcc1d10b7838d67f From af95ca85e98906b65e5de5728c310ddd9625a921 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Tue, 13 Jun 2017 07:47:23 -0500 Subject: [PATCH 2/2] Updated tests --- test/data-visual | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/data-visual b/test/data-visual index 35ebee7a6..dd0c6261a 160000 --- a/test/data-visual +++ b/test/data-visual @@ -1 +1 @@ -Subproject commit 35ebee7a653a48ca33501636bcc1d10b7838d67f +Subproject commit dd0c6261afb21d387df21890fd90f2915eea539d