etsi_its_messages v3.4.0
Loading...
Searching...
No Matches
constants.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright Institute for Automotive Engineering (ika), RWTH Aachen University
3
8
9#pragma once
10
11#include <iostream>
12#include <map>
13
14namespace etsi_its_msgs {
15
16const uint64_t UNIX_SECONDS_2004 = 1072915200; // Unix-Seconds for 2004-01-01T00:00:00.000Z
17
22const std::map<uint64_t, uint16_t> LEAP_SECOND_INSERTIONS_SINCE_2004{
23 {UNIX_SECONDS_2004, 0}, // 2004-01-01T00:00:00.000Z
24 {1136073599, 1}, // 2005-12-31T23:59:59.000Z
25 {1230767999, 2}, // 2008-12-31T23:59:59.000Z
26 {1341100799, 3}, // 2012-06-30T23:59:59.000Z
27 {1435708799, 4}, // 2015-06-30T23:59:59.000Z
28 {1483228799, 5} // 2016-12-31T23:59:59.000Z
29};
30
37inline uint16_t getLeapSecondInsertionsSince2004(const uint64_t unix_seconds) {
38 // Check if the map is empty
39 if (LEAP_SECOND_INSERTIONS_SINCE_2004.empty()) return 0;
40 auto it = LEAP_SECOND_INSERTIONS_SINCE_2004.upper_bound(
41 unix_seconds); // Find the first element greater than givenUnixSecond
42 if (it == LEAP_SECOND_INSERTIONS_SINCE_2004.begin()) return 0;
43 --it; // Move iterator to the element with a key less than or equal to givenUnixSecond
44 return it->second; // Return the corresponding value
45}
46
47// An interval containing 95% of the points in a 1D Gaussian distribution
48constexpr const double ONE_D_GAUSSIAN_FACTOR = 2.0;
49
50// An ellipse containing 95% of the points in a 2D Gaussian distribution
51// has size 2.4477*sigma_{major/minor}
52constexpr const double TWO_D_GAUSSIAN_FACTOR = 2.4477;
53
54
55// Helper struct to get the value of ONE_CENTIMETER from a given type, if it exists
56// Otherwise, it defaults to 1
57template <typename SemiAxisLength, typename = std::void_t<>>
59 static constexpr int value = 1; // Default value
60};
61
62// Specialization for types that have ONE_CENTIMETER defined
63template <typename SemiAxisLength>
64struct OneCentimeterHelper<SemiAxisLength, std::void_t<decltype(SemiAxisLength::ONE_CENTIMETER)>> {
65 static constexpr int value = SemiAxisLength::ONE_CENTIMETER;
66};
67
68
69} // namespace etsi_its_msgs
uint16_t getLeapSecondInsertionsSince2004(const uint64_t unix_seconds)
Get the leap second insertions since 2004 for given unix seconds.
Definition constants.h:37
const std::map< uint64_t, uint16_t > LEAP_SECOND_INSERTIONS_SINCE_2004
std::map that stores all leap second insertions since 2004 with the corresponding unix-date of the in...
Definition constants.h:22