module; #include module routemon:geo$impl; import :geo; namespace routemon::geo { auto split_linestring_with_overlap_segments( linestring const& ls, double max_split_distance_m, std::vector& append_to) -> void { if (bgeo::is_empty(ls)) return; auto current_ls = linestring{}; auto current_ls_length = 0.0; auto previous = std::optional{}; bgeo::for_each_point( ls, [&](point p) -> void { bgeo::append(current_ls, p); if (previous) { auto d = bgeo::distance(*previous, p, vincenty_strategy()); current_ls_length += d; if (current_ls_length > max_split_distance_m) { append_to.push_back(std::move(current_ls)); current_ls = linestring{*previous, p}; current_ls_length = d; } } previous = p; }); append_to.emplace_back(std::move(current_ls)); } } // namespace routemon::geo