Big Restructuring / Cleanup
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#ifndef ENGINE_RESPONSE_OBJECTS_HPP_
|
||||
#define ENGINE_RESPONSE_OBJECTS_HPP_
|
||||
|
||||
#include "engine/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/travel_mode.hpp"
|
||||
#include "engine/polyline_compressor.hpp"
|
||||
#include "engine/guidance/route_step.hpp"
|
||||
@@ -32,8 +32,8 @@ namespace json
|
||||
namespace detail
|
||||
{
|
||||
|
||||
std::string instructionTypeToString(guidance::TurnType type);
|
||||
std::string instructionModifierToString(guidance::DirectionModifier modifier);
|
||||
std::string instructionTypeToString(extractor::guidance::TurnType type);
|
||||
std::string instructionModifierToString(extractor::guidance::DirectionModifier modifier);
|
||||
|
||||
util::json::Array coordinateToLonLat(const util::Coordinate coordinate);
|
||||
|
||||
|
||||
@@ -39,8 +39,7 @@ class MatchAPI final : public RouteAPI
|
||||
auto route = MakeRoute(sub_routes[index].segment_end_coordinates,
|
||||
sub_routes[index].unpacked_path_segments,
|
||||
sub_routes[index].source_traversed_in_reverse,
|
||||
sub_routes[index].target_traversed_in_reverse,
|
||||
nullptr);
|
||||
sub_routes[index].target_traversed_in_reverse, nullptr);
|
||||
route.values["confidence"] = sub_matchings[index].confidence;
|
||||
routes.values.push_back(std::move(route));
|
||||
}
|
||||
|
||||
@@ -152,6 +152,7 @@ class RouteAPI : public BaseAPI
|
||||
leg_geometry.locations.begin() + step.geometry_end));
|
||||
});
|
||||
}
|
||||
|
||||
return json::makeRoute(route,
|
||||
json::makeRouteLegs(std::move(legs), std::move(step_geometries)),
|
||||
std::move(json_overview));
|
||||
|
||||
@@ -29,7 +29,7 @@ class TripAPI final : public RouteAPI
|
||||
const std::vector<InternalRouteResult> &sub_routes,
|
||||
const std::vector<PhantomNode> &phantoms,
|
||||
util::json::Object &response,
|
||||
const std::vector<std::vector<util::Coordinate>> * const coordinates) const
|
||||
const std::vector<std::vector<util::Coordinate>> *const coordinates) const
|
||||
{
|
||||
auto number_of_routes = sub_trips.size();
|
||||
util::json::Array routes;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "extractor/external_memory_node.hpp"
|
||||
#include "contractor/query_edge.hpp"
|
||||
#include "engine/phantom_node.hpp"
|
||||
#include "engine/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/string_util.hpp"
|
||||
@@ -76,7 +76,7 @@ class BaseDataFacade
|
||||
virtual void GetUncompressedWeights(const EdgeID id,
|
||||
std::vector<EdgeWeight> &result_weights) const = 0;
|
||||
|
||||
virtual guidance::TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const = 0;
|
||||
virtual extractor::guidance::TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const = 0;
|
||||
|
||||
virtual extractor::TravelMode GetTravelModeForEdgeID(const unsigned id) const = 0;
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "engine/datafacade/datafacade_base.hpp"
|
||||
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
|
||||
#include "engine/geospatial_query.hpp"
|
||||
#include "extractor/original_edge_data.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
@@ -68,7 +70,7 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
std::shared_ptr<util::ShM<util::Coordinate, false>::vector> m_coordinate_list;
|
||||
util::ShM<NodeID, false>::vector m_via_node_list;
|
||||
util::ShM<unsigned, false>::vector m_name_ID_list;
|
||||
util::ShM<guidance::TurnInstruction, false>::vector m_turn_instruction_list;
|
||||
util::ShM<extractor::guidance::TurnInstruction, false>::vector m_turn_instruction_list;
|
||||
util::ShM<extractor::TravelMode, false>::vector m_travel_mode_list;
|
||||
util::ShM<char, false>::vector m_names_char_list;
|
||||
util::ShM<unsigned, false>::vector m_geometry_indices;
|
||||
@@ -327,7 +329,7 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
return m_coordinate_list->at(id);
|
||||
}
|
||||
|
||||
guidance::TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const override final
|
||||
extractor::guidance::TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const override final
|
||||
{
|
||||
return m_turn_instruction_list.at(id);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "storage/shared_datatype.hpp"
|
||||
#include "storage/shared_memory.hpp"
|
||||
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
|
||||
#include "engine/geospatial_query.hpp"
|
||||
#include "util/range_table.hpp"
|
||||
#include "util/static_graph.hpp"
|
||||
@@ -70,7 +72,7 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
std::shared_ptr<util::ShM<util::Coordinate, true>::vector> m_coordinate_list;
|
||||
util::ShM<NodeID, true>::vector m_via_node_list;
|
||||
util::ShM<unsigned, true>::vector m_name_ID_list;
|
||||
util::ShM<guidance::TurnInstruction, true>::vector m_turn_instruction_list;
|
||||
util::ShM<extractor::guidance::TurnInstruction, true>::vector m_turn_instruction_list;
|
||||
util::ShM<extractor::TravelMode, true>::vector m_travel_mode_list;
|
||||
util::ShM<char, true>::vector m_names_char_list;
|
||||
util::ShM<unsigned, true>::vector m_name_begin_indices;
|
||||
@@ -145,9 +147,9 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
travel_mode_list_ptr, data_layout->num_entries[storage::SharedDataLayout::TRAVEL_MODE]);
|
||||
m_travel_mode_list = std::move(travel_mode_list);
|
||||
|
||||
auto turn_instruction_list_ptr = data_layout->GetBlockPtr<guidance::TurnInstruction>(
|
||||
auto turn_instruction_list_ptr = data_layout->GetBlockPtr<extractor::guidance::TurnInstruction>(
|
||||
shared_memory, storage::SharedDataLayout::TURN_INSTRUCTION);
|
||||
typename util::ShM<guidance::TurnInstruction, true>::vector turn_instruction_list(
|
||||
typename util::ShM<extractor::guidance::TurnInstruction, true>::vector turn_instruction_list(
|
||||
turn_instruction_list_ptr,
|
||||
data_layout->num_entries[storage::SharedDataLayout::TURN_INSTRUCTION]);
|
||||
m_turn_instruction_list = std::move(turn_instruction_list);
|
||||
@@ -398,7 +400,7 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
return m_via_node_list.at(id);
|
||||
}
|
||||
|
||||
guidance::TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const override final
|
||||
extractor::guidance::TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const override final
|
||||
{
|
||||
return m_turn_instruction_list.at(id);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "engine/guidance/leg_geometry.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
#include "engine/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/travel_mode.hpp"
|
||||
|
||||
#include <vector>
|
||||
@@ -49,7 +49,7 @@ LegGeometry assembleGeometry(const DataFacadeT &facade,
|
||||
current_distance +=
|
||||
util::coordinate_calculation::haversineDistance(prev_coordinate, coordinate);
|
||||
|
||||
if (path_point.turn_instruction != TurnInstruction::NO_TURN())
|
||||
if (path_point.turn_instruction != extractor::guidance::TurnInstruction::NO_TURN())
|
||||
{
|
||||
geometry.segment_distances.push_back(current_distance);
|
||||
geometry.segment_offsets.push_back(geometry.locations.size());
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "engine/guidance/route_step.hpp"
|
||||
#include "engine/guidance/step_maneuver.hpp"
|
||||
#include "engine/guidance/leg_geometry.hpp"
|
||||
#include "engine/guidance/guidance_toolkit.hpp"
|
||||
#include "engine/guidance/turn_instruction.hpp"
|
||||
#include "engine/guidance/toolkit.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "engine/internal_route_result.hpp"
|
||||
#include "engine/phantom_node.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
@@ -25,7 +25,7 @@ namespace guidance
|
||||
namespace detail
|
||||
{
|
||||
// FIXME move implementation to cpp
|
||||
inline StepManeuver stepManeuverFromGeometry(TurnInstruction instruction,
|
||||
inline StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
|
||||
const LegGeometry &leg_geometry,
|
||||
const std::size_t segment_index,
|
||||
const unsigned exit)
|
||||
@@ -59,7 +59,6 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
boost::optional<util::Coordinate> source_location,
|
||||
boost::optional<util::Coordinate> target_location)
|
||||
{
|
||||
(void) source_location;
|
||||
const auto source_duration =
|
||||
(source_traversed_in_reverse ? source_node.GetReverseWeightPlusOffset()
|
||||
: source_node.GetForwardWeightPlusOffset()) /
|
||||
@@ -80,22 +79,28 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
steps.reserve(number_of_segments);
|
||||
|
||||
std::size_t segment_index = 0;
|
||||
const auto initial_modifier =
|
||||
(source_location && leg_geometry.locations.size() >= 2)
|
||||
? angleToDirectionModifier(util::coordinate_calculation::computeAngle(
|
||||
source_location.get(), *(leg_geometry.locations.begin()),
|
||||
*(leg_geometry.locations.begin() + 1)))
|
||||
: extractor::guidance::DirectionModifier::UTurn;
|
||||
|
||||
if (leg_data.size() > 0)
|
||||
{
|
||||
|
||||
StepManeuver maneuver = detail::stepManeuverFromGeometry(
|
||||
TurnInstruction{TurnType::Location, DirectionModifier::UTurn}, leg_geometry,
|
||||
segment_index, INVALID_EXIT_NR);
|
||||
maneuver.instruction.direction_modifier = bearingToDirectionModifier(maneuver.bearing_before);
|
||||
extractor::guidance::TurnInstruction{extractor::guidance::TurnType::Location,
|
||||
initial_modifier},
|
||||
leg_geometry, segment_index, INVALID_EXIT_NR);
|
||||
|
||||
// TODO fix this: it makes no sense
|
||||
// PathData saves the information we need of the segment _before_ the turn,
|
||||
// but a RouteStep is with regard to the segment after the turn.
|
||||
// We need to skip the first segment because it is already covered by the
|
||||
// initial start of a route
|
||||
for (const auto &path_point : leg_data)
|
||||
{
|
||||
if (path_point.turn_instruction != TurnInstruction::NO_TURN())
|
||||
if (path_point.turn_instruction != extractor::guidance::TurnInstruction::NO_TURN())
|
||||
{
|
||||
const auto name = facade.get_name_for_id(path_point.name_id);
|
||||
const auto distance = leg_geometry.segment_distances[segment_index];
|
||||
@@ -108,7 +113,6 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
segment_index++;
|
||||
}
|
||||
}
|
||||
// TODO remove this hack
|
||||
const auto distance = leg_geometry.segment_distances[segment_index];
|
||||
steps.push_back(RouteStep{target_node.name_id, facade.get_name_for_id(target_node.name_id),
|
||||
target_duration, distance, target_mode, maneuver,
|
||||
@@ -123,9 +127,9 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
// x---*---*---*---z compressed edge
|
||||
// |-------| duration
|
||||
StepManeuver maneuver = {source_node.location, 0., 0.,
|
||||
TurnInstruction{TurnType::Location, DirectionModifier::UTurn},
|
||||
extractor::guidance::TurnInstruction{
|
||||
extractor::guidance::TurnType::Location, initial_modifier},
|
||||
INVALID_EXIT_NR};
|
||||
maneuver.instruction.direction_modifier = bearingToDirectionModifier(maneuver.bearing_before);
|
||||
|
||||
steps.push_back(RouteStep{source_node.name_id, facade.get_name_for_id(source_node.name_id),
|
||||
target_duration - source_duration,
|
||||
@@ -136,15 +140,18 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
|
||||
BOOST_ASSERT(segment_index == number_of_segments - 1);
|
||||
const auto final_modifier =
|
||||
target_location ? angleToDirectionModifier(util::coordinate_calculation::computeAngle(
|
||||
*(leg_geometry.locations.end() - 3),
|
||||
*(leg_geometry.locations.end() - 1), target_location.get()))
|
||||
: DirectionModifier::UTurn;
|
||||
(target_location && leg_geometry.locations.size() >= 2)
|
||||
? angleToDirectionModifier(util::coordinate_calculation::computeAngle(
|
||||
*(leg_geometry.locations.end() - 2), *(leg_geometry.locations.end() - 1),
|
||||
target_location.get()))
|
||||
: extractor::guidance::DirectionModifier::UTurn;
|
||||
// This step has length zero, the only reason we need it is the target location
|
||||
steps.push_back(RouteStep{
|
||||
target_node.name_id, facade.get_name_for_id(target_node.name_id), 0., 0., target_mode,
|
||||
StepManeuver{target_node.location, 0., 0.,
|
||||
TurnInstruction{TurnType::Location, final_modifier}, INVALID_EXIT_NR},
|
||||
extractor::guidance::TurnInstruction{extractor::guidance::TurnType::Location,
|
||||
final_modifier},
|
||||
INVALID_EXIT_NR},
|
||||
leg_geometry.locations.size(), leg_geometry.locations.size()});
|
||||
|
||||
return steps;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace engine
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
std::vector<std::vector<PathData>> postProcess( std::vector<std::vector<PathData>> path_data );
|
||||
std::vector<std::vector<PathData>> postProcess(std::vector<std::vector<PathData>> path_data);
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace engine
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define ENGINE_GUIDANCE_STEP_MANEUVER_HPP
|
||||
|
||||
#include "util/coordinate.hpp"
|
||||
#include "engine/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -16,7 +16,7 @@ struct StepManeuver
|
||||
util::Coordinate location;
|
||||
double bearing_before;
|
||||
double bearing_after;
|
||||
TurnInstruction instruction;
|
||||
extractor::guidance::TurnInstruction instruction;
|
||||
unsigned exit;
|
||||
};
|
||||
} // namespace guidance
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef OSRM_UTIL_GUIDANCE_TOOLKIT_HPP_
|
||||
#define OSRM_UTIL_GUIDANCE_TOOLKIT_HPP_
|
||||
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "util/bearing.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
// Silent Turn Instructions are not to be mentioned to the outside world but
|
||||
inline bool isSilent(const extractor::guidance::TurnInstruction instruction)
|
||||
{
|
||||
return instruction.type == extractor::guidance::TurnType::NoTurn || instruction.type == extractor::guidance::TurnType::Suppressed ||
|
||||
instruction.type == extractor::guidance::TurnType::StayOnRoundabout;
|
||||
}
|
||||
|
||||
inline bool entersRoundabout(const extractor::guidance::TurnInstruction instruction)
|
||||
{
|
||||
return (instruction.type == extractor::guidance::TurnType::EnterRoundabout ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRotary ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRoundaboutAtExit ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRotaryAtExit ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRoundabout ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRotary);
|
||||
}
|
||||
|
||||
inline bool leavesRoundabout(const extractor::guidance::TurnInstruction instruction)
|
||||
{
|
||||
return (instruction.type == extractor::guidance::TurnType::ExitRoundabout ||
|
||||
instruction.type == extractor::guidance::TurnType::ExitRotary ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRoundabout ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRotary);
|
||||
}
|
||||
|
||||
inline bool staysOnRoundabout(const extractor::guidance::TurnInstruction instruction)
|
||||
{
|
||||
return instruction.type == extractor::guidance::TurnType::StayOnRoundabout;
|
||||
}
|
||||
|
||||
inline extractor::guidance::DirectionModifier angleToDirectionModifier(const double bearing)
|
||||
{
|
||||
if (bearing < 135)
|
||||
{
|
||||
return extractor::guidance::DirectionModifier::Right;
|
||||
}
|
||||
|
||||
if (bearing <= 225)
|
||||
{
|
||||
return extractor::guidance::DirectionModifier::Straight;
|
||||
}
|
||||
return extractor::guidance::DirectionModifier::Left;
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace engine
|
||||
} // namespace osrm
|
||||
|
||||
#endif /* OSRM_UTIL_GUIDANCE_TOOLKIT_HPP_ */
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "engine/phantom_node.hpp"
|
||||
#include "extractor/travel_mode.hpp"
|
||||
#include "guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
@@ -26,7 +26,7 @@ struct PathData
|
||||
// duration that is traveled on the segment until the turn is reached
|
||||
EdgeWeight duration_until_turn;
|
||||
// instruction to execute at the turn
|
||||
guidance::TurnInstruction turn_instruction;
|
||||
extractor::guidance::TurnInstruction turn_instruction;
|
||||
// travel mode of the street that leads to the turn
|
||||
extractor::TravelMode travel_mode : 4;
|
||||
// exit ID of highway exit, roundabout exit, intersection nr
|
||||
|
||||
@@ -203,7 +203,7 @@ class BasePlugin
|
||||
}
|
||||
}
|
||||
|
||||
// we didn't found a fitting node, return error
|
||||
// we didn't find a fitting node, return error
|
||||
if (phantom_nodes[i].empty())
|
||||
{
|
||||
break;
|
||||
@@ -264,7 +264,7 @@ class BasePlugin
|
||||
}
|
||||
}
|
||||
|
||||
// we didn't found a fitting node, return error
|
||||
// we didn't find a fitting node, return error
|
||||
if (!phantom_node_pairs[i].first.IsValid(facade.GetNumberOfNodes()))
|
||||
{
|
||||
//TODO document why?
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "engine/internal_route_result.hpp"
|
||||
#include "engine/search_engine_data.hpp"
|
||||
#include "engine/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
@@ -283,7 +283,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
{
|
||||
BOOST_ASSERT_MSG(!ed.shortcut, "original edge flagged as shortcut");
|
||||
unsigned name_index = facade->GetNameIndexFromEdgeID(ed.id);
|
||||
const guidance::TurnInstruction turn_instruction =
|
||||
const auto turn_instruction =
|
||||
facade->GetTurnInstructionForEdgeID(ed.id);
|
||||
const extractor::TravelMode travel_mode =
|
||||
(unpacked_path.empty() && start_traversed_in_reverse)
|
||||
@@ -320,9 +320,9 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
BOOST_ASSERT(start_index < end_index);
|
||||
for (std::size_t i = start_index; i < end_index; ++i)
|
||||
{
|
||||
unpacked_path.push_back(PathData{id_vector[i], name_index, weight_vector[i],
|
||||
guidance::TurnInstruction::NO_TURN(),
|
||||
travel_mode, INVALID_EXIT_NR});
|
||||
unpacked_path.push_back(PathData{id_vector[i], name_index, weight_vector[i],
|
||||
extractor::guidance::TurnInstruction::NO_TURN(),
|
||||
travel_mode, INVALID_EXIT_NR});
|
||||
}
|
||||
BOOST_ASSERT(unpacked_path.size() > 0);
|
||||
unpacked_path.back().turn_instruction = turn_instruction;
|
||||
@@ -365,7 +365,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0);
|
||||
unpacked_path.emplace_back(PathData{
|
||||
id_vector[i], phantom_node_pair.target_phantom.name_id, 0,
|
||||
guidance::TurnInstruction::NO_TURN(),
|
||||
extractor::guidance::TurnInstruction::NO_TURN(),
|
||||
target_traversed_in_reverse ? phantom_node_pair.target_phantom.backward_travel_mode
|
||||
: phantom_node_pair.target_phantom.forward_travel_mode,
|
||||
INVALID_EXIT_NR});
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
#include "extractor/edge_based_node.hpp"
|
||||
#include "extractor/original_edge_data.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/turn_analysis.hpp"
|
||||
#include "extractor/guidance/turn_analysis.hpp"
|
||||
|
||||
#include "engine/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
|
||||
#include "util/node_based_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
@@ -71,12 +71,12 @@ class EdgeBasedGraphFactory
|
||||
// with known angle.
|
||||
// Handles special cases like u-turns and roundabouts
|
||||
// For basic turns, the turn based on the angle-classification is returned
|
||||
engine::guidance::TurnInstruction AnalyzeTurn(const NodeID u,
|
||||
const EdgeID e1,
|
||||
const NodeID v,
|
||||
const EdgeID e2,
|
||||
const NodeID w,
|
||||
const double angle) const;
|
||||
guidance::TurnInstruction AnalyzeTurn(const NodeID u,
|
||||
const EdgeID e1,
|
||||
const NodeID v,
|
||||
const EdgeID e2,
|
||||
const NodeID w,
|
||||
const double angle) const;
|
||||
|
||||
std::int32_t GetTurnPenalty(double angle, lua_State *lua_state) const;
|
||||
|
||||
@@ -129,10 +129,6 @@ class EdgeBasedGraphFactory
|
||||
void FlushVectorToStream(std::ofstream &edge_data_file,
|
||||
std::vector<OriginalEdgeData> &original_edge_data_vector) const;
|
||||
|
||||
// Use In Order to generate base turns
|
||||
std::vector<TurnCandidate> getTurns(const NodeID from, const EdgeID via_edge);
|
||||
// cannot be const due to the counters...
|
||||
|
||||
std::size_t restricted_turns_counter;
|
||||
std::size_t skipped_uturns_counter;
|
||||
std::size_t skipped_barrier_turns_counter;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "extractor/travel_mode.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
#include "engine/guidance/classification_data.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -34,7 +33,6 @@ struct ExtractionWay
|
||||
name.clear();
|
||||
forward_travel_mode = TRAVEL_MODE_INACCESSIBLE;
|
||||
backward_travel_mode = TRAVEL_MODE_INACCESSIBLE;
|
||||
road_classification_data.invalidate();
|
||||
}
|
||||
|
||||
// These accessors exists because it's not possible to take the address of a bitfield,
|
||||
@@ -53,7 +51,6 @@ struct ExtractionWay
|
||||
bool is_startpoint;
|
||||
TravelMode forward_travel_mode : 4;
|
||||
TravelMode backward_travel_mode : 4;
|
||||
engine::guidance::RoadClassificationData road_classification_data;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+16
-28
@@ -1,13 +1,11 @@
|
||||
#ifndef OSRM_GUIDANCE_CLASSIFICATION_DATA_HPP_
|
||||
#define OSRM_GUIDANCE_CLASSIFICATION_DATA_HPP_
|
||||
#ifndef OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_
|
||||
#define OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_
|
||||
|
||||
#include "util/simple_logger.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <iostream> //TODO remove
|
||||
|
||||
#include "util/simple_logger.hpp"
|
||||
|
||||
// Forward Declaration to allow usage of external osmium::Way
|
||||
namespace osmium
|
||||
{
|
||||
@@ -16,13 +14,14 @@ class Way;
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
enum FunctionalRoadClass
|
||||
enum class FunctionalRoadClass : short
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
MOTORWAY,
|
||||
MOTORWAY_LINK,
|
||||
TRUNK,
|
||||
@@ -37,12 +36,12 @@ enum FunctionalRoadClass
|
||||
RESIDENTIAL,
|
||||
SERVICE,
|
||||
LIVING_STREET,
|
||||
LOW_PRIORITY_ROAD, // a road simply included for connectivity. Should be avoided at all cost
|
||||
UNKNOWN
|
||||
LOW_PRIORITY_ROAD // a road simply included for connectivity. Should be avoided at all cost
|
||||
};
|
||||
|
||||
inline FunctionalRoadClass functionalRoadClassFromTag(std::string const &value)
|
||||
{
|
||||
//FIXME at some point this should be part of the profiles
|
||||
const static auto initializeClassHash = []()
|
||||
{
|
||||
std::unordered_map<std::string, FunctionalRoadClass> hash;
|
||||
@@ -84,36 +83,25 @@ inline FunctionalRoadClass functionalRoadClassFromTag(std::string const &value)
|
||||
inline bool isRampClass(const FunctionalRoadClass road_class)
|
||||
{
|
||||
// Primary Roads and down are usually too small to announce their links as ramps
|
||||
return road_class == MOTORWAY_LINK || road_class == TRUNK_LINK;
|
||||
//|| road_class == PRIMARY_LINK ||
|
||||
// road_class == SECONDARY_LINK || road_class == TERTIARY_LINK;
|
||||
return road_class == FunctionalRoadClass::MOTORWAY_LINK ||
|
||||
road_class == FunctionalRoadClass::TRUNK_LINK;
|
||||
}
|
||||
|
||||
// TODO augment this with all data required for guidance generation
|
||||
struct RoadClassificationData
|
||||
{
|
||||
FunctionalRoadClass road_class;
|
||||
FunctionalRoadClass road_class = FunctionalRoadClass::UNKNOWN;
|
||||
|
||||
void augment(const osmium::Way &way);
|
||||
|
||||
// reset to a defined but invalid state
|
||||
void invalidate();
|
||||
|
||||
static RoadClassificationData INVALID()
|
||||
{
|
||||
RoadClassificationData tmp;
|
||||
tmp.invalidate();
|
||||
return tmp;
|
||||
};
|
||||
};
|
||||
|
||||
inline bool operator==( const RoadClassificationData lhs, const RoadClassificationData rhs )
|
||||
inline bool operator==(const RoadClassificationData lhs, const RoadClassificationData rhs)
|
||||
{
|
||||
return lhs.road_class == rhs.road_class;
|
||||
return lhs.road_class == rhs.road_class;
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace engine
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_GUIDANCE_CLASSIFICATION_DATA_HPP_
|
||||
#endif // OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_DISCRETE_ANGLE
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_DISCRETE_ANGLE
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
typedef uint8_t DiscreteAngle;
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /* OSRM_EXTRACTOR_GUIDANCE_DISCRETE_ANGLE */
|
||||
+46
-133
@@ -1,5 +1,5 @@
|
||||
#ifndef OSRM_GUIDANCE_GUIDANCE_TOOLKIT_HPP_
|
||||
#define OSRM_GUIDANCE_GUIDANCE_TOOLKIT_HPP_
|
||||
#ifndef OSRM_GUIDANCE_TOOLKIT_HPP_
|
||||
#define OSRM_GUIDANCE_TOOLKIT_HPP_
|
||||
|
||||
#include "util/bearing.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
@@ -8,15 +8,16 @@
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
|
||||
#include "engine/guidance/classification_data.hpp"
|
||||
#include "engine/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/discrete_angle.hpp"
|
||||
#include "extractor/guidance/classification_data.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <cmath>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
@@ -26,15 +27,10 @@ namespace detail
|
||||
const constexpr double DESIRED_SEGMENT_LENGTH = 10.0;
|
||||
const constexpr bool shiftable_ccw[] = {false, true, true, false, false, true, true, false};
|
||||
const constexpr bool shiftable_cw[] = {false, false, true, true, false, false, true, true};
|
||||
// direction modifier bounds in 360./256. degrees
|
||||
const constexpr uint8_t modifier_bounds[num_direction_modifiers] = {0, 36, 93, 121,
|
||||
136, 163, 220, 255};
|
||||
|
||||
const constexpr uint8_t modifier_bounds[detail::num_direction_modifiers] = {
|
||||
0, 36, 93, 121, 136, 163, 220, 255};
|
||||
const constexpr double discrete_angle_step_size = 360. / 256.;
|
||||
} // namespace detail
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename IteratorType>
|
||||
util::Coordinate
|
||||
getCoordinateFromCompressedRange(util::Coordinate current_coordinate,
|
||||
@@ -136,13 +132,15 @@ getRepresentativeCoordinate(const NodeID from_node,
|
||||
}
|
||||
|
||||
// shift an instruction around the degree circle in CCW order
|
||||
inline DirectionModifier forcedShiftCCW(const DirectionModifier modifier)
|
||||
inline DirectionModifier
|
||||
forcedShiftCCW(const DirectionModifier modifier)
|
||||
{
|
||||
return static_cast<DirectionModifier>((static_cast<uint32_t>(modifier) + 1) %
|
||||
detail::num_direction_modifiers);
|
||||
return static_cast<DirectionModifier>(
|
||||
(static_cast<uint32_t>(modifier) + 1) % detail::num_direction_modifiers);
|
||||
}
|
||||
|
||||
inline DirectionModifier shiftCCW(const DirectionModifier modifier)
|
||||
inline DirectionModifier
|
||||
shiftCCW(const DirectionModifier modifier)
|
||||
{
|
||||
if (detail::shiftable_ccw[static_cast<int>(modifier)])
|
||||
return forcedShiftCCW(modifier);
|
||||
@@ -151,14 +149,16 @@ inline DirectionModifier shiftCCW(const DirectionModifier modifier)
|
||||
}
|
||||
|
||||
// shift an instruction around the degree circle in CW order
|
||||
inline DirectionModifier forcedShiftCW(const DirectionModifier modifier)
|
||||
inline DirectionModifier
|
||||
forcedShiftCW(const DirectionModifier modifier)
|
||||
{
|
||||
return static_cast<DirectionModifier>(
|
||||
(static_cast<uint32_t>(modifier) + detail::num_direction_modifiers - 1) %
|
||||
detail::num_direction_modifiers);
|
||||
}
|
||||
|
||||
inline DirectionModifier shiftCW(const DirectionModifier modifier)
|
||||
inline DirectionModifier
|
||||
shiftCW(const DirectionModifier modifier)
|
||||
{
|
||||
if (detail::shiftable_cw[static_cast<int>(modifier)])
|
||||
return forcedShiftCW(modifier);
|
||||
@@ -166,60 +166,21 @@ inline DirectionModifier shiftCW(const DirectionModifier modifier)
|
||||
return modifier;
|
||||
}
|
||||
|
||||
inline bool entersRoundabout(const TurnInstruction instruction)
|
||||
{
|
||||
return (instruction.type == TurnType::EnterRoundabout ||
|
||||
instruction.type == TurnType::EnterRotary ||
|
||||
instruction.type == TurnType::EnterRoundaboutAtExit ||
|
||||
instruction.type == TurnType::EnterRotaryAtExit ||
|
||||
instruction.type == TurnType::EnterAndExitRoundabout ||
|
||||
instruction.type == TurnType::EnterAndExitRotary);
|
||||
}
|
||||
|
||||
inline bool leavesRoundabout(const TurnInstruction instruction)
|
||||
{
|
||||
return (instruction.type == TurnType::ExitRoundabout ||
|
||||
instruction.type == TurnType::ExitRotary ||
|
||||
instruction.type == TurnType::EnterAndExitRoundabout ||
|
||||
instruction.type == TurnType::EnterAndExitRotary);
|
||||
}
|
||||
|
||||
inline bool staysOnRoundabout(const TurnInstruction instruction)
|
||||
{
|
||||
return instruction.type == TurnType::StayOnRoundabout;
|
||||
}
|
||||
|
||||
inline bool isOnRoundabout(const TurnInstruction instruction)
|
||||
{
|
||||
return staysOnRoundabout(instruction) || leavesRoundabout(instruction);
|
||||
}
|
||||
|
||||
inline bool isTurnNecessary(const TurnInstruction instruction)
|
||||
{
|
||||
return instruction.type != TurnType::NoTurn && instruction.type != TurnType::Suppressed;
|
||||
}
|
||||
|
||||
inline bool isLeftRight(const DirectionModifier modifier)
|
||||
{
|
||||
return DirectionModifier::Right == modifier || DirectionModifier::Left == modifier;
|
||||
}
|
||||
|
||||
inline bool isSlightLeftRight(const DirectionModifier modifier)
|
||||
{
|
||||
return DirectionModifier::SlightRight == modifier || DirectionModifier::SlightLeft == modifier;
|
||||
}
|
||||
|
||||
inline bool isBasic(const TurnType type)
|
||||
{
|
||||
return type == TurnType::Turn || type == TurnType::EndOfRoad;
|
||||
return type == TurnType::Turn ||
|
||||
type == TurnType::EndOfRoad;
|
||||
}
|
||||
|
||||
inline bool isUturn(const TurnInstruction instruction)
|
||||
{
|
||||
return isBasic(instruction.type) && instruction.direction_modifier == DirectionModifier::UTurn;
|
||||
return isBasic(instruction.type) &&
|
||||
instruction.direction_modifier == DirectionModifier::UTurn;
|
||||
}
|
||||
|
||||
inline bool resolve(TurnInstruction &to_resolve, const TurnInstruction neighbor, bool resolve_cw)
|
||||
inline bool resolve(TurnInstruction &to_resolve,
|
||||
const TurnInstruction neighbor,
|
||||
bool resolve_cw)
|
||||
{
|
||||
const auto shifted_turn = resolve_cw ? shiftCW(to_resolve.direction_modifier)
|
||||
: shiftCCW(to_resolve.direction_modifier);
|
||||
@@ -262,8 +223,9 @@ inline bool isSlightModifier(const DirectionModifier direction_modifier)
|
||||
|
||||
inline bool isSharpTurn(const TurnInstruction turn)
|
||||
{
|
||||
return isBasic(turn.type) && (turn.direction_modifier == DirectionModifier::SharpLeft ||
|
||||
turn.direction_modifier == DirectionModifier::SharpRight);
|
||||
return isBasic(turn.type) &&
|
||||
(turn.direction_modifier == DirectionModifier::SharpLeft ||
|
||||
turn.direction_modifier == DirectionModifier::SharpRight);
|
||||
}
|
||||
|
||||
inline bool isStraight(const TurnInstruction turn)
|
||||
@@ -272,30 +234,18 @@ inline bool isStraight(const TurnInstruction turn)
|
||||
turn.direction_modifier == DirectionModifier::Straight;
|
||||
}
|
||||
|
||||
inline bool isConflict(const TurnInstruction first, const TurnInstruction second)
|
||||
inline bool isConflict(const TurnInstruction first,
|
||||
const TurnInstruction second)
|
||||
{
|
||||
return (first.type == second.type && first.direction_modifier == second.direction_modifier) ||
|
||||
(isStraight(first) && isStraight(second));
|
||||
}
|
||||
|
||||
inline DirectionModifier discreteAngleToDircetionModifier(const DiscreteAngle angle)
|
||||
{
|
||||
auto modifier = DirectionModifier::UTurn;
|
||||
DiscreteAngle bound(detail::modifier_bounds[modifier]);
|
||||
do
|
||||
{
|
||||
if (angle <= bound)
|
||||
return modifier;
|
||||
modifier = forcedShiftCW(modifier);
|
||||
bound = static_cast<DiscreteAngle>(detail::modifier_bounds[modifier]);
|
||||
} while (modifier != DirectionModifier::UTurn);
|
||||
return modifier;
|
||||
}
|
||||
|
||||
inline DiscreteAngle discretizeAngle(const double angle)
|
||||
{
|
||||
BOOST_ASSERT(angle >= 0. && angle <= 360.);
|
||||
return DiscreteAngle(static_cast<uint8_t>(angle / detail::discrete_angle_step_size));
|
||||
return DiscreteAngle(
|
||||
static_cast<uint8_t>(angle / detail::discrete_angle_step_size));
|
||||
}
|
||||
|
||||
inline double angleFromDiscreteAngle(const DiscreteAngle angle)
|
||||
@@ -319,7 +269,8 @@ inline double getTurnConfidence(const double angle, TurnInstruction instruction)
|
||||
{
|
||||
|
||||
// special handling of U-Turns and Roundabout
|
||||
if (!isBasic(instruction.type) || instruction.direction_modifier == DirectionModifier::UTurn)
|
||||
if (!isBasic(instruction.type) ||
|
||||
instruction.direction_modifier == DirectionModifier::UTurn)
|
||||
return 1.0;
|
||||
|
||||
const double deviations[] = {0, 45, 50, 35, 10, 35, 50, 45};
|
||||
@@ -352,57 +303,19 @@ inline DirectionModifier getTurnDirection(const double angle)
|
||||
return DirectionModifier::UTurn;
|
||||
}
|
||||
|
||||
inline DirectionModifier angleToDirectionModifier(const double bearing)
|
||||
{
|
||||
if (bearing < 135)
|
||||
{
|
||||
return DirectionModifier::Right;
|
||||
}
|
||||
|
||||
if (bearing <= 225)
|
||||
{
|
||||
return DirectionModifier::Straight;
|
||||
}
|
||||
return DirectionModifier::Left;
|
||||
}
|
||||
|
||||
inline DirectionModifier bearingToDirectionModifier(const std::string &bearing)
|
||||
{
|
||||
const static auto buildHash = []()
|
||||
{
|
||||
std::map<std::string, DirectionModifier> hash;
|
||||
hash["N"] = DirectionModifier::Straight;
|
||||
hash["NE"] = DirectionModifier::SlightRight;
|
||||
hash["E"] = DirectionModifier::Right;
|
||||
hash["SE"] = DirectionModifier::SharpRight;
|
||||
hash["S"] = DirectionModifier::UTurn;
|
||||
hash["SW"] = DirectionModifier::SharpLeft;
|
||||
hash["W"] = DirectionModifier::Left;
|
||||
hash["NW"] = DirectionModifier::SlightLeft;
|
||||
return hash;
|
||||
};
|
||||
|
||||
const static std::map<std::string, DirectionModifier> hash = buildHash();
|
||||
return hash.find(bearing)->second;
|
||||
}
|
||||
|
||||
inline DirectionModifier bearingToDirectionModifier(const double angle)
|
||||
{
|
||||
return bearingToDirectionModifier(util::bearing::get(angle));
|
||||
}
|
||||
|
||||
inline bool isHighway(FunctionalRoadClass road_class)
|
||||
{
|
||||
return road_class == FunctionalRoadClass::MOTORWAY || road_class == FunctionalRoadClass::TRUNK;
|
||||
}
|
||||
|
||||
// swaps left <-> right modifier types
|
||||
inline DirectionModifier mirrorDirectionModifier(const DirectionModifier modifier)
|
||||
inline DirectionModifier
|
||||
mirrorDirectionModifier(const DirectionModifier modifier)
|
||||
{
|
||||
const constexpr DirectionModifier results[] = {
|
||||
DirectionModifier::UTurn, DirectionModifier::SharpLeft, DirectionModifier::Left,
|
||||
DirectionModifier::SlightLeft, DirectionModifier::Straight, DirectionModifier::SlightRight,
|
||||
DirectionModifier::Right, DirectionModifier::SharpRight};
|
||||
DirectionModifier::UTurn,
|
||||
DirectionModifier::SharpLeft,
|
||||
DirectionModifier::Left,
|
||||
DirectionModifier::SlightLeft,
|
||||
DirectionModifier::Straight,
|
||||
DirectionModifier::SlightRight,
|
||||
DirectionModifier::Right,
|
||||
DirectionModifier::SharpRight};
|
||||
return results[modifier];
|
||||
}
|
||||
|
||||
@@ -420,7 +333,7 @@ inline bool isLowPriorityRoadClass(const FunctionalRoadClass road_class)
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace engine
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_GUIDANCE_GUIDANCE_TOOLKIT_HPP_
|
||||
#endif // OSRM_GUIDANCE_TOOLKIT_HPP_
|
||||
+51
-24
@@ -1,9 +1,8 @@
|
||||
#ifndef OSRM_EXTRACTOR_TURN_ANALYSIS
|
||||
#define OSRM_EXTRACTOR_TURN_ANALYSIS
|
||||
|
||||
#include "engine/guidance/turn_classification.hpp"
|
||||
#include "engine/guidance/guidance_toolkit.hpp"
|
||||
|
||||
#include "extractor/guidance/turn_classification.hpp"
|
||||
#include "extractor/guidance/toolkit.hpp"
|
||||
#include "extractor/restriction_map.hpp"
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
|
||||
@@ -13,14 +12,16 @@ namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
struct TurnCandidate
|
||||
{
|
||||
EdgeID eid; // the id of the arc
|
||||
bool valid; // a turn may be relevant to good instructions, even if we cannot take the road
|
||||
double angle; // the approximated angle of the turn
|
||||
engine::guidance::TurnInstruction instruction; // a proposed instruction
|
||||
double confidence; // how close to the border is the turn?
|
||||
TurnInstruction instruction; // a proposed instruction
|
||||
double confidence; // how close to the border is the turn?
|
||||
|
||||
std::string toString() const
|
||||
{
|
||||
@@ -38,8 +39,6 @@ struct TurnCandidate
|
||||
return result;
|
||||
}
|
||||
};
|
||||
namespace turn_analysis
|
||||
{
|
||||
|
||||
// the entry into the turn analysis
|
||||
std::vector<TurnCandidate>
|
||||
@@ -57,6 +56,7 @@ namespace detail
|
||||
// Check for restrictions/barriers and generate a list of valid and invalid turns present at the
|
||||
// node reached
|
||||
// from `from_node` via `via_eid`
|
||||
// The resulting candidates have to be analysed for their actual instructions later on.
|
||||
std::vector<TurnCandidate>
|
||||
getTurnCandidates(const NodeID from_node,
|
||||
const EdgeID via_eid,
|
||||
@@ -66,16 +66,27 @@ getTurnCandidates(const NodeID from_node,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const CompressedEdgeContainer &compressed_edge_container);
|
||||
|
||||
// merge segregated roads to omit invalid turns in favor of treating segregated roads as one
|
||||
// Merge segregated roads to omit invalid turns in favor of treating segregated roads as one.
|
||||
// This function combines roads the following way:
|
||||
//
|
||||
// * *
|
||||
// * is converted to *
|
||||
// v ^ +
|
||||
// v ^ +
|
||||
//
|
||||
// The treatment results in a straight turn angle of 180º rather than a turn angle of approx 160
|
||||
std::vector<TurnCandidate>
|
||||
mergeSegregatedRoads(const NodeID from_node,
|
||||
const EdgeID via_eid,
|
||||
std::vector<TurnCandidate> turn_candidates,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// handle roundabouts
|
||||
// TODO distinguish roundabouts and rotaries
|
||||
// TODO handle bike/walk cases that allow crossing a roundabout!
|
||||
|
||||
// Processing of roundabouts
|
||||
// Produces instructions to enter/exit a roundabout or to stay on it.
|
||||
// Performs the distinction between roundabout and rotaries.
|
||||
std::vector<TurnCandidate>
|
||||
handleRoundabouts(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
@@ -85,79 +96,100 @@ handleRoundabouts(const NodeID from,
|
||||
std::vector<TurnCandidate> turn_candidates,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// A Basic junction is a junction not requiring special treatment. It cannot contain anything
|
||||
// but streets of lesser priority than trunks and ramps (of any type). No roundabouts or motorway
|
||||
// like types.
|
||||
bool isBasicJunction(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
const std::vector<TurnCandidate> &turn_candidates,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// Indicates a Junction containing a motoryway
|
||||
bool isMotorwayJunction(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
const std::vector<TurnCandidate> &turn_candidates,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// Decide whether a turn is a turn or a ramp access
|
||||
engine::guidance::TurnType
|
||||
turnOrRamp(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
const TurnCandidate &candidate,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
TurnType turnOrRamp(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
const TurnCandidate &candidate,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// Get the Instruction for an obvious turn
|
||||
engine::guidance::TurnInstruction
|
||||
// Instruction will be a silent instruction
|
||||
TurnInstruction
|
||||
getInstructionForObvious(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
const TurnCandidate &candidate,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
engine::guidance::TurnInstruction
|
||||
// Helper Function that decides between NoTurn or NewName
|
||||
TurnInstruction
|
||||
noTurnOrNewName(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
const TurnCandidate &candidate,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// handle basic intersections
|
||||
// Basic Turn Handling
|
||||
|
||||
// Dead end.
|
||||
std::vector<TurnCandidate>
|
||||
handleOneWayTurn(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
std::vector<TurnCandidate> turn_candidates,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// Mode Changes, new names...
|
||||
std::vector<TurnCandidate>
|
||||
handleTwoWayTurn(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
std::vector<TurnCandidate> turn_candidates,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// Forks, T intersections and similar
|
||||
std::vector<TurnCandidate>
|
||||
handleThreeWayTurn(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
std::vector<TurnCandidate> turn_candidates,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// Normal Intersection. Can still contain forks...
|
||||
std::vector<TurnCandidate>
|
||||
handleFourWayTurn(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
std::vector<TurnCandidate> turn_candidates,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// Fallback for turns of high complexion
|
||||
std::vector<TurnCandidate>
|
||||
handleComplexTurn(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
std::vector<TurnCandidate> turn_candidates,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// Any Junction containing motorways
|
||||
std::vector<TurnCandidate>
|
||||
handleMotorwayJunction(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
std::vector<TurnCandidate> turn_candidates,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// Utility function, setting basic turn types. Prepares for normal turn handling.
|
||||
std::vector<TurnCandidate>
|
||||
setTurnTypes(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
std::vector<TurnCandidate> turn_candidates,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// Utility function to handle direction modifier conflicts if reasonably possible
|
||||
std::vector<TurnCandidate>
|
||||
handleConflicts(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
std::vector<TurnCandidate> turn_candidates,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// Old fallbacks, to be removed
|
||||
std::vector<TurnCandidate>
|
||||
optimizeRamps(const EdgeID via_edge,
|
||||
std::vector<TurnCandidate> turn_candidates,
|
||||
@@ -180,7 +212,7 @@ suppressTurns(const EdgeID via_eid,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
// node_u -- (edge_1) --> node_v -- (edge_2) --> node_w
|
||||
engine::guidance::TurnInstruction
|
||||
TurnInstruction
|
||||
AnalyzeTurn(const NodeID node_u,
|
||||
const EdgeID edge1,
|
||||
const NodeID node_v,
|
||||
@@ -189,13 +221,8 @@ AnalyzeTurn(const NodeID node_u,
|
||||
const double angle,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
|
||||
std::vector<TurnCandidate>
|
||||
handleConflicts(const NodeID from,
|
||||
const EdgeID via_edge,
|
||||
std::vector<TurnCandidate> turn_candidates,
|
||||
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
|
||||
} // namespace detail
|
||||
} // namespace turn_analysis
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
+23
-4
@@ -1,8 +1,7 @@
|
||||
#ifndef OSRM_GUIDANCE_TURN_CLASSIFICATION_HPP_
|
||||
#define OSRM_GUIDANCE_TURN_CLASSIFICATION_HPP_
|
||||
|
||||
#include "engine/guidance/turn_instruction.hpp"
|
||||
#include "engine/guidance/guidance_toolkit.hpp"
|
||||
#include "extractor/guidance/toolkit.hpp"
|
||||
|
||||
#include "util/typedefs.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
@@ -17,7 +16,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
@@ -35,6 +34,26 @@ struct TurnPossibility
|
||||
EdgeID edge_id;
|
||||
};
|
||||
|
||||
struct CompareTurnPossibilities
|
||||
{
|
||||
bool operator()(const std::vector<TurnPossibility> &left,
|
||||
const std::vector<TurnPossibility> &right) const
|
||||
{
|
||||
if (left.size() < right.size())
|
||||
return true;
|
||||
if (left.size() > right.size())
|
||||
return false;
|
||||
for (std::size_t i = 0; i < left.size(); ++i)
|
||||
{
|
||||
if ((((int)left[i].angle + 16) % 256) / 32 < (((int)right[i].angle + 16) % 256) / 32)
|
||||
return true;
|
||||
if ((((int)left[i].angle + 16) % 256) / 32 > (((int)right[i].angle + 16) % 256) / 32)
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
inline std::vector<TurnPossibility>
|
||||
classifyIntersection(NodeID nid,
|
||||
const util::NodeBasedDynamicGraph &graph,
|
||||
@@ -98,7 +117,7 @@ classifyIntersection(NodeID nid,
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace engine
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_GUIDANCE_TURN_CLASSIFICATION_HPP_
|
||||
+4
-57
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
@@ -33,17 +33,6 @@ enum DirectionModifier
|
||||
SharpLeft
|
||||
};
|
||||
|
||||
const constexpr char *modifier_names[detail::num_direction_modifiers] = {
|
||||
"uturn", "sharp right", "right", "slight right",
|
||||
"straight", "slight left", "left", "sharp left"};
|
||||
|
||||
enum LocationType
|
||||
{
|
||||
Start,
|
||||
Intermediate,
|
||||
Destination
|
||||
};
|
||||
|
||||
// enum class TurnType : unsigned char
|
||||
enum TurnType // at the moment we can support 32 turn types, without increasing memory consumption
|
||||
{
|
||||
@@ -71,42 +60,7 @@ enum TurnType // at the moment we can support 32 turn types, without increasing
|
||||
Notification // Travel Mode Changes`
|
||||
};
|
||||
|
||||
inline bool isValidModifier( const TurnType type, const DirectionModifier modifier )
|
||||
{
|
||||
if( type == TurnType::Location &&
|
||||
modifier != DirectionModifier::Left
|
||||
&& modifier != DirectionModifier::Straight
|
||||
&& modifier != DirectionModifier::Right )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
const constexpr char *turn_type_names[] = {"invalid",
|
||||
"no turn",
|
||||
"waypoint",
|
||||
"invalid",
|
||||
"new name",
|
||||
"continue",
|
||||
"turn",
|
||||
"merge",
|
||||
"ramp",
|
||||
"fork",
|
||||
"end of road",
|
||||
"roundabout",
|
||||
"invalid",
|
||||
"roundabout",
|
||||
"invalid",
|
||||
"traffic circle",
|
||||
"invalid",
|
||||
"traffic circle",
|
||||
"invalid",
|
||||
"invalid",
|
||||
"restriction",
|
||||
"notification"};
|
||||
|
||||
// turn angle in 1.40625 degree -> 128 == 180 degree
|
||||
typedef uint8_t DiscreteAngle;
|
||||
|
||||
struct TurnInstruction
|
||||
{
|
||||
TurnInstruction(const TurnType type = TurnType::Invalid,
|
||||
@@ -135,7 +89,7 @@ struct TurnInstruction
|
||||
|
||||
static TurnInstruction ENTER_ROUNDABOUT(const DirectionModifier modifier)
|
||||
{
|
||||
return TurnInstruction(TurnType::EnterRoundabout, modifier);
|
||||
return TurnInstruction(TurnType::EnterRoundabout, modifier);
|
||||
}
|
||||
|
||||
static TurnInstruction EXIT_ROUNDABOUT(const DirectionModifier modifier)
|
||||
@@ -145,7 +99,7 @@ struct TurnInstruction
|
||||
|
||||
static TurnInstruction SUPPRESSED(const DirectionModifier modifier)
|
||||
{
|
||||
return TurnInstruction{TurnType::Suppressed,modifier};
|
||||
return TurnInstruction{TurnType::Suppressed, modifier};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -159,15 +113,8 @@ inline bool operator==(const TurnInstruction lhs, const TurnInstruction rhs)
|
||||
return lhs.type == rhs.type && lhs.direction_modifier == rhs.direction_modifier;
|
||||
}
|
||||
|
||||
// Silent Turn Instructions are not to be mentioned to the outside world
|
||||
inline bool isSilent(const TurnInstruction instruction)
|
||||
{
|
||||
return instruction.type == TurnType::NoTurn || instruction.type == TurnType::Suppressed ||
|
||||
instruction.type == TurnType::StayOnRoundabout;
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace engine
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_GUIDANCE_TURN_INSTRUCTION_HPP_
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include <utility>
|
||||
#include "engine/guidance/classification_data.hpp"
|
||||
#include "extractor/guidance/classification_data.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -52,7 +52,7 @@ struct InternalExtractorEdge
|
||||
true,
|
||||
TRAVEL_MODE_INACCESSIBLE,
|
||||
false,
|
||||
engine::guidance::RoadClassificationData::INVALID())
|
||||
guidance::RoadClassificationData())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ struct InternalExtractorEdge
|
||||
bool startpoint,
|
||||
TravelMode travel_mode,
|
||||
bool is_split,
|
||||
engine::guidance::RoadClassificationData road_classification)
|
||||
guidance::RoadClassificationData road_classification)
|
||||
: result(OSMNodeID(source),
|
||||
OSMNodeID(target),
|
||||
name_id,
|
||||
@@ -96,13 +96,13 @@ struct InternalExtractorEdge
|
||||
{
|
||||
return InternalExtractorEdge(MIN_OSM_NODEID, MIN_OSM_NODEID, 0, WeightData(), false, false,
|
||||
false, false, true, TRAVEL_MODE_INACCESSIBLE, false,
|
||||
engine::guidance::RoadClassificationData::INVALID());
|
||||
guidance::RoadClassificationData());
|
||||
}
|
||||
static InternalExtractorEdge max_osm_value()
|
||||
{
|
||||
return InternalExtractorEdge(MAX_OSM_NODEID, MAX_OSM_NODEID, 0, WeightData(), false, false,
|
||||
false, false, true, TRAVEL_MODE_INACCESSIBLE, false,
|
||||
engine::guidance::RoadClassificationData::INVALID());
|
||||
guidance::RoadClassificationData());
|
||||
}
|
||||
|
||||
static InternalExtractorEdge min_internal_value()
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "extractor/travel_mode.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include "engine/guidance/classification_data.hpp"
|
||||
#include "extractor/guidance/classification_data.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -26,7 +26,7 @@ struct NodeBasedEdge
|
||||
bool startpoint,
|
||||
TravelMode travel_mode,
|
||||
bool is_split,
|
||||
engine::guidance::RoadClassificationData road_classification);
|
||||
guidance::RoadClassificationData road_classification);
|
||||
|
||||
bool operator<(const NodeBasedEdge &other) const;
|
||||
|
||||
@@ -41,7 +41,7 @@ struct NodeBasedEdge
|
||||
bool startpoint : 1;
|
||||
bool is_split : 1;
|
||||
TravelMode travel_mode : 4;
|
||||
engine::guidance::RoadClassificationData road_classification;
|
||||
guidance::RoadClassificationData road_classification;
|
||||
};
|
||||
|
||||
struct NodeBasedEdgeWithOSM : NodeBasedEdge
|
||||
@@ -57,7 +57,7 @@ struct NodeBasedEdgeWithOSM : NodeBasedEdge
|
||||
bool startpoint,
|
||||
TravelMode travel_mode,
|
||||
bool is_split,
|
||||
engine::guidance::RoadClassificationData road_classification);
|
||||
guidance::RoadClassificationData road_classification);
|
||||
|
||||
OSMNodeID osm_source_id;
|
||||
OSMNodeID osm_target_id;
|
||||
@@ -70,7 +70,6 @@ inline NodeBasedEdge::NodeBasedEdge()
|
||||
backward(false), roundabout(false), access_restricted(false), startpoint(true),
|
||||
is_split(false), travel_mode(false)
|
||||
{
|
||||
road_classification.invalidate();
|
||||
}
|
||||
|
||||
inline NodeBasedEdge::NodeBasedEdge(NodeID source,
|
||||
@@ -84,7 +83,7 @@ inline NodeBasedEdge::NodeBasedEdge(NodeID source,
|
||||
bool startpoint,
|
||||
TravelMode travel_mode,
|
||||
bool is_split,
|
||||
engine::guidance::RoadClassificationData road_classification)
|
||||
guidance::RoadClassificationData road_classification)
|
||||
: source(source), target(target), name_id(name_id), weight(weight), forward(forward),
|
||||
backward(backward), roundabout(roundabout), access_restricted(access_restricted),
|
||||
startpoint(startpoint), is_split(is_split), travel_mode(travel_mode),
|
||||
@@ -121,7 +120,7 @@ inline NodeBasedEdgeWithOSM::NodeBasedEdgeWithOSM(
|
||||
bool startpoint,
|
||||
TravelMode travel_mode,
|
||||
bool is_split,
|
||||
engine::guidance::RoadClassificationData road_classification)
|
||||
guidance::RoadClassificationData road_classification)
|
||||
: NodeBasedEdge(SPECIAL_NODEID,
|
||||
SPECIAL_NODEID,
|
||||
name_id,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define ORIGINAL_EDGE_DATA_HPP
|
||||
|
||||
#include "extractor/travel_mode.hpp"
|
||||
#include "engine/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <limits>
|
||||
@@ -16,7 +16,7 @@ struct OriginalEdgeData
|
||||
{
|
||||
explicit OriginalEdgeData(NodeID via_node,
|
||||
unsigned name_id,
|
||||
engine::guidance::TurnInstruction turn_instruction,
|
||||
guidance::TurnInstruction turn_instruction,
|
||||
TravelMode travel_mode)
|
||||
: via_node(via_node), name_id(name_id), turn_instruction(turn_instruction),
|
||||
travel_mode(travel_mode)
|
||||
@@ -26,14 +26,14 @@ struct OriginalEdgeData
|
||||
OriginalEdgeData()
|
||||
: via_node(std::numeric_limits<unsigned>::max()),
|
||||
name_id(std::numeric_limits<unsigned>::max()),
|
||||
turn_instruction(engine::guidance::TurnInstruction::INVALID()),
|
||||
turn_instruction(guidance::TurnInstruction::INVALID()),
|
||||
travel_mode(TRAVEL_MODE_INACCESSIBLE)
|
||||
{
|
||||
}
|
||||
|
||||
NodeID via_node;
|
||||
unsigned name_id;
|
||||
engine::guidance::TurnInstruction turn_instruction;
|
||||
guidance::TurnInstruction turn_instruction;
|
||||
TravelMode travel_mode;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -58,7 +58,9 @@ double bearing(const Coordinate first_coordinate, const Coordinate second_coordi
|
||||
// Get angle of line segment (A,C)->(C,B)
|
||||
double computeAngle(const Coordinate first, const Coordinate second, const Coordinate third);
|
||||
|
||||
Coordinate interpolateLinear( double factor, const Coordinate from, const Coordinate to );
|
||||
// factor in [0,1]. Returns point along the straight line between from and to. 0 returns from, 1
|
||||
// returns to
|
||||
Coordinate interpolateLinear(double factor, const Coordinate from, const Coordinate to);
|
||||
|
||||
namespace mercator
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "util/dynamic_graph.hpp"
|
||||
#include "extractor/node_based_edge.hpp"
|
||||
#include "util/graph_utils.hpp"
|
||||
#include "engine/guidance/classification_data.hpp"
|
||||
#include "extractor/guidance/classification_data.hpp"
|
||||
|
||||
#include <tbb/parallel_sort.h>
|
||||
|
||||
@@ -46,13 +46,15 @@ struct NodeBasedEdgeData
|
||||
bool roundabout : 1;
|
||||
bool startpoint : 1;
|
||||
extractor::TravelMode travel_mode : 4;
|
||||
engine::guidance::RoadClassificationData road_classification;
|
||||
extractor::guidance::RoadClassificationData road_classification;
|
||||
|
||||
bool IsCompatibleTo(const NodeBasedEdgeData &other) const
|
||||
{
|
||||
//TODO roundabout/startpoint/access_restricted should all be part of this??
|
||||
return (reversed == other.reversed) && (name_id == other.name_id) &&
|
||||
(travel_mode == other.travel_mode && road_classification == other.road_classification);
|
||||
return (name_id == other.name_id) && (reversed == other.reversed) &&
|
||||
(roundabout == other.roundabout) && (startpoint == other.startpoint) &&
|
||||
(access_restricted == other.access_restricted) &&
|
||||
(travel_mode == other.travel_mode) &&
|
||||
(road_classification == other.road_classification);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user