1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
module;
#include <boost/geometry.hpp>
#include <boost/json.hpp>
export module routemon:api;
import std;
import :datex2;
import :geo.wgs84;
import :geo.multizonal;
import :gpx;
import :log;
import :time;
import :trace;
namespace {
namespace chrono = std::chrono;
namespace json = boost::json;
namespace views = std::views;
} // namespace
export namespace routemon::api {
struct relevant_road_closure
{
std::vector<geo::utm::zonable_wgs84_linestring> relevant_lss;
};
struct relevant_situation
{
std::string id;
std::optional<geo::utm::zonable_wgs84_point> location;
std::vector<std::string> comments;
std::vector<relevant_road_closure> relevant_road_closures;
};
struct track_segment
{
geo::utm::zonable_wgs84_linestring points;
};
struct track
{
std::vector<track_segment> segments;
};
struct process_gpx_result
{
std::vector<track> tracks;
std::vector<relevant_situation> relevant_situations;
};
struct sysinfo
{
time::timestamp using_publication_of;
std::size_t blse_index_size;
std::size_t p_index_size;
};
auto tag_invoke(
json::value_from_tag, json::value& jv, relevant_road_closure const& clo)
-> void;
auto tag_invoke(
json::value_from_tag, json::value& jv, relevant_situation const& sit)
-> void;
auto tag_invoke(json::value_from_tag, json::value& jv, track_segment const& seg)
-> void;
auto tag_invoke(json::value_from_tag, json::value& jv, track const& track)
-> void;
auto tag_invoke(
json::value_from_tag, json::value& jv, process_gpx_result const& res)
-> void;
auto tag_invoke(json::value_from_tag, json::value& jv, sysinfo const& info)
-> void;
class handler
{
constexpr static auto const min_distance_ = 5.0;
using blse_index_value = std::shared_ptr<datex2::road_closure>;
using blse_index = geo::multizonal::linestring_rtree<blse_index_value>;
using p_index_value = std::pair<
geo::utm::zonable_wgs84_point, std::shared_ptr<datex2::road_closure>
>;
using p_index = bgeo::index::rtree<p_index_value, bgeo::index::quadratic<16>>;
log::logger l_;
datex2::situation_publication pub_;
blse_index blse_index_;
p_index p_index_;
public:
explicit handler(log::logger const& l, datex2::situation_publication pub);
auto process_gpx(gpx::file&& gpx_file) -> std::optional<process_gpx_result>;
auto sysinfo() -> sysinfo;
};
} // namespace routemon::api
|