Skip to content

Commit

Permalink
Split intersection analysis and guidance code
Browse files Browse the repository at this point in the history
Intersection analysis occupy in osrm::extractor::intersection namespace
and guidance code osrm::guidance
  • Loading branch information
oxidase committed Jan 23, 2018
1 parent af7b005 commit e244072
Show file tree
Hide file tree
Showing 100 changed files with 1,399 additions and 1,367 deletions.
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ add_executable(osrm-routed src/tools/routed.cpp $<TARGET_OBJECTS:SERVER> $<TARGE
add_executable(osrm-datastore src/tools/store.cpp $<TARGET_OBJECTS:UTIL>)
add_library(osrm src/osrm/osrm.cpp $<TARGET_OBJECTS:ENGINE> $<TARGET_OBJECTS:UTIL> $<TARGET_OBJECTS:STORAGE>)
add_library(osrm_contract src/osrm/contractor.cpp $<TARGET_OBJECTS:CONTRACTOR> $<TARGET_OBJECTS:UTIL>)
add_library(osrm_extract src/osrm/extractor.cpp $<TARGET_OBJECTS:GUIDANCE> $<TARGET_OBJECTS:EXTRACTOR> $<TARGET_OBJECTS:UTIL>)
add_library(osrm_extract src/osrm/extractor.cpp $<TARGET_OBJECTS:EXTRACTOR> $<TARGET_OBJECTS:UTIL>)
add_library(osrm_guidance $<TARGET_OBJECTS:GUIDANCE> $<TARGET_OBJECTS:UTIL>)
add_library(osrm_partition $<TARGET_OBJECTS:PARTITIONER> $<TARGET_OBJECTS:UTIL>)
add_library(osrm_customize $<TARGET_OBJECTS:CUSTOMIZER> $<TARGET_OBJECTS:UTIL>)
add_library(osrm_update $<TARGET_OBJECTS:UPDATER> $<TARGET_OBJECTS:UTIL>)
Expand Down Expand Up @@ -608,7 +609,7 @@ set(BOOST_ENGINE_LIBRARIES

# Binaries
target_link_libraries(osrm-datastore osrm_store ${Boost_PROGRAM_OPTIONS_LIBRARY})
target_link_libraries(osrm-extract osrm_extract ${Boost_PROGRAM_OPTIONS_LIBRARY})
target_link_libraries(osrm-extract osrm_extract osrm_guidance ${Boost_PROGRAM_OPTIONS_LIBRARY})
target_link_libraries(osrm-partition osrm_partition ${Boost_PROGRAM_OPTIONS_LIBRARY})
target_link_libraries(osrm-customize osrm_customize ${Boost_PROGRAM_OPTIONS_LIBRARY})
target_link_libraries(osrm-contract osrm_contract ${Boost_PROGRAM_OPTIONS_LIBRARY})
Expand All @@ -626,6 +627,12 @@ set(EXTRACTOR_LIBRARIES
${TBB_LIBRARIES}
${ZLIB_LIBRARY}
${MAYBE_COVERAGE_LIBRARIES})
set(GUIDANCE_LIBRARIES
${BOOST_BASE_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${USED_LUA_LIBRARIES}
${TBB_LIBRARIES}
${MAYBE_COVERAGE_LIBRARIES})
set(PARTITIONER_LIBRARIES
${BOOST_ENGINE_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
Expand Down
35 changes: 17 additions & 18 deletions include/engine/datafacade/contiguous_internalmem_datafacade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#include "extractor/packed_osm_ids.hpp"
#include "extractor/profile_properties.hpp"
#include "extractor/segment_data_container.hpp"
#include "extractor/turn_data_container.hpp"
#include "extractor/turn_lane_types.hpp"
#include "guidance/turn_data_container.hpp"
#include "guidance/turn_instruction.hpp"
#include "guidance/turn_lane_types.hpp"

#include "contractor/query_graph.hpp"

Expand Down Expand Up @@ -192,12 +192,12 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
util::vector_view<util::Coordinate> m_coordinate_list;
extractor::PackedOSMIDsView m_osmnodeid_list;
util::vector_view<std::uint32_t> m_lane_description_offsets;
util::vector_view<extractor::guidance::TurnLaneType::Mask> m_lane_description_masks;
util::vector_view<extractor::TurnLaneType::Mask> m_lane_description_masks;
util::vector_view<TurnPenalty> m_turn_weight_penalties;
util::vector_view<TurnPenalty> m_turn_duration_penalties;
extractor::SegmentDataView segment_data;
extractor::TurnDataView turn_data;
extractor::EdgeBasedNodeDataView edge_based_node_data;
guidance::TurnDataView turn_data;

util::vector_view<char> m_datasource_name_data;
util::vector_view<std::size_t> m_datasource_name_offsets;
Expand Down Expand Up @@ -318,10 +318,9 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
util::vector_view<LaneDataID> lane_data_ids(
lane_data_id_ptr, layout.num_entries[storage::DataLayout::LANE_DATA_ID]);

const auto turn_instruction_list_ptr =
layout.GetBlockPtr<extractor::guidance::TurnInstruction>(
memory_ptr, storage::DataLayout::TURN_INSTRUCTION);
util::vector_view<extractor::guidance::TurnInstruction> turn_instructions(
const auto turn_instruction_list_ptr = layout.GetBlockPtr<guidance::TurnInstruction>(
memory_ptr, storage::DataLayout::TURN_INSTRUCTION);
util::vector_view<guidance::TurnInstruction> turn_instructions(
turn_instruction_list_ptr, layout.num_entries[storage::DataLayout::TURN_INSTRUCTION]);

const auto entry_class_id_list_ptr =
Expand All @@ -339,11 +338,11 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
util::vector_view<util::guidance::TurnBearing> post_turn_bearings(
post_turn_bearing_ptr, layout.num_entries[storage::DataLayout::POST_TURN_BEARING]);

turn_data = extractor::TurnDataView(std::move(turn_instructions),
std::move(lane_data_ids),
std::move(entry_class_ids),
std::move(pre_turn_bearings),
std::move(post_turn_bearings));
turn_data = guidance::TurnDataView(std::move(turn_instructions),
std::move(lane_data_ids),
std::move(entry_class_ids),
std::move(pre_turn_bearings),
std::move(post_turn_bearings));
}

void InitializeNamePointers(storage::DataLayout &data_layout, char *memory_block)
Expand All @@ -363,10 +362,10 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
offsets_ptr, data_layout.num_entries[storage::DataLayout::LANE_DESCRIPTION_OFFSETS]);
m_lane_description_offsets = std::move(offsets);

auto masks_ptr = data_layout.GetBlockPtr<extractor::guidance::TurnLaneType::Mask>(
auto masks_ptr = data_layout.GetBlockPtr<extractor::TurnLaneType::Mask>(
memory_block, storage::DataLayout::LANE_DESCRIPTION_MASKS);

util::vector_view<extractor::guidance::TurnLaneType::Mask> masks(
util::vector_view<extractor::TurnLaneType::Mask> masks(
masks_ptr, data_layout.num_entries[storage::DataLayout::LANE_DESCRIPTION_MASKS]);
m_lane_description_masks = std::move(masks);

Expand Down Expand Up @@ -609,7 +608,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
return m_turn_duration_penalties[id];
}

extractor::guidance::TurnInstruction
osrm::guidance::TurnInstruction
GetTurnInstructionForEdgeID(const EdgeID id) const override final
{
return turn_data.GetTurnInstruction(id);
Expand Down Expand Up @@ -868,13 +867,13 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
return m_lane_tupel_id_pairs.at(turn_data.GetLaneDataID(id));
}

extractor::guidance::TurnLaneDescription
extractor::TurnLaneDescription
GetTurnDescription(const LaneDescriptionID lane_description_id) const override final
{
if (lane_description_id == INVALID_LANE_DESCRIPTIONID)
return {};
else
return extractor::guidance::TurnLaneDescription(
return extractor::TurnLaneDescription(
m_lane_description_masks.begin() + m_lane_description_offsets[lane_description_id],
m_lane_description_masks.begin() +
m_lane_description_offsets[lane_description_id + 1]);
Expand Down
8 changes: 3 additions & 5 deletions include/engine/datafacade/datafacade_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@

#include "extractor/class_data.hpp"
#include "extractor/edge_based_node_segment.hpp"
#include "extractor/original_edge_data.hpp"
#include "extractor/query_node.hpp"
#include "extractor/travel_mode.hpp"
#include "extractor/turn_lane_types.hpp"
#include "guidance/turn_instruction.hpp"
#include "guidance/turn_lane_types.hpp"

#include "util/exception.hpp"
#include "util/guidance/bearing_class.hpp"
Expand Down Expand Up @@ -87,8 +86,7 @@ class BaseDataFacade
// Gets the name of a datasource
virtual StringView GetDatasourceName(const DatasourceID id) const = 0;

virtual extractor::guidance::TurnInstruction
GetTurnInstructionForEdgeID(const EdgeID id) const = 0;
virtual osrm::guidance::TurnInstruction GetTurnInstructionForEdgeID(const EdgeID id) const = 0;

virtual extractor::TravelMode GetTravelMode(const NodeID id) const = 0;

Expand Down Expand Up @@ -156,7 +154,7 @@ class BaseDataFacade

virtual bool HasLaneData(const EdgeID id) const = 0;
virtual util::guidance::LaneTupleIdPair GetLaneData(const EdgeID id) const = 0;
virtual extractor::guidance::TurnLaneDescription
virtual extractor::TurnLaneDescription
GetTurnDescription(const LaneDescriptionID lane_description_id) const = 0;

virtual NameID GetNameIndex(const NodeID id) const = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/engine/guidance/assemble_geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
cumulative_distance += current_distance;

// all changes to this check have to be matched with assemble_steps
if (path_point.turn_instruction.type != extractor::guidance::TurnType::NoTurn)
if (path_point.turn_instruction.type != osrm::guidance::TurnType::NoTurn)
{
geometry.segment_distances.push_back(cumulative_distance);
geometry.segment_offsets.push_back(geometry.locations.size());
Expand Down
10 changes: 5 additions & 5 deletions include/engine/guidance/assemble_steps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define ENGINE_GUIDANCE_ASSEMBLE_STEPS_HPP_

#include "extractor/travel_mode.hpp"
#include "extractor/turn_lane_types.hpp"
#include "guidance/turn_instruction.hpp"
#include "guidance/turn_lane_types.hpp"
#include "engine/datafacade/datafacade_base.hpp"
#include "engine/guidance/leg_geometry.hpp"
#include "engine/guidance/route_step.hpp"
Expand Down Expand Up @@ -83,7 +83,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
StepManeuver maneuver{source_node.location,
bearings.first,
bearings.second,
extractor::guidance::TurnInstruction::NO_TURN(),
osrm::guidance::TurnInstruction::NO_TURN(),
WaypointType::Depart,
0};

Expand Down Expand Up @@ -115,7 +115,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
segment_weight += path_point.weight_until_turn;

// all changes to this check have to be matched with assemble_geometry
if (path_point.turn_instruction.type != extractor::guidance::TurnType::NoTurn)
if (path_point.turn_instruction.type != osrm::guidance::TurnType::NoTurn)
{
BOOST_ASSERT(segment_weight >= 0);
const auto name = facade.GetNameForID(step_name_id);
Expand Down Expand Up @@ -171,7 +171,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
intersection.lane_description =
path_point.lane_data.second != INVALID_LANE_DESCRIPTIONID
? facade.GetTurnDescription(path_point.lane_data.second)
: extractor::guidance::TurnLaneDescription();
: extractor::TurnLaneDescription();

// Lanes in turn are bound by total number of lanes at the location
BOOST_ASSERT(intersection.lanes.lanes_in_turn <=
Expand Down Expand Up @@ -290,7 +290,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
maneuver = {intersection.location,
bearings.first,
bearings.second,
extractor::guidance::TurnInstruction::NO_TURN(),
osrm::guidance::TurnInstruction::NO_TURN(),
WaypointType::Arrive,
0};

Expand Down
4 changes: 2 additions & 2 deletions include/engine/guidance/collapse_turns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ struct AdjustToCombinedTurnStrategy : CombineStrategy
// Set a fixed instruction type
struct SetFixedInstructionStrategy : CombineStrategy
{
SetFixedInstructionStrategy(const extractor::guidance::TurnInstruction instruction);
SetFixedInstructionStrategy(const osrm::guidance::TurnInstruction instruction);
void operator()(RouteStep &step_at_turn_location, const RouteStep &transfer_from_step) const;

const extractor::guidance::TurnInstruction instruction;
const osrm::guidance::TurnInstruction instruction;
};

// Handling of staggered intersections
Expand Down
22 changes: 10 additions & 12 deletions include/engine/guidance/collapsing_utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#include <boost/range/algorithm_ext/erase.hpp>
#include <cstddef>

using osrm::extractor::guidance::TurnInstruction;
using namespace osrm::extractor::guidance;

namespace osrm
{
namespace engine
Expand All @@ -30,7 +27,7 @@ const constexpr double NAME_SEGMENT_CUTOFF_LENGTH = 105.0;
// check if a step is completely without turn type
inline bool hasTurnType(const RouteStep &step)
{
return step.maneuver.instruction.type != TurnType::NoTurn;
return step.maneuver.instruction.type != osrm::guidance::TurnType::NoTurn;
}
inline bool hasWaypointType(const RouteStep &step)
{
Expand Down Expand Up @@ -67,12 +64,13 @@ inline RouteStepIterator findNextTurn(RouteStepIterator current_step)
}

// alias for comparisons
inline bool hasTurnType(const RouteStep &step, const TurnType::Enum type)
inline bool hasTurnType(const RouteStep &step, const osrm::guidance::TurnType::Enum type)
{
return type == step.maneuver.instruction.type;
}
// alias for comparisons
inline bool hasModifier(const RouteStep &step, const DirectionModifier::Enum modifier)
inline bool hasModifier(const RouteStep &step,
const osrm::guidance::DirectionModifier::Enum modifier)
{
return modifier == step.maneuver.instruction.direction_modifier;
}
Expand All @@ -96,12 +94,12 @@ inline std::size_t numberOfAllowedTurns(const RouteStep &step)
// fulfill:
inline bool isTrafficLightStep(const RouteStep &step)
{
return hasTurnType(step, TurnType::Suppressed) && numberOfAvailableTurns(step) == 2 &&
numberOfAllowedTurns(step) == 1;
return hasTurnType(step, osrm::guidance::TurnType::Suppressed) &&
numberOfAvailableTurns(step) == 2 && numberOfAllowedTurns(step) == 1;
}

// alias for readability
inline void setInstructionType(RouteStep &step, const TurnType::Enum type)
inline void setInstructionType(RouteStep &step, const osrm::guidance::TurnType::Enum type)
{
step.maneuver.instruction.type = type;
}
Expand Down Expand Up @@ -151,12 +149,12 @@ inline bool haveSameName(const RouteStep &lhs, const RouteStep &rhs)
inline bool areSameSide(const RouteStep &lhs, const RouteStep &rhs)
{
const auto is_left = [](const RouteStep &step) {
return hasModifier(step, DirectionModifier::Straight) ||
return hasModifier(step, osrm::guidance::DirectionModifier::Straight) ||
hasLeftModifier(step.maneuver.instruction);
};

const auto is_right = [](const RouteStep &step) {
return hasModifier(step, DirectionModifier::Straight) ||
return hasModifier(step, osrm::guidance::DirectionModifier::Straight) ||
hasRightModifier(step.maneuver.instruction);
};

Expand All @@ -174,7 +172,7 @@ inline std::vector<RouteStep> removeNoTurnInstructions(std::vector<RouteStep> st

// keep valid instructions
const auto not_is_valid = [](const RouteStep &step) {
return step.maneuver.instruction == TurnInstruction::NO_TURN() &&
return step.maneuver.instruction == osrm::guidance::TurnInstruction::NO_TURN() &&
step.maneuver.waypoint_type == WaypointType::None;
};

Expand Down
4 changes: 2 additions & 2 deletions include/engine/guidance/route_step.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"

#include "guidance/turn_lane_types.hpp"
#include "extractor/turn_lane_types.hpp"
#include "util/guidance/turn_lanes.hpp"

#include <cstddef>
Expand Down Expand Up @@ -41,7 +41,7 @@ struct IntermediateIntersection

// turn lane information
util::guidance::LaneTuple lanes;
extractor::guidance::TurnLaneDescription lane_description;
extractor::TurnLaneDescription lane_description;
std::vector<std::string> classes;
};

Expand Down
4 changes: 2 additions & 2 deletions include/engine/guidance/step_maneuver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct StepManeuver
util::Coordinate location;
short bearing_before;
short bearing_after;
extractor::guidance::TurnInstruction instruction;
osrm::guidance::TurnInstruction instruction;

WaypointType waypoint_type;
unsigned exit;
Expand All @@ -39,7 +39,7 @@ inline StepManeuver getInvalidStepManeuver()
return {util::Coordinate{util::FloatLongitude{0.0}, util::FloatLatitude{0.0}},
0,
0,
extractor::guidance::TurnInstruction::NO_TURN(),
osrm::guidance::TurnInstruction::NO_TURN(),
WaypointType::None,
0};
}
Expand Down
2 changes: 1 addition & 1 deletion include/engine/internal_route_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct PathData
// will contain the duration of the turn. Otherwise it will be 0.
EdgeWeight duration_of_turn;
// instruction to execute at the turn
extractor::guidance::TurnInstruction turn_instruction;
osrm::guidance::TurnInstruction turn_instruction;
// turn lane data
util::guidance::LaneTupleIdPair lane_data;
// travel mode of the street that leads to the turn
Expand Down
4 changes: 2 additions & 2 deletions include/engine/routing_algorithms/routing_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void annotatePath(const FacadeT &facade,
0,
duration_vector[segment_idx],
0,
extractor::guidance::TurnInstruction::NO_TURN(),
guidance::TurnInstruction::NO_TURN(),
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
travel_mode,
classes,
Expand Down Expand Up @@ -273,7 +273,7 @@ void annotatePath(const FacadeT &facade,
0,
duration_vector[segment_idx],
0,
extractor::guidance::TurnInstruction::NO_TURN(),
guidance::TurnInstruction::NO_TURN(),
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
facade.GetTravelMode(target_node_id),
facade.GetClassData(target_node_id),
Expand Down
2 changes: 1 addition & 1 deletion include/engine/routing_algorithms/tile_turns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct TurnData final
const int turn_angle;
const EdgeWeight weight;
const EdgeWeight duration;
const extractor::guidance::TurnInstruction turn_instruction;
const guidance::TurnInstruction turn_instruction;
};

using RTreeLeaf = datafacade::BaseDataFacade::RTreeLeaf;
Expand Down
Loading

0 comments on commit e244072

Please sign in to comment.