From 6da9de573978d5a05b7048dbdc642a7a648d38bc Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Wed, 24 Aug 2016 11:15:32 +0000 Subject: [PATCH 1/3] fix closing segment --- .../renderer_common/process_building_symbolizer.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/mapnik/renderer_common/process_building_symbolizer.hpp b/include/mapnik/renderer_common/process_building_symbolizer.hpp index 6b0a94f79..a9c88436b 100644 --- a/include/mapnik/renderer_common/process_building_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_building_symbolizer.hpp @@ -41,6 +41,7 @@ void make_building(geometry::polygon const& poly, double height, F1 cons const std::unique_ptr frame(new path_type(path_type::types::LineString)); const std::unique_ptr roof(new path_type(path_type::types::Polygon)); std::deque face_segments; + double ring_begin_x, ring_begin_y; double x0 = 0; double y0 = 0; double x,y; @@ -52,15 +53,21 @@ void make_building(geometry::polygon const& poly, double height, F1 cons if (cm == SEG_MOVETO) { frame->move_to(x,y); + ring_begin_x = x; + ring_begin_y = y; } else if (cm == SEG_LINETO) { frame->line_to(x,y); - face_segments.push_back(segment_t(x0,y0,x,y)); + face_segments.emplace_back(x0,y0,x,y); } else if (cm == SEG_CLOSE) { frame->close_path(); + if (!face_segments.empty()) + { + face_segments.emplace_back(x0, y0, ring_begin_x, ring_begin_y); + } } x0 = x; y0 = y; From 8b18c605fd0337ebf7db879e7a68dffbc767b972 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Wed, 24 Aug 2016 11:30:21 +0000 Subject: [PATCH 2/3] no need for heap allocation --- .../process_building_symbolizer.hpp | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/include/mapnik/renderer_common/process_building_symbolizer.hpp b/include/mapnik/renderer_common/process_building_symbolizer.hpp index a9c88436b..d65df2544 100644 --- a/include/mapnik/renderer_common/process_building_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_building_symbolizer.hpp @@ -38,8 +38,8 @@ namespace detail { template void make_building(geometry::polygon const& poly, double height, F1 const& face_func, F2 const& frame_func, F3 const& roof_func) { - const std::unique_ptr frame(new path_type(path_type::types::LineString)); - const std::unique_ptr roof(new path_type(path_type::types::Polygon)); + path_type frame(path_type::types::LineString); + path_type roof(path_type::types::Polygon); std::deque face_segments; double ring_begin_x, ring_begin_y; double x0 = 0; @@ -52,18 +52,18 @@ void make_building(geometry::polygon const& poly, double height, F1 cons { if (cm == SEG_MOVETO) { - frame->move_to(x,y); + frame.move_to(x,y); ring_begin_x = x; ring_begin_y = y; } else if (cm == SEG_LINETO) { - frame->line_to(x,y); + frame.line_to(x,y); face_segments.emplace_back(x0,y0,x,y); } else if (cm == SEG_CLOSE) { - frame->close_path(); + frame.close_path(); if (!face_segments.empty()) { face_segments.emplace_back(x0, y0, ring_begin_x, ring_begin_y); @@ -76,16 +76,16 @@ void make_building(geometry::polygon const& poly, double height, F1 cons std::sort(face_segments.begin(),face_segments.end(), y_order); for (auto const& seg : face_segments) { - const std::unique_ptr faces(new path_type(path_type::types::Polygon)); - faces->move_to(std::get<0>(seg),std::get<1>(seg)); - faces->line_to(std::get<2>(seg),std::get<3>(seg)); - faces->line_to(std::get<2>(seg),std::get<3>(seg) + height); - faces->line_to(std::get<0>(seg),std::get<1>(seg) + height); + path_type faces(path_type::types::Polygon); + faces.move_to(std::get<0>(seg),std::get<1>(seg)); + faces.line_to(std::get<2>(seg),std::get<3>(seg)); + faces.line_to(std::get<2>(seg),std::get<3>(seg) + height); + faces.line_to(std::get<0>(seg),std::get<1>(seg) + height); - face_func(*faces); + face_func(faces); // - frame->move_to(std::get<0>(seg),std::get<1>(seg)); - frame->line_to(std::get<0>(seg),std::get<1>(seg)+height); + frame.move_to(std::get<0>(seg),std::get<1>(seg)); + frame.line_to(std::get<0>(seg),std::get<1>(seg)+height); } va.rewind(0); @@ -94,23 +94,23 @@ void make_building(geometry::polygon const& poly, double height, F1 cons { if (cm == SEG_MOVETO) { - frame->move_to(x,y+height); - roof->move_to(x,y+height); + frame.move_to(x,y+height); + roof.move_to(x,y+height); } else if (cm == SEG_LINETO) { - frame->line_to(x,y+height); - roof->line_to(x,y+height); + frame.line_to(x,y+height); + roof.line_to(x,y+height); } else if (cm == SEG_CLOSE) { - frame->close_path(); - roof->close_path(); + frame.close_path(); + roof.close_path(); } } - frame_func(*frame); - roof_func(*roof); + frame_func(frame); + roof_func(roof); } } // ns detail From 2f98b8965bab33a52fbb9c926bf248f3c78a20ee Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Thu, 25 Aug 2016 09:36:30 +0000 Subject: [PATCH 3/3] update visual tests data --- test/data-visual | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/data-visual b/test/data-visual index bb0a8927f..d7eacd7b2 160000 --- a/test/data-visual +++ b/test/data-visual @@ -1 +1 @@ -Subproject commit bb0a8927f4305df861d1b5c6366216bb4e530975 +Subproject commit d7eacd7b23cad68756f771fa9c65a47507ebe470