From 3beba890f800c16e5601d2c6da578de8f4fce2f0 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 22 Jul 2013 13:25:04 -0400 Subject: [PATCH] make scale_factor accessible off renderers - no need to store as member of feature_style_processor --- include/mapnik/agg_renderer.hpp | 5 +++++ include/mapnik/cairo_renderer.hpp | 5 +++++ include/mapnik/feature_style_processor.hpp | 1 - include/mapnik/feature_style_processor_impl.hpp | 12 ++++-------- include/mapnik/grid/grid_renderer.hpp | 4 ++++ include/mapnik/svg/output/svg_renderer.hpp | 5 +++++ 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index 29db7e4fb..be248ea94 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -132,6 +132,11 @@ public: return DEFAULT; } + inline double scale_factor() const + { + return scale_factor_; + } + protected: template void debug_draw_box(R& buf, box2d const& extent, diff --git a/include/mapnik/cairo_renderer.hpp b/include/mapnik/cairo_renderer.hpp index 4f5dd9144..1a4bade72 100644 --- a/include/mapnik/cairo_renderer.hpp +++ b/include/mapnik/cairo_renderer.hpp @@ -129,6 +129,11 @@ public: return DEFAULT; } + inline double scale_factor() const + { + return scale_factor_; + } + void render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& mtx, diff --git a/include/mapnik/feature_style_processor.hpp b/include/mapnik/feature_style_processor.hpp index de7fe9fda..93a3114bb 100644 --- a/include/mapnik/feature_style_processor.hpp +++ b/include/mapnik/feature_style_processor.hpp @@ -92,7 +92,6 @@ private: proj_transform const& prj_trans); Map const& m_; - double scale_factor_; }; } diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index dd8a039d8..e2f62e1f6 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -41,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -134,11 +132,10 @@ struct has_process template feature_style_processor::feature_style_processor(Map const& m, double scale_factor) - : m_(m), - scale_factor_(scale_factor) + : m_(m) { // https://github.com/mapnik/mapnik/issues/1100 - if (scale_factor_ <= 0) + if (scale_factor <= 0) { throw std::runtime_error("scale_factor must be greater than 0.0"); } @@ -153,7 +150,7 @@ void feature_style_processor::apply(double scale_denom) projection proj(m_.srs(),true); if (scale_denom <= 0.0) scale_denom = mapnik::scale_denominator(m_.scale(),proj.is_geographic()); - scale_denom *= scale_factor_; + scale_denom *= p.scale_factor(); BOOST_FOREACH ( layer const& lyr, m_.layers() ) { @@ -188,7 +185,7 @@ void feature_style_processor::apply(mapnik::layer const& lyr, projection proj(m_.srs(),true); if (scale_denom <= 0.0) scale_denom = mapnik::scale_denominator(m_.scale(),proj.is_geographic()); - scale_denom *= scale_factor_; + scale_denom *= p.scale_factor(); if (lyr.visible(scale_denom)) { @@ -458,7 +455,6 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces boost::shared_ptr cache = boost::make_shared(); if (features) { - // Cache all features into the memory_datasource before rendering. feature_ptr feature; while ((feature = features->next())) { diff --git a/include/mapnik/grid/grid_renderer.hpp b/include/mapnik/grid/grid_renderer.hpp index e37d12bb8..f2b8e83b5 100644 --- a/include/mapnik/grid/grid_renderer.hpp +++ b/include/mapnik/grid/grid_renderer.hpp @@ -122,6 +122,10 @@ public: { return DEFAULT; } + inline double scale_factor() const + { + return scale_factor_; + } private: buffer_type & pixmap_; diff --git a/include/mapnik/svg/output/svg_renderer.hpp b/include/mapnik/svg/output/svg_renderer.hpp index c9bb8240c..f76e19072 100644 --- a/include/mapnik/svg/output/svg_renderer.hpp +++ b/include/mapnik/svg/output/svg_renderer.hpp @@ -137,6 +137,11 @@ public: return DEFAULT; } + inline double scale_factor() const + { + return scale_factor_; + } + inline OutputIterator& get_output_iterator() { return output_iterator_;