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); } } }