diff options
Diffstat (limited to 'server/src/geo.cppm')
| -rw-r--r-- | server/src/geo.cppm | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/server/src/geo.cppm b/server/src/geo.cppm index b599ad4..4f8b840 100644 --- a/server/src/geo.cppm +++ b/server/src/geo.cppm | |||
| @@ -17,33 +17,6 @@ using vincenty_strategy = bgeo::strategy::distance::vincenty<stype>; | |||
| 17 | 17 | ||
| 18 | auto split_linestring_with_overlap_segments( | 18 | auto split_linestring_with_overlap_segments( |
| 19 | linestring const& ls, double max_split_distance_m, | 19 | linestring const& ls, double max_split_distance_m, |
| 20 | std::vector<linestring>& append_to) -> void | 20 | std::vector<linestring>& append_to) -> void; |
| 21 | { | ||
| 22 | if (bgeo::is_empty(ls)) | ||
| 23 | return; | ||
| 24 | |||
| 25 | auto current_ls = linestring{}; | ||
| 26 | auto current_ls_length = 0.0; | ||
| 27 | auto previous = std::optional<point>{}; | ||
| 28 | bgeo::for_each_point( | ||
| 29 | ls, | ||
| 30 | [&](point p) -> void | ||
| 31 | { | ||
| 32 | bgeo::append(current_ls, p); | ||
| 33 | if (previous) | ||
| 34 | { | ||
| 35 | auto d = bgeo::distance(*previous, p, vincenty_strategy()); | ||
| 36 | current_ls_length += d; | ||
| 37 | if (current_ls_length > max_split_distance_m) | ||
| 38 | { | ||
| 39 | append_to.push_back(std::move(current_ls)); | ||
| 40 | current_ls = linestring{*previous, p}; | ||
| 41 | current_ls_length = d; | ||
| 42 | } | ||
| 43 | } | ||
| 44 | previous = p; | ||
| 45 | }); | ||
| 46 | append_to.emplace_back(std::move(current_ls)); | ||
| 47 | } | ||
| 48 | 21 | ||
| 49 | } // namespace routemon::geo | 22 | } // namespace routemon::geo |