Prints turn types and modifiers as strings
This commit is contained in:
committed by
Daniel J. H
parent
c5b48e3506
commit
aed7bd852d
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "extractor/guidance/intersection.hpp"
|
||||
#include "extractor/guidance/intersection_handler.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
|
||||
#include "util/log.hpp"
|
||||
|
||||
@@ -45,12 +46,12 @@ class StatisticsHandler final : public IntersectionHandler
|
||||
util::Log() << "Assigned turn instruction types";
|
||||
|
||||
for (const auto &kv : type_hist)
|
||||
util::Log() << (int)kv.first << ": " << kv.second;
|
||||
util::Log() << internalInstructionTypeToString(kv.first) << ": " << kv.second;
|
||||
|
||||
util::Log() << "Assigned turn instruction modifiers";
|
||||
|
||||
for (const auto &kv : modifier_hist)
|
||||
util::Log() << (int)kv.first << ": " << kv.second;
|
||||
util::Log() << instructionModifierToString(kv.first) << ": " << kv.second;
|
||||
}
|
||||
|
||||
bool canProcess(const NodeID, const EdgeID, const Intersection &) const override final
|
||||
|
||||
@@ -309,6 +309,86 @@ inline DirectionModifier::Enum bearingToDirectionModifier(const double bearing)
|
||||
return extractor::guidance::DirectionModifier::Left;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
const constexpr char *modifier_names[] = {"uturn",
|
||||
"sharp right",
|
||||
"right",
|
||||
"slight right",
|
||||
"straight",
|
||||
"slight left",
|
||||
"left",
|
||||
"sharp left"};
|
||||
|
||||
/**
|
||||
* Human readable values for TurnType enum values
|
||||
*/
|
||||
struct TurnTypeName
|
||||
{
|
||||
// String value we return with our API
|
||||
const char *external_name;
|
||||
// Internal only string name for the turn type - useful for debugging
|
||||
// and used by debug tiles for visualizing hidden turn types
|
||||
const char *internal_name;
|
||||
};
|
||||
|
||||
// Indexes in this list correspond to the Enum values of osrm::extractor::guidance::TurnType
|
||||
const constexpr TurnTypeName turn_type_names[] = {
|
||||
{"invalid", "(not set)"},
|
||||
{"new name", "new name"},
|
||||
{"continue", "continue"},
|
||||
{"turn", "turn"},
|
||||
{"merge", "merge"},
|
||||
{"on ramp", "on ramp"},
|
||||
{"off ramp", "off ramp"},
|
||||
{"fork", "fork"},
|
||||
{"end of road", "end of road"},
|
||||
{"notification", "notification"},
|
||||
{"roundabout", "enter roundabout"},
|
||||
{"exit roundabout", "enter and exit roundabout"},
|
||||
{"rotary", "enter rotary"},
|
||||
{"exit rotary", "enter and exit rotary"},
|
||||
{"roundabout turn", "enter roundabout turn"},
|
||||
{"roundabout turn", "enter and exit roundabout turn"},
|
||||
{"use lane", "use lane"},
|
||||
{"invalid", "(noturn)"},
|
||||
{"invalid", "(suppressed)"},
|
||||
{"roundabout", "roundabout"},
|
||||
{"exit roundabout", "exit roundabout"},
|
||||
{"rotary", "rotary"},
|
||||
{"exit rotary", "exit rotary"},
|
||||
{"roundabout turn", "roundabout turn"},
|
||||
{"exit roundabout", "exit roundabout turn"},
|
||||
{"invalid", "(stay on roundabout)"},
|
||||
{"invalid", "(sliproad)"}};
|
||||
|
||||
} // ns detail
|
||||
|
||||
inline std::string instructionTypeToString(const TurnType::Enum type)
|
||||
{
|
||||
static_assert(sizeof(detail::turn_type_names) / sizeof(detail::turn_type_names[0]) >=
|
||||
TurnType::MaxTurnType,
|
||||
"Some turn types have no string representation.");
|
||||
return detail::turn_type_names[static_cast<std::size_t>(type)].external_name;
|
||||
}
|
||||
|
||||
inline std::string internalInstructionTypeToString(const TurnType::Enum type)
|
||||
{
|
||||
static_assert(sizeof(detail::turn_type_names) / sizeof(detail::turn_type_names[0]) >=
|
||||
TurnType::MaxTurnType,
|
||||
"Some turn types have no string representation.");
|
||||
return detail::turn_type_names[static_cast<std::size_t>(type)].internal_name;
|
||||
}
|
||||
|
||||
inline std::string instructionModifierToString(const DirectionModifier::Enum modifier)
|
||||
{
|
||||
static_assert(sizeof(detail::modifier_names) / sizeof(detail::modifier_names[0]) >=
|
||||
DirectionModifier::MaxDirectionModifier,
|
||||
"Some direction modifiers have no string representation.");
|
||||
return detail::modifier_names[static_cast<std::size_t>(modifier)];
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
Reference in New Issue
Block a user