/
Utils.h
55 lines (49 loc) · 2.8 KB
/
Utils.h
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
#ifndef V2X_UTILS_H
#define V2X_UTILS_H
#include "MessageSink.h"
#include "asn_headers.h"
#include <set>
class Utils
{
private:
Utils();
public:
static bool is_ingress_lane(LaneDirection_t &dir);
static bool is_egress_lane(LaneDirection_t &dir);
static bool has_individual_vehicle_traffic(LaneSharing_t s);
static bool has_tracked_vehicle_traffic(LaneSharing_t s);
static bool has_bus_vehicle_traffic(LaneSharing_t s);
static bool has_taxi_vehicle_traffic(LaneSharing_t s);
static bool has_pedestrian_traffic(LaneSharing_t s);
static bool has_cyclist_traffic(LaneSharing_t s);
static bool maneuver_right_turn_on_red(AllowedManeuvers_t &m);
static MovementPhaseState_t get_movement_phase_for_signal_group(SPATEM_t *spatem, SignalGroupID_t &id);
static sf::Vector2f ortho(sf::Vector2f &a);
static sf::Vector2f ortho(sf::Vector2<int64_t> &a);
static sf::Vector2f normalize(sf::Vector2f &a);
static sf::Vector2f normalize(sf::Vector2<int64_t> &a);
static sf::Vector2f rotate(sf::Vector2f &a, float angle);
static float length(sf::Vector2f &a);
static float length(sf::Vector2<int64_t> &a);
static float timemark_to_seconds(TimeMark_t &t);
static sf::Vector2<int32_t> lat_lon_to_x_y(double lat, double lon, uint8_t zoom);
static void draw_arrow(sf::VertexArray *va, sf::Vector2f &start, sf::Vector2f &dir, sf::Vector2<int64_t> &ref, sf::Color color = sf::Color::White);
static void draw_arrow(sf::VertexArray *va, sf::Vector2f &start, sf::Vector2f &dir, sf::Color color = sf::Color::White);
static void bezier_to_va(const sf::Vector2f &start, const sf::Vector2f &end, const sf::Vector2f &startControl, const sf::Vector2f &endControl, const size_t numSegments, sf::VertexArray &va);
static void lat_lon_move(int64_t lat, int64_t lon, int64_t x_cm, int64_t y_cm, int64_t &out_lat, int64_t &out_lon);
static sf::Vector2f to_screen(sf::Vector2f &f);
static sf::Vector2f to_screen(sf::Vector2f &f, int64_t ox, int64_t oy);
static sf::Vector2f to_screen(sf::Vector2<int64_t> &i);
static sf::Vector2f to_screen(sf::Vector2<int64_t> &i, int64_t ox, int64_t oy);
static sf::Vector2f to_screen(int64_t ix, int64_t iy);
static sf::Vector2f to_screen(int64_t ix, int64_t iy, int64_t ox, int64_t oy);
static bool point_in_polygon(std::vector<sf::Vector2<int64_t>> &polygon, sf::Vector2<int64_t> &point);
static std::vector<sf::Vector2<int64_t>> convex_hull(std::vector<sf::Vector2<int64_t>> &set);
static std::vector<std::string> split(const std::string& s, char delimiter);
static std::string join(const std::vector<std::string> &v, char delimiter, size_t start);
};
sf::Vector2<int64_t> operator*(sf::Vector2<int64_t> v, float a);
sf::Vector2<int64_t> operator/(sf::Vector2<int64_t> v, float a);
sf::Vector2f operator+(sf::Vector2f a, sf::Vector2<int64_t> b);
sf::Vector2f operator+(sf::Vector2<int64_t> a, sf::Vector2f b);
#endif //V2X_UTILS_H