Skip to content

Commit

Permalink
Add last point to linestring to make it closed
Browse files Browse the repository at this point in the history
  • Loading branch information
casperlamboo committed Jan 18, 2024
1 parent 88654f8 commit 69c25a3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils/polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <range/v3/view/sliding.hpp>
#include <range/v3/view/transform.hpp>
#include <range/v3/view/zip.hpp>
#include <range/v3/view/concat.hpp>
#include <range/v3/view/take.hpp>
#include <spdlog/spdlog.h>

#include "utils/ListPolyIt.h"
Expand Down Expand Up @@ -845,14 +847,14 @@ Polygons Polygons::toPolygons(ClipperLib::PolyTree& poly_tree)
| ranges::views::transform(
[](const auto& path)
{
const auto path_str = path
const auto line_string = ranges::views::concat(path, path | ranges::views::take(1))
| ranges::views::transform(
[](const auto& point)
{
return fmt::format("{} {}", point.X, point.Y);
})
| ranges::views::join(ranges::views::c_str(", ")) | ranges::to<std::string>();
return "(" + path_str + ")";
return "(" + line_string + ")";
})
| ranges::views::join(ranges::views::c_str(", ")) | ranges::to<std::string>();
stream << paths_str;
Expand Down

0 comments on commit 69c25a3

Please sign in to comment.