etsi_its_messages
v3.5.0
Toggle main menu visibility
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
14
namespace
etsi_its_msgs {
15
16
const
uint64_t UNIX_SECONDS_2004 = 1072915200;
// Unix-Seconds for 2004-01-01T00:00:00.000Z
17
22
const
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
37
inline
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
48
constexpr
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}
52
constexpr
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
57
template
<
typename
SemiAxisLength,
typename
= std::
void
_t<>>
58
struct
OneCentimeterHelper
{
59
static
constexpr
int
value = 1;
// Default value
60
};
61
62
// Specialization for types that have ONE_CENTIMETER defined
63
template
<
typename
SemiAxisLength>
64
struct
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
etsi_its_msgs::getLeapSecondInsertionsSince2004
uint16_t getLeapSecondInsertionsSince2004(const uint64_t unix_seconds)
Get the leap second insertions since 2004 for given unix seconds.
Definition
constants.h:37
etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004
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
etsi_its_msgs::OneCentimeterHelper
Definition
constants.h:58
etsi_its_msgs_utils
include
etsi_its_msgs_utils
impl
constants.h
Generated by
1.17.0