osrm-backend/include/engine/routing_algorithms/tile_turns.hpp
Michael Bell 5d468f2897
Make edge metrics strongly typed (#6421)
This change takes the existing typedefs for weight, duration and
distance, and makes them proper types, using the existing Alias
functionality.

Primarily this is to prevent bugs where the metrics are switched,
but it also adds additional documentation. For example, it now
makes it clear (despite the naming of variables) that most of the
trip algorithm is running on the duration metric.

I've not made any changes to the casts performed between metrics
and numeric types, they now just more explicit.
2022-10-28 15:16:12 +01:00

45 lines
1.2 KiB
C++

#ifndef OSRM_ENGINE_ROUTING_ALGORITHMS_TILE_TURNS_HPP
#define OSRM_ENGINE_ROUTING_ALGORITHMS_TILE_TURNS_HPP
#include "engine/algorithm.hpp"
#include "engine/datafacade.hpp"
#include "util/coordinate.hpp"
#include "util/typedefs.hpp"
#include <vector>
namespace osrm
{
namespace engine
{
namespace routing_algorithms
{
// Used to accumulate all the information we want in the tile about a turn.
struct TurnData final
{
const util::Coordinate coordinate;
const int in_angle;
const int turn_angle;
const EdgeWeight weight;
const EdgeDuration duration;
const guidance::TurnInstruction turn_instruction;
};
using RTreeLeaf = datafacade::BaseDataFacade::RTreeLeaf;
std::vector<TurnData> getTileTurns(const DataFacade<ch::Algorithm> &facade,
const std::vector<RTreeLeaf> &edges,
const std::vector<std::size_t> &sorted_edge_indexes);
std::vector<TurnData> getTileTurns(const DataFacade<mld::Algorithm> &facade,
const std::vector<RTreeLeaf> &edges,
const std::vector<std::size_t> &sorted_edge_indexes);
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
#endif