From b0edff4d118a14f35b83262cc7f872d4093fd3e6 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 7 Oct 2013 11:14:50 +0100 Subject: [PATCH] + skip repeated verticies --- plugins/input/topojson/topojson_featureset.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/input/topojson/topojson_featureset.cpp b/plugins/input/topojson/topojson_featureset.cpp index 28ddaab06..94bcd0cf4 100644 --- a/plugins/input/topojson/topojson_featureset.cpp +++ b/plugins/input/topojson/topojson_featureset.cpp @@ -31,7 +31,7 @@ #include #include #include - +#include #include "topojson_featureset.hpp" namespace mapnik { namespace topojson { @@ -195,6 +195,7 @@ struct feature_generator : public boost::static_visitor mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx_,feature_id_)); std::unique_ptr poly_ptr(new geometry_type(geometry_type::types::Polygon)); std::vector processed_coords; + for (auto const& ring : poly.rings) { bool first = true; @@ -213,14 +214,18 @@ struct feature_generator : public boost::static_visitor if (topo_.tr) { - x = (px += x) * (*topo_.tr).scale_x + (*topo_.tr).translate_x; - y = (py += y) * (*topo_.tr).scale_y + (*topo_.tr).translate_y; + transform const& tr = *topo_.tr; + x = (px += x) * tr.scale_x + tr.translate_x; + y = (py += y) * tr.scale_y + tr.translate_y; } processed_coords.emplace_back(coordinate{x,y}); } + + using namespace boost::adaptors; + if (reversed) { - for (auto const& c : boost::adaptors::reverse(processed_coords)) + for (auto const& c : reverse(processed_coords) | sliced(0,processed_coords.size()-1)) { if (first) { @@ -232,7 +237,7 @@ struct feature_generator : public boost::static_visitor } else { - for (auto const& c : processed_coords) + for (auto const& c : processed_coords | sliced(0,processed_coords.size()-1)) { if (first) {