diff options
Diffstat (limited to 'server/src/geo.cppm')
| -rw-r--r-- | server/src/geo.cppm | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/server/src/geo.cppm b/server/src/geo.cppm index 9101af8..b599ad4 100644 --- a/server/src/geo.cppm +++ b/server/src/geo.cppm | |||
| @@ -9,15 +9,15 @@ export namespace bgeo = boost::geometry; | |||
| 9 | export namespace routemon::geo { | 9 | export namespace routemon::geo { |
| 10 | 10 | ||
| 11 | using point = | 11 | using point = |
| 12 | bgeo::model::point<double, 2, bgeo::cs::spherical_equatorial<bgeo::degree>>; | 12 | bgeo::model::point<double, 2, bgeo::cs::spherical_equatorial<bgeo::degree>>; |
| 13 | using linestring = bgeo::model::linestring<point>; | 13 | using linestring = bgeo::model::linestring<point>; |
| 14 | using box = bgeo::model::box<point>; | 14 | using box = bgeo::model::box<point>; |
| 15 | using stype = bgeo::srs::spheroid<double>; | 15 | using stype = bgeo::srs::spheroid<double>; |
| 16 | using vincenty_strategy = bgeo::strategy::distance::vincenty<stype>; | 16 | 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 | { | 21 | { |
| 22 | if (bgeo::is_empty(ls)) | 22 | if (bgeo::is_empty(ls)) |
| 23 | return; | 23 | return; |
| @@ -26,23 +26,23 @@ auto split_linestring_with_overlap_segments( | |||
| 26 | auto current_ls_length = 0.0; | 26 | auto current_ls_length = 0.0; |
| 27 | auto previous = std::optional<point>{}; | 27 | auto previous = std::optional<point>{}; |
| 28 | bgeo::for_each_point( | 28 | bgeo::for_each_point( |
| 29 | ls, | 29 | ls, |
| 30 | [&](point p) -> void | 30 | [&](point p) -> void |
| 31 | { | ||
| 32 | bgeo::append(current_ls, p); | ||
| 33 | if (previous) | ||
| 34 | { | 31 | { |
| 35 | auto d = bgeo::distance(*previous, p, vincenty_strategy()); | 32 | bgeo::append(current_ls, p); |
| 36 | current_ls_length += d; | 33 | if (previous) |
| 37 | if (current_ls_length > max_split_distance_m) | ||
| 38 | { | 34 | { |
| 39 | append_to.push_back(std::move(current_ls)); | 35 | auto d = bgeo::distance(*previous, p, vincenty_strategy()); |
| 40 | current_ls = linestring{*previous, p}; | 36 | current_ls_length += d; |
| 41 | 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 | } | ||
| 42 | } | 43 | } |
| 43 | } | 44 | previous = p; |
| 44 | previous = p; | 45 | }); |
| 45 | }); | ||
| 46 | append_to.emplace_back(std::move(current_ls)); | 46 | append_to.emplace_back(std::move(current_ls)); |
| 47 | } | 47 | } |
| 48 | 48 | ||