From 82ac4e0976a463215d2d4f99ebc8523bd2dc457e Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 1 Mar 2016 17:26:47 +0100 Subject: [PATCH] refactor apply_markers_multi and help compiler a bit more --- include/mapnik/marker_helpers.hpp | 75 ++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index f36bc70e4..38c1fe2e2 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -159,12 +159,10 @@ void setup_transform_scaling(agg::trans_affine & tr, symbolizer_base const& sym); // Apply markers to a feature with multiple geometries + template -void apply_markers_multi(feature_impl const& feature, attributes const& vars, Converter & converter, Processor & proc, symbolizer_base const& sym) +void apply_markers_single(Converter & converter, Processor & proc, geometry::geometry const& geom) { - using apply_vertex_converter_type = detail::apply_vertex_converter; - apply_vertex_converter_type apply(converter, proc); - auto const& geom = feature.get_geometry(); geometry::geometry_types type = geometry::geometry_type(geom); if (type == geometry::geometry_types::Point) @@ -182,6 +180,48 @@ void apply_markers_multi(feature_impl const& feature, attributes const& vars, Co geometry::polygon_vertex_adapter va(geom.get>()); converter.apply(va, proc); } + else if (type == geometry::geometry_types::MultiPoint) + { + for (auto const& pt : geom.get>()) + { + geometry::point_vertex_adapter va(pt); + converter.apply(va, proc); + } + } + else if (type == geometry::geometry_types::MultiLineString) + { + for (auto const& line : geom.get>()) + { + geometry::line_string_vertex_adapter va(line); + converter.apply(va, proc); + } + } + else if (type == geometry::geometry_types::MultiPolygon) + { + for (auto const& poly : geom.get>()) + { + geometry::polygon_vertex_adapter va(poly); + converter.apply(va, proc); + } + } +} + +template +void apply_markers_multi(feature_impl const& feature, attributes const& vars, Converter & converter, Processor & proc, symbolizer_base const& sym) +{ + using apply_vertex_converter_type = detail::apply_vertex_converter; + apply_vertex_converter_type apply(converter, proc); + auto const& geom = feature.get_geometry(); + geometry::geometry_types type = geometry::geometry_type(geom); + + if (type == geometry::geometry_types::Point + || + type == geometry::geometry_types::LineString + || + type == geometry::geometry_types::Polygon) + { + apply_markers_single(converter, proc, geom); + } else { @@ -238,33 +278,16 @@ void apply_markers_multi(feature_impl const& feature, attributes const& vars, Co { MAPNIK_LOG_WARN(marker_symbolizer) << "marker_multi_policy != 'each' has no effect with marker_placement != 'point'"; } - if (type == geometry::geometry_types::MultiPoint) + if (type == geometry::geometry_types::GeometryCollection) { - for (auto const& pt : geom.get>()) + for (auto const& g : geom.get>()) { - geometry::point_vertex_adapter va(pt); - converter.apply(va, proc); + apply_markers_single(converter, proc, g); } } - else if (type == geometry::geometry_types::MultiLineString) + else { - for (auto const& line : geom.get>()) - { - geometry::line_string_vertex_adapter va(line); - converter.apply(va, proc); - } - } - else if (type == geometry::geometry_types::MultiPolygon) - { - for (auto const& poly : geom.get>()) - { - geometry::polygon_vertex_adapter va(poly); - converter.apply(va, proc); - } - } - else if (type == geometry::geometry_types::GeometryCollection) - { - // no-op for GeometryCollection + apply_markers_single(converter, proc, geom); } } }