From 0c2558c154e2d21fc7800c24f1d95460af0bca5b Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 17 Mar 2016 14:19:29 +0100 Subject: [PATCH] topojson bounding_box - fix multi_point logic (remove bogus `if (num_arcs_ > 0)` condition) --- include/mapnik/json/topojson_utils.hpp | 36 ++++++++++++-------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/include/mapnik/json/topojson_utils.hpp b/include/mapnik/json/topojson_utils.hpp index be6a83a2c..b65a90cae 100644 --- a/include/mapnik/json/topojson_utils.hpp +++ b/include/mapnik/json/topojson_utils.hpp @@ -50,27 +50,25 @@ struct bounding_box_visitor box2d operator() (mapnik::topojson::multi_point const& multi_pt) const { box2d bbox; - if (num_arcs_ > 0) + bool first = true; + double px = 0, py = 0; + for (auto const& pt : multi_pt.points) { - bool first = true; - for (auto const& pt : multi_pt.points) + double x = pt.x; + double y = pt.y; + if (topo_.tr) { - double x = pt.x; - double y = pt.y; - if (topo_.tr) - { - x = x * (*topo_.tr).scale_x + (*topo_.tr).translate_x; - y = y * (*topo_.tr).scale_y + (*topo_.tr).translate_y; // TODO : delta encoded ? - } - if (first) - { - first = false; - bbox.init(x,y,x,y); - } - else - { - bbox.expand_to_include(x,y); - } + x = (px += x) * (*topo_.tr).scale_x + (*topo_.tr).translate_x; + y = (py += y) * (*topo_.tr).scale_y + (*topo_.tr).translate_y; + } + if (first) + { + first = false; + bbox.init(x,y,x,y); + } + else + { + bbox.expand_to_include(x,y); } } return bbox;