mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-21 13:53:37 +00:00
# Conflicts: # CMakeLists.txt # android/app/src/main/java/app/organicmaps/settings/SettingsPrefsFragment.java # android/sdk/src/main/cpp/app/organicmaps/sdk/Framework.hpp # android/sdk/src/main/cpp/app/organicmaps/sdk/OrganicMaps.cpp # android/sdk/src/main/cpp/app/organicmaps/sdk/util/Config.cpp # libs/indexer/data_source.hpp # libs/indexer/feature.hpp # libs/indexer/ftypes_matcher.hpp # libs/map/framework.cpp # libs/map/traffic_manager.cpp # libs/routing/absent_regions_finder.cpp # libs/routing/edge_estimator.hpp # libs/routing/index_router.cpp # libs/routing/index_router.hpp # libs/routing/routing_session.hpp # libs/routing_common/num_mwm_id.hpp # libs/traffic/traffic_info.cpp # qt/mainwindow.hpp # qt/preferences_dialog.cpp # tools/openlr/helpers.hpp # tools/openlr/openlr_decoder.cpp # tools/openlr/openlr_decoder.hpp # tools/openlr/openlr_stat/openlr_stat.cpp # tools/openlr/router.hpp # tools/openlr/score_candidate_paths_getter.cpp # tools/openlr/score_candidate_paths_getter.hpp # xcode/CoMaps.xcworkspace/contents.xcworkspacedata
63 lines
2.0 KiB
C++
63 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
namespace traffic
|
|
{
|
|
/**
|
|
* A bucket for the ratio of the speed of moving traffic to the posted speed limit.
|
|
*
|
|
* Let Vmax be the posted speed limit and Vreal the speed at which traffic is currently flowing
|
|
* or expected to flow. The possible ratios (Vreal/Vmax) are grouped into buckets and, from then
|
|
* on, only the bucket number is used.
|
|
*
|
|
* The threshold ratios for the individual values are defined in `kSpeedGroupThresholdPercentage`.
|
|
*/
|
|
enum class SpeedGroup : uint8_t
|
|
{
|
|
G0 = 0,
|
|
G1,
|
|
G2,
|
|
G3,
|
|
G4,
|
|
G5,
|
|
TempBlock,
|
|
Unknown,
|
|
Count
|
|
};
|
|
|
|
static_assert(static_cast<uint8_t>(SpeedGroup::Count) <= 8, "");
|
|
|
|
/**
|
|
* Threshold ratios for the individual values of `SpeedGroup`.
|
|
*
|
|
* Let Vmax be the posted speed limit and Vreal the speed at which traffic is currently flowing
|
|
* or expected to flow. The possible ratios (Vreal/Vmax) are grouped into buckets and, from then
|
|
* on, only the bucket number is used.
|
|
*
|
|
* `kSpeedGroupThresholdPercentage[g]` is the maximum percentage of Vreal/Vmax for group g. Values
|
|
* falling on the border of two groups may belong to either group.
|
|
*
|
|
* For special groups, where Vreal/Vmax is unknown or undefined, the threshold is 100%.
|
|
*/
|
|
extern uint32_t const kSpeedGroupThresholdPercentage[static_cast<size_t>(SpeedGroup::Count)];
|
|
|
|
/**
|
|
* Converts the ratio between speed of flowing traffic and the posted limit to a `SpeedGroup`.
|
|
*
|
|
* This method is used in traffic jam generation: Let Vmax be the posted speed limit and Vreal the
|
|
* speed at which traffic is currently flowing or expected to flow. The possible ratios
|
|
* (Vreal/Vmax) are grouped into buckets and, from then on, only the bucket number is used.
|
|
*
|
|
* This method performs the conversion from the ratio to a `SpeedGroup` bucket.
|
|
*
|
|
* @param p Vreal / Vmax * 100% (ratio expressed in percent)
|
|
*
|
|
* @return the `SpeedGroup` value which corresponds to `p`
|
|
*/
|
|
SpeedGroup GetSpeedGroupByPercentage(double p);
|
|
|
|
std::string DebugPrint(SpeedGroup const & group);
|
|
} // namespace traffic
|