summaryrefslogtreecommitdiffstats
path: root/server/src/geo.cppm
diff options
context:
space:
mode:
authorRutger Broekhoff2026-08-28 22:17:10 +0200
committerRutger Broekhoff2026-08-28 22:17:10 +0200
commit70643a9e4821bd11c3f363f1708fe420965467d1 (patch)
tree65572b58e247248846628940a2aaca197a15d784 /server/src/geo.cppm
parent173cd34bdd0717d3f4beeac76b3296ecd46ada0d (diff)
downloadroutemon-70643a9e4821bd11c3f363f1708fe420965467d1.tar.gz
routemon-70643a9e4821bd11c3f363f1708fe420965467d1.zip
Format again
Diffstat (limited to 'server/src/geo.cppm')
-rw-r--r--server/src/geo.cppm34
1 files changed, 17 insertions, 17 deletions
diff --git a/server/src/geo.cppm b/server/src/geo.cppm
index b599ad4..9101af8 100644
--- a/server/src/geo.cppm
+++ b/server/src/geo.cppm
@@ -9,15 +9,15 @@ export namespace bgeo = boost::geometry;
9export namespace routemon::geo { 9export namespace routemon::geo {
10 10
11using point = 11using 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>>;
13using linestring = bgeo::model::linestring<point>; 13using linestring = bgeo::model::linestring<point>;
14using box = bgeo::model::box<point>; 14using box = bgeo::model::box<point>;
15using stype = bgeo::srs::spheroid<double>; 15using stype = bgeo::srs::spheroid<double>;
16using vincenty_strategy = bgeo::strategy::distance::vincenty<stype>; 16using vincenty_strategy = bgeo::strategy::distance::vincenty<stype>;
17 17
18auto split_linestring_with_overlap_segments( 18auto 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)
31 { 34 {
32 bgeo::append(current_ls, p); 35 auto d = bgeo::distance(*previous, p, vincenty_strategy());
33 if (previous) 36 current_ls_length += d;
37 if (current_ls_length > max_split_distance_m)
34 { 38 {
35 auto d = bgeo::distance(*previous, p, vincenty_strategy()); 39 append_to.push_back(std::move(current_ls));
36 current_ls_length += d; 40 current_ls = linestring{*previous, p};
37 if (current_ls_length > max_split_distance_m) 41 current_ls_length = d;
38 {
39 append_to.push_back(std::move(current_ls));
40 current_ls = linestring{*previous, p};
41 current_ls_length = d;
42 }
43 } 42 }
44 previous = p; 43 }
45 }); 44 previous = p;
45 });
46 append_to.emplace_back(std::move(current_ls)); 46 append_to.emplace_back(std::move(current_ls));
47} 47}
48 48