summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorRutger Broekhoff2026-08-30 15:29:41 +0200
committerRutger Broekhoff2026-08-30 15:29:41 +0200
commit15bcf23f2e75f9c710eee3753d530ebefc5f78f1 (patch)
treef5291f804d63662f536b7f8bf6d7e099c88d0754 /server/src
parent5abc825cdfaa16580dd05045cdf9847ecd3fcd60 (diff)
downloadroutemon-15bcf23f2e75f9c710eee3753d530ebefc5f78f1.tar.gz
routemon-15bcf23f2e75f9c710eee3753d530ebefc5f78f1.zip
Another (at this point perhaps needless) optimization attempt
Diffstat (limited to 'server/src')
-rw-r--r--server/src/api.cpp24
-rw-r--r--server/src/api.cppm10
2 files changed, 17 insertions, 17 deletions
diff --git a/server/src/api.cpp b/server/src/api.cpp
index 9953675..5dd3fc5 100644
--- a/server/src/api.cpp
+++ b/server/src/api.cpp
@@ -92,7 +92,7 @@ auto tag_invoke(json::value_from_tag, json::value& jv, sysinfo const& info)
92 jv = json::object{ 92 jv = json::object{
93 {"using_publication_of", 93 {"using_publication_of",
94 std::format("{:%FT%TZ}", info.using_publication_of)}, 94 std::format("{:%FT%TZ}", info.using_publication_of)},
95 {"lse_index_size", info.lse_index_size}, 95 {"blse_index_size", info.blse_index_size},
96 {"p_index_size", info.p_index_size}, 96 {"p_index_size", info.p_index_size},
97 }; 97 };
98} 98}
@@ -135,13 +135,13 @@ handler::handler(log::logger const& l, datex2::situation_publication pub)
135 { 135 {
136 for (auto const& ls : rc->relevant_line_strings) 136 for (auto const& ls : rc->relevant_line_strings)
137 { 137 {
138 auto box = geo::box{};
139 bgeo::envelope(*ls, box);
140 auto buffered_ls = geo::multi_polygon{}; 138 auto buffered_ls = geo::multi_polygon{};
141 bgeo::buffer( 139 bgeo::buffer(
142 *ls, buffered_ls, distance_strategy, side_strategy, join_strategy, 140 *ls, buffered_ls, distance_strategy, side_strategy, join_strategy,
143 end_strategy, circle_strategy); 141 end_strategy, circle_strategy);
144 lse_index_.insert(std::make_tuple(box, buffered_ls, rc)); 142 auto blse = geo::box{};
143 bgeo::envelope(buffered_ls, blse);
144 blse_index_.insert(std::make_tuple(blse, buffered_ls, rc));
145 } 145 }
146 for (auto p : rc->relevant_points) 146 for (auto p : rc->relevant_points)
147 { 147 {
@@ -161,7 +161,7 @@ handler::handler(log::logger const& l, datex2::situation_publication pub)
161 auto const after_build = chrono::steady_clock::now(); 161 auto const after_build = chrono::steady_clock::now();
162 auto const dur_build_s = chrono::duration<double>{after_build - before_build}; 162 auto const dur_build_s = chrono::duration<double>{after_build - before_build};
163 l_.info("Indices built in {}", dur_build_s); 163 l_.info("Indices built in {}", dur_build_s);
164 l_.info("LSE index size: {}", lse_index_.size()); 164 l_.info("BLSE index size: {}", blse_index_.size());
165 l_.info("Point index size: {}", p_index_.size()); 165 l_.info("Point index size: {}", p_index_.size());
166} 166}
167 167
@@ -200,19 +200,19 @@ auto handler::process_gpx(gpx::file&& gpx_file)
200 auto part_box = geo::box{}; 200 auto part_box = geo::box{};
201 bgeo::envelope(part, part_box); 201 bgeo::envelope(part, part_box);
202 202
203 for (auto it = lse_index_.qbegin(bgeo::index::intersects(part_box)); 203 for (auto it = blse_index_.qbegin(bgeo::index::intersects(part_box));
204 it != lse_index_.qend(); it++) 204 it != blse_index_.qend(); it++)
205 { 205 {
206 // Cannot use structured bindings here, as boost::geometry::get 206 // Cannot use structured bindings here, as boost::geometry::get
207 // interferes with ADL. It is a candidate as the namespace 207 // interferes with ADL. It is a candidate as the namespace
208 // boost::geometry is part of the associated namespace set, which 208 // boost::geometry is part of the associated namespace set, which
209 // happens because geo::linestring ≡ 209 // happens because geo::linestring ≡
210 // boost::geometry::model::linestring<geo::point> is part of the 210 // boost::geometry::model::linestring<geo::point> is part of the
211 // whole tuple type (lse_index_value) that is the value_type of the 211 // whole tuple type (blse_index_value) that is the value_type of the
212 // iterator. 212 // iterator.
213 213
214 // geo::box const& lse = std::get<0>(*it); 214 geo::box const& blse = std::get<0>(*it);
215 geo::multi_polygon const& buffered_ls = std::get<1>(*it); 215 geo::multi_polygon const& bls = std::get<1>(*it);
216 std::shared_ptr<datex2::road_closure> const& rc = std::get<2>(*it); 216 std::shared_ptr<datex2::road_closure> const& rc = std::get<2>(*it);
217 if (rc->validity 217 if (rc->validity
218 && rc->validity->intersect(check_periods).periods().empty()) 218 && rc->validity->intersect(check_periods).periods().empty())
@@ -221,7 +221,7 @@ auto handler::process_gpx(gpx::file&& gpx_file)
221 // auto small_parts = bgeo::model::multi_linestring<geo::linestring>{}; 221 // auto small_parts = bgeo::model::multi_linestring<geo::linestring>{};
222 // bgeo::intersection(part, lse, small_parts); 222 // bgeo::intersection(part, lse, small_parts);
223 223
224 if (bgeo::intersects(buffered_ls, part)) 224 if (bgeo::intersects(blse, part) && bgeo::intersects(bls, part))
225 relevant_road_closures.emplace(rc); 225 relevant_road_closures.emplace(rc);
226 226
227 // if (!bgeo::is_empty(small_parts)) 227 // if (!bgeo::is_empty(small_parts))
@@ -318,7 +318,7 @@ auto handler::sysinfo() -> struct sysinfo
318{ 318{
319 return { 319 return {
320 .using_publication_of = pub_.publication_time, 320 .using_publication_of = pub_.publication_time,
321 .lse_index_size = lse_index_.size(), 321 .blse_index_size = blse_index_.size(),
322 .p_index_size = p_index_.size(), 322 .p_index_size = p_index_.size(),
323 }; 323 };
324} 324}
diff --git a/server/src/api.cppm b/server/src/api.cppm
index 6f301c4..b0f3944 100644
--- a/server/src/api.cppm
+++ b/server/src/api.cppm
@@ -55,7 +55,7 @@ struct process_gpx_result
55struct sysinfo 55struct sysinfo
56{ 56{
57 time::timestamp using_publication_of; 57 time::timestamp using_publication_of;
58 std::size_t lse_index_size; 58 std::size_t blse_index_size;
59 std::size_t p_index_size; 59 std::size_t p_index_size;
60}; 60};
61 61
@@ -79,18 +79,18 @@ class handler
79{ 79{
80 constexpr static auto const min_distance_ = 5.0; 80 constexpr static auto const min_distance_ = 5.0;
81 81
82 using lse_index_value = std::tuple< 82 using blse_index_value = std::tuple<
83 geo::box, geo::multi_polygon, std::shared_ptr<datex2::road_closure> 83 geo::box, geo::multi_polygon, std::shared_ptr<datex2::road_closure>
84 >; 84 >;
85 using p_index_value = 85 using p_index_value =
86 std::pair<geo::point, std::shared_ptr<datex2::road_closure>>; 86 std::pair<geo::point, std::shared_ptr<datex2::road_closure>>;
87 using lse_index = 87 using blse_index =
88 bgeo::index::rtree<lse_index_value, bgeo::index::quadratic<16>>; 88 bgeo::index::rtree<blse_index_value, bgeo::index::quadratic<16>>;
89 using p_index = bgeo::index::rtree<p_index_value, bgeo::index::quadratic<16>>; 89 using p_index = bgeo::index::rtree<p_index_value, bgeo::index::quadratic<16>>;
90 90
91 log::logger l_; 91 log::logger l_;
92 datex2::situation_publication pub_; 92 datex2::situation_publication pub_;
93 lse_index lse_index_; 93 blse_index blse_index_;
94 p_index p_index_; 94 p_index p_index_;
95 95
96public: 96public: