From f2757e5cf5c18a8d1ee0d37d2ffe61b8bbcd1865 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Tue, 16 Jan 2018 12:57:16 +0100 Subject: [PATCH] Review comments --- .../contiguous_internalmem_datafacade.hpp | 15 ++- include/engine/datafacade/datafacade_base.hpp | 7 +- include/engine/internal_route_result.hpp | 7 +- .../routing_algorithms/routing_base.hpp | 10 +- .../intersection/mergable_road_detector.hpp | 2 +- .../intersection/node_based_graph_walker.hpp | 2 +- include/extractor/turn_data_container.hpp.tbd | 123 ------------------ include/guidance/guidance_processing.hpp | 32 ++--- ...segregated_intersection_classification.hpp | 4 +- include/guidance/turn_bearing.hpp | 38 ++++++ include/guidance/turn_data_container.hpp | 30 ++--- include/util/guidance/turn_bearing.hpp | 30 ----- src/extractor/edge_based_graph_factory.cpp | 1 - src/extractor/extractor.cpp | 33 ++--- .../intersection/coordinate_extractor.cpp | 2 +- .../intersection/mergable_road_detector.cpp | 2 +- src/guidance/guidance_processing.cpp | 44 +++---- ...segregated_intersection_classification.cpp | 14 +- src/storage/storage.cpp | 16 +-- src/util/guidance/bearing_class.cpp | 2 +- src/util/guidance/entry_class.cpp | 2 +- src/util/guidance/turn_bearing.cpp | 25 ---- unit_tests/engine/offline_facade.cpp | 8 +- unit_tests/mocks/mock_datafacade.hpp | 10 +- 24 files changed, 158 insertions(+), 301 deletions(-) delete mode 100644 include/extractor/turn_data_container.hpp.tbd create mode 100644 include/guidance/turn_bearing.hpp delete mode 100644 include/util/guidance/turn_bearing.hpp delete mode 100644 src/util/guidance/turn_bearing.cpp diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index 716d8926a8a..6ad1a18afb4 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -19,6 +19,8 @@ #include "extractor/profile_properties.hpp" #include "extractor/segment_data_container.hpp" #include "extractor/turn_lane_types.hpp" + +#include "guidance/turn_bearing.hpp" #include "guidance/turn_data_container.hpp" #include "guidance/turn_instruction.hpp" @@ -35,7 +37,6 @@ #include "util/filtered_graph.hpp" #include "util/guidance/bearing_class.hpp" #include "util/guidance/entry_class.hpp" -#include "util/guidance/turn_bearing.hpp" #include "util/guidance/turn_lanes.hpp" #include "util/log.hpp" #include "util/name_table.hpp" @@ -328,14 +329,14 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade util::vector_view entry_class_ids( entry_class_id_list_ptr, layout.num_entries[storage::DataLayout::ENTRY_CLASSID]); - const auto pre_turn_bearing_ptr = layout.GetBlockPtr( + const auto pre_turn_bearing_ptr = layout.GetBlockPtr( memory_ptr, storage::DataLayout::PRE_TURN_BEARING); - util::vector_view pre_turn_bearings( + util::vector_view pre_turn_bearings( pre_turn_bearing_ptr, layout.num_entries[storage::DataLayout::PRE_TURN_BEARING]); - const auto post_turn_bearing_ptr = layout.GetBlockPtr( + const auto post_turn_bearing_ptr = layout.GetBlockPtr( memory_ptr, storage::DataLayout::POST_TURN_BEARING); - util::vector_view post_turn_bearings( + util::vector_view post_turn_bearings( post_turn_bearing_ptr, layout.num_entries[storage::DataLayout::POST_TURN_BEARING]); turn_data = guidance::TurnDataView(std::move(turn_instructions), @@ -844,11 +845,11 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade return intersection_bearings_view.GetBearingClass(node); } - util::guidance::TurnBearing PreTurnBearing(const EdgeID eid) const override final + guidance::TurnBearing PreTurnBearing(const EdgeID eid) const override final { return turn_data.GetPreTurnBearing(eid); } - util::guidance::TurnBearing PostTurnBearing(const EdgeID eid) const override final + guidance::TurnBearing PostTurnBearing(const EdgeID eid) const override final { return turn_data.GetPostTurnBearing(eid); } diff --git a/include/engine/datafacade/datafacade_base.hpp b/include/engine/datafacade/datafacade_base.hpp index 8eb42686120..de1ab10c5f2 100644 --- a/include/engine/datafacade/datafacade_base.hpp +++ b/include/engine/datafacade/datafacade_base.hpp @@ -13,12 +13,13 @@ #include "extractor/query_node.hpp" #include "extractor/travel_mode.hpp" #include "extractor/turn_lane_types.hpp" + +#include "guidance/turn_bearing.hpp" #include "guidance/turn_instruction.hpp" #include "util/exception.hpp" #include "util/guidance/bearing_class.hpp" #include "util/guidance/entry_class.hpp" -#include "util/guidance/turn_bearing.hpp" #include "util/guidance/turn_lanes.hpp" #include "util/integer_range.hpp" #include "util/string_util.hpp" @@ -181,8 +182,8 @@ class BaseDataFacade virtual double GetWeightMultiplier() const = 0; - virtual util::guidance::TurnBearing PreTurnBearing(const EdgeID eid) const = 0; - virtual util::guidance::TurnBearing PostTurnBearing(const EdgeID eid) const = 0; + virtual osrm::guidance::TurnBearing PreTurnBearing(const EdgeID eid) const = 0; + virtual osrm::guidance::TurnBearing PostTurnBearing(const EdgeID eid) const = 0; virtual util::guidance::BearingClass GetBearingClass(const NodeID node) const = 0; diff --git a/include/engine/internal_route_result.hpp b/include/engine/internal_route_result.hpp index bf30032293f..f3cdf7100bf 100644 --- a/include/engine/internal_route_result.hpp +++ b/include/engine/internal_route_result.hpp @@ -3,13 +3,14 @@ #include "extractor/class_data.hpp" #include "extractor/travel_mode.hpp" + +#include "guidance/turn_bearing.hpp" #include "guidance/turn_instruction.hpp" #include "engine/phantom_node.hpp" #include "util/coordinate.hpp" #include "util/guidance/entry_class.hpp" -#include "util/guidance/turn_bearing.hpp" #include "util/guidance/turn_lanes.hpp" #include "util/integer_range.hpp" #include "util/typedefs.hpp" @@ -56,9 +57,9 @@ struct PathData DatasourceID datasource_id; // bearing (as seen from the intersection) pre-turn - util::guidance::TurnBearing pre_turn_bearing; + osrm::guidance::TurnBearing pre_turn_bearing; // bearing (as seen from the intersection) post-turn - util::guidance::TurnBearing post_turn_bearing; + osrm::guidance::TurnBearing post_turn_bearing; // Driving side of the turn bool is_left_hand_driving; diff --git a/include/engine/routing_algorithms/routing_base.hpp b/include/engine/routing_algorithms/routing_base.hpp index 087a8e98fed..b9fa5425ffe 100644 --- a/include/engine/routing_algorithms/routing_base.hpp +++ b/include/engine/routing_algorithms/routing_base.hpp @@ -1,6 +1,7 @@ #ifndef OSRM_ENGINE_ROUTING_BASE_HPP #define OSRM_ENGINE_ROUTING_BASE_HPP +#include "guidance/turn_bearing.hpp" #include "guidance/turn_instruction.hpp" #include "engine/algorithm.hpp" @@ -10,7 +11,6 @@ #include "engine/search_engine_data.hpp" #include "util/coordinate_calculation.hpp" -#include "util/guidance/turn_bearing.hpp" #include "util/typedefs.hpp" #include @@ -205,8 +205,8 @@ void annotatePath(const FacadeT &facade, classes, EMPTY_ENTRY_CLASS, datasource_vector[segment_idx], - util::guidance::TurnBearing(0), - util::guidance::TurnBearing(0), + osrm::guidance::TurnBearing(0), + osrm::guidance::TurnBearing(0), is_left_hand_driving}); } BOOST_ASSERT(unpacked_path.size() > 0); @@ -279,8 +279,8 @@ void annotatePath(const FacadeT &facade, facade.GetClassData(target_node_id), EMPTY_ENTRY_CLASS, datasource_vector[segment_idx], - util::guidance::TurnBearing(0), - util::guidance::TurnBearing(0), + guidance::TurnBearing(0), + guidance::TurnBearing(0), is_target_left_hand_driving}); } diff --git a/include/extractor/intersection/mergable_road_detector.hpp b/include/extractor/intersection/mergable_road_detector.hpp index 69d9f7fe535..b53bf635870 100644 --- a/include/extractor/intersection/mergable_road_detector.hpp +++ b/include/extractor/intersection/mergable_road_detector.hpp @@ -177,7 +177,7 @@ class MergableRoadDetector const static double constexpr distance_to_extract = 120; }; -} // namespace guidance +} // namespace intersection } // namespace extractor } // namespace osrm diff --git a/include/extractor/intersection/node_based_graph_walker.hpp b/include/extractor/intersection/node_based_graph_walker.hpp index 0fe03ebeb51..64f6a0b80ba 100644 --- a/include/extractor/intersection/node_based_graph_walker.hpp +++ b/include/extractor/intersection/node_based_graph_walker.hpp @@ -311,7 +311,7 @@ struct DistanceToNextIntersectionAccumulator double distance = 0.; }; -} // namespace guidance +} // namespace intersection } // namespace extractor } // namespace osrm diff --git a/include/extractor/turn_data_container.hpp.tbd b/include/extractor/turn_data_container.hpp.tbd deleted file mode 100644 index 1545097e6da..00000000000 --- a/include/extractor/turn_data_container.hpp.tbd +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef OSRM_EXTRACTOR_TURN_DATA_CONTAINER_HPP -#define OSRM_EXTRACTOR_TURN_DATA_CONTAINER_HPP - -#include "extractor/travel_mode.hpp" -#include "guidance/turn_instruction.hpp" - -#include "storage/io_fwd.hpp" -#include "storage/shared_memory_ownership.hpp" - -#include "util/guidance/turn_bearing.hpp" -#include "util/vector_view.hpp" - -#include "util/typedefs.hpp" - -namespace osrm -{ -namespace extractor -{ -namespace detail -{ -template class TurnDataContainerImpl; -} - -namespace serialization -{ -template -void read(storage::io::FileReader &reader, detail::TurnDataContainerImpl &turn_data); - -template -void write(storage::io::FileWriter &writer, - const detail::TurnDataContainerImpl &turn_data); -} - -struct TurnData -{ - extractor::guidance::TurnInstruction turn_instruction; - LaneDataID lane_data_id; - EntryClassID entry_class_id; - util::guidance::TurnBearing pre_turn_bearing; - util::guidance::TurnBearing post_turn_bearing; -}; - -namespace detail -{ -template class TurnDataContainerImpl -{ - template using Vector = util::ViewOrVector; - - public: - TurnDataContainerImpl() = default; - - TurnDataContainerImpl(Vector turn_instructions, - Vector lane_data_ids, - Vector entry_class_ids, - Vector pre_turn_bearings, - Vector post_turn_bearings) - : turn_instructions(std::move(turn_instructions)), lane_data_ids(std::move(lane_data_ids)), - entry_class_ids(std::move(entry_class_ids)), - pre_turn_bearings(std::move(pre_turn_bearings)), - post_turn_bearings(std::move(post_turn_bearings)) - { - } - - EntryClassID GetEntryClassID(const EdgeID id) const { return entry_class_ids[id]; } - - util::guidance::TurnBearing GetPreTurnBearing(const EdgeID id) const - { - return pre_turn_bearings[id]; - } - - util::guidance::TurnBearing GetPostTurnBearing(const EdgeID id) const - { - return post_turn_bearings[id]; - } - - LaneDataID GetLaneDataID(const EdgeID id) const { return lane_data_ids[id]; } - - bool HasLaneData(const EdgeID id) const { return INVALID_LANE_DATAID != lane_data_ids[id]; } - - extractor::guidance::TurnInstruction GetTurnInstruction(const EdgeID id) const - { - return turn_instructions[id]; - } - - // Used by EdgeBasedGraphFactory to fill data structure - template > - void push_back(const TurnData &data) - { - turn_instructions.push_back(data.turn_instruction); - lane_data_ids.push_back(data.lane_data_id); - entry_class_ids.push_back(data.entry_class_id); - pre_turn_bearings.push_back(data.pre_turn_bearing); - post_turn_bearings.push_back(data.post_turn_bearing); - } - - template > - void append(const std::vector &others) - { - std::for_each( - others.begin(), others.end(), [this](const TurnData &other) { push_back(other); }); - } - - friend void serialization::read(storage::io::FileReader &reader, - TurnDataContainerImpl &turn_data_container); - friend void serialization::write(storage::io::FileWriter &writer, - const TurnDataContainerImpl &turn_data_container); - - private: - Vector turn_instructions; - Vector lane_data_ids; - Vector entry_class_ids; - Vector pre_turn_bearings; - Vector post_turn_bearings; -}; -} - -using TurnDataExternalContainer = detail::TurnDataContainerImpl; -using TurnDataContainer = detail::TurnDataContainerImpl; -using TurnDataView = detail::TurnDataContainerImpl; -} -} - -#endif diff --git a/include/guidance/guidance_processing.hpp b/include/guidance/guidance_processing.hpp index 614c00e11f6..192a580b41e 100644 --- a/include/guidance/guidance_processing.hpp +++ b/include/guidance/guidance_processing.hpp @@ -26,22 +26,22 @@ using BearingClassesVector = std::vector; using BearingClassesMap = util::ConcurrentIDMap; using EntryClassesMap = util::ConcurrentIDMap; -void processGuidanceTurns(const util::NodeBasedDynamicGraph &node_based_graph, - const extractor::EdgeBasedNodeDataContainer &edge_based_node_container, - const std::vector &node_coordinates, - const extractor::CompressedEdgeContainer &compressed_edge_container, - const std::unordered_set &barrier_nodes, - const extractor::RestrictionMap &node_restriction_map, - const extractor::WayRestrictionMap &way_restriction_map, - const util::NameTable &name_table, - const extractor::SuffixTable &suffix_table, - const extractor::TurnLanesIndexedArray &turn_lanes_data, - extractor::LaneDescriptionMap &lane_description_map, - util::guidance::LaneDataIdMap &lane_data_map, - guidance::TurnDataExternalContainer &turn_data_container, - BearingClassesVector &bearing_class_by_node_based_node, - BearingClassesMap &bearing_class_hash, - EntryClassesMap &entry_class_hash); +void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph, + const extractor::EdgeBasedNodeDataContainer &edge_based_node_container, + const std::vector &node_coordinates, + const extractor::CompressedEdgeContainer &compressed_edge_container, + const std::unordered_set &barrier_nodes, + const extractor::RestrictionMap &node_restriction_map, + const extractor::WayRestrictionMap &way_restriction_map, + const util::NameTable &name_table, + const extractor::SuffixTable &suffix_table, + const extractor::TurnLanesIndexedArray &turn_lanes_data, + extractor::LaneDescriptionMap &lane_description_map, + util::guidance::LaneDataIdMap &lane_data_map, + guidance::TurnDataExternalContainer &turn_data_container, + BearingClassesVector &bearing_class_by_node_based_node, + BearingClassesMap &bearing_class_hash, + EntryClassesMap &entry_class_hash); } // namespace customizer } // namespace osrm diff --git a/include/guidance/segregated_intersection_classification.hpp b/include/guidance/segregated_intersection_classification.hpp index 8007ca53e06..25d39d929f9 100644 --- a/include/guidance/segregated_intersection_classification.hpp +++ b/include/guidance/segregated_intersection_classification.hpp @@ -12,6 +12,7 @@ class NameTable; namespace extractor { class NodeBasedGraphFactory; +} namespace guidance { @@ -20,8 +21,7 @@ namespace guidance // - middle edges between two osm ways in one logic road (U-turn) // - staggered intersections (X-cross) // - square/circle intersections -std::unordered_set findSegregatedNodes(const NodeBasedGraphFactory &factory, +std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFactory &factory, const util::NameTable &names); } } -} diff --git a/include/guidance/turn_bearing.hpp b/include/guidance/turn_bearing.hpp new file mode 100644 index 00000000000..ad6e3ac1afb --- /dev/null +++ b/include/guidance/turn_bearing.hpp @@ -0,0 +1,38 @@ +#ifndef OSRM_INCLUDE_GUIDANCE_TURN_BEARING_HPP_ +#define OSRM_INCLUDE_GUIDANCE_TURN_BEARING_HPP_ + +#include + +#include + +namespace osrm +{ +namespace guidance +{ +namespace +{ +const double bearing_scale = 360.0 / 256.0; +} + +#pragma pack(push, 1) +class TurnBearing +{ + public: + // discretizes a bearing into distinct units of 1.4 degrees + TurnBearing(const double value = 0) : bearing(value / bearing_scale) + { + BOOST_ASSERT_MSG(value >= 0 && value < 360.0, + "Bearing value needs to be between 0 and 360 (exclusive)"); + } + + double Get() const { return bearing * bearing_scale; } + + private: + std::uint8_t bearing; +}; +#pragma pack(pop) + +} // namespace guidance +} // namespace osrm + +#endif /* OSRM_INCLUDE_GUIDANCE_TURN_BEARING_HPP_ */ diff --git a/include/guidance/turn_data_container.hpp b/include/guidance/turn_data_container.hpp index 8f77eb2df43..91261f3f3b8 100644 --- a/include/guidance/turn_data_container.hpp +++ b/include/guidance/turn_data_container.hpp @@ -2,12 +2,12 @@ #define OSRM_GUIDANCE_TURN_DATA_CONTAINER_HPP #include "extractor/travel_mode.hpp" +#include "guidance/turn_bearing.hpp" #include "guidance/turn_instruction.hpp" #include "storage/io_fwd.hpp" #include "storage/shared_memory_ownership.hpp" -#include "util/guidance/turn_bearing.hpp" #include "util/vector_view.hpp" #include "util/typedefs.hpp" @@ -33,11 +33,11 @@ void write(storage::io::FileWriter &writer, struct TurnData { - guidance::TurnInstruction turn_instruction; + TurnInstruction turn_instruction; LaneDataID lane_data_id; EntryClassID entry_class_id; - util::guidance::TurnBearing pre_turn_bearing; - util::guidance::TurnBearing post_turn_bearing; + TurnBearing pre_turn_bearing; + TurnBearing post_turn_bearing; }; namespace detail @@ -49,11 +49,11 @@ template class TurnDataContainerImpl public: TurnDataContainerImpl() = default; - TurnDataContainerImpl(Vector turn_instructions, + TurnDataContainerImpl(Vector turn_instructions, Vector lane_data_ids, Vector entry_class_ids, - Vector pre_turn_bearings, - Vector post_turn_bearings) + Vector pre_turn_bearings, + Vector post_turn_bearings) : turn_instructions(std::move(turn_instructions)), lane_data_ids(std::move(lane_data_ids)), entry_class_ids(std::move(entry_class_ids)), pre_turn_bearings(std::move(pre_turn_bearings)), @@ -63,15 +63,9 @@ template class TurnDataContainerImpl EntryClassID GetEntryClassID(const EdgeID id) const { return entry_class_ids[id]; } - util::guidance::TurnBearing GetPreTurnBearing(const EdgeID id) const - { - return pre_turn_bearings[id]; - } + TurnBearing GetPreTurnBearing(const EdgeID id) const { return pre_turn_bearings[id]; } - util::guidance::TurnBearing GetPostTurnBearing(const EdgeID id) const - { - return post_turn_bearings[id]; - } + TurnBearing GetPostTurnBearing(const EdgeID id) const { return post_turn_bearings[id]; } LaneDataID GetLaneDataID(const EdgeID id) const { return lane_data_ids[id]; } @@ -106,11 +100,11 @@ template class TurnDataContainerImpl const TurnDataContainerImpl &turn_data_container); private: - Vector turn_instructions; + Vector turn_instructions; Vector lane_data_ids; Vector entry_class_ids; - Vector pre_turn_bearings; - Vector post_turn_bearings; + Vector pre_turn_bearings; + Vector post_turn_bearings; }; } diff --git a/include/util/guidance/turn_bearing.hpp b/include/util/guidance/turn_bearing.hpp deleted file mode 100644 index 87b4f2a3bdb..00000000000 --- a/include/util/guidance/turn_bearing.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef OSRM_INCLUDE_UTIL_TURN_BEARING_HPP_ -#define OSRM_INCLUDE_UTIL_TURN_BEARING_HPP_ - -#include - -namespace osrm -{ -namespace util -{ -namespace guidance -{ - -#pragma pack(push, 1) -class TurnBearing -{ - public: - TurnBearing(const double value = 0); - - double Get() const; - - private: - std::uint8_t bearing; -}; -#pragma pack(pop) - -} // namespace guidance -} // namespace util -} // namespace osrm - -#endif /* OSRM_INCLUDE_UTIL_TURN_BEARING_HPP_ */ diff --git a/src/extractor/edge_based_graph_factory.cpp b/src/extractor/edge_based_graph_factory.cpp index 93d424cf020..0b297753275 100644 --- a/src/extractor/edge_based_graph_factory.cpp +++ b/src/extractor/edge_based_graph_factory.cpp @@ -14,7 +14,6 @@ #include "util/coordinate.hpp" #include "util/coordinate_calculation.hpp" #include "util/exception.hpp" -#include "util/guidance/turn_bearing.hpp" #include "util/integer_range.hpp" #include "util/log.hpp" #include "util/percent.hpp" diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index addbc3d27ea..ceefd449b2b 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -16,6 +16,7 @@ #include "guidance/files.hpp" #include "guidance/guidance_processing.hpp" #include "guidance/segregated_intersection_classification.hpp" +#include "guidance/turn_data_container.hpp" #include "storage/io.hpp" @@ -874,22 +875,22 @@ void Extractor::ProcessGuidanceTurns( RestrictionMap node_restriction_map(node_restrictions, IndexNodeByFromAndVia()); WayRestrictionMap way_restriction_map(conditional_turn_restrictions); - osrm::guidance::processGuidanceTurns(node_based_graph, - edge_based_node_container, - node_coordinates, - compressed_edge_container, - barrier_nodes, - node_restriction_map, - way_restriction_map, - name_table, - street_name_suffix_table, - turn_lanes_data, - lane_description_map, - lane_data_map, - turn_data_container, - bearing_class_by_node_based_node, - bearing_class_hash, - entry_class_hash); + osrm::guidance::annotateTurns(node_based_graph, + edge_based_node_container, + node_coordinates, + compressed_edge_container, + barrier_nodes, + node_restriction_map, + way_restriction_map, + name_table, + street_name_suffix_table, + turn_lanes_data, + lane_description_map, + lane_data_map, + turn_data_container, + bearing_class_by_node_based_node, + bearing_class_hash, + entry_class_hash); } util::Log() << "Writing Intersection Classification Data"; diff --git a/src/extractor/intersection/coordinate_extractor.cpp b/src/extractor/intersection/coordinate_extractor.cpp index f8c96dcd01f..389271b15e4 100644 --- a/src/extractor/intersection/coordinate_extractor.cpp +++ b/src/extractor/intersection/coordinate_extractor.cpp @@ -1174,6 +1174,6 @@ CoordinateExtractor::RegressionLine(const std::vector &coordin return {coord_between_front, coord_between_back}; } -} // namespace guidance +} // namespace intersection } // namespace extractor } // namespace osrm diff --git a/src/extractor/intersection/mergable_road_detector.cpp b/src/extractor/intersection/mergable_road_detector.cpp index 1a379374382..eb69ecbd00d 100644 --- a/src/extractor/intersection/mergable_road_detector.cpp +++ b/src/extractor/intersection/mergable_road_detector.cpp @@ -615,6 +615,6 @@ bool MergableRoadDetector::IsLinkRoad(const NodeID intersection_node, .annotation_data)); } -} // namespace guidance +} // namespace intersection } // namespace extractor } // namespace osrm diff --git a/src/guidance/guidance_processing.cpp b/src/guidance/guidance_processing.cpp index 76204ed552a..7b51bb75f1a 100644 --- a/src/guidance/guidance_processing.cpp +++ b/src/guidance/guidance_processing.cpp @@ -16,22 +16,22 @@ namespace osrm namespace guidance { -void processGuidanceTurns(const util::NodeBasedDynamicGraph &node_based_graph, - const extractor::EdgeBasedNodeDataContainer &edge_based_node_container, - const std::vector &node_coordinates, - const extractor::CompressedEdgeContainer &compressed_edge_container, - const std::unordered_set &barrier_nodes, - const extractor::RestrictionMap &node_restriction_map, - const extractor::WayRestrictionMap &way_restriction_map, - const util::NameTable &name_table, - const extractor::SuffixTable &suffix_table, - const extractor::TurnLanesIndexedArray &turn_lanes_data, - extractor::LaneDescriptionMap &lane_description_map, - util::guidance::LaneDataIdMap &lane_data_map, - guidance::TurnDataExternalContainer &turn_data_container, - BearingClassesVector &bearing_class_by_node_based_node, - BearingClassesMap &bearing_class_hash, - EntryClassesMap &entry_class_hash) +void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph, + const extractor::EdgeBasedNodeDataContainer &edge_based_node_container, + const std::vector &node_coordinates, + const extractor::CompressedEdgeContainer &compressed_edge_container, + const std::unordered_set &barrier_nodes, + const extractor::RestrictionMap &node_restriction_map, + const extractor::WayRestrictionMap &way_restriction_map, + const util::NameTable &name_table, + const extractor::SuffixTable &suffix_table, + const extractor::TurnLanesIndexedArray &turn_lanes_data, + extractor::LaneDescriptionMap &lane_description_map, + util::guidance::LaneDataIdMap &lane_data_map, + guidance::TurnDataExternalContainer &turn_data_container, + BearingClassesVector &bearing_class_by_node_based_node, + BearingClassesMap &bearing_class_hash, + EntryClassesMap &entry_class_hash) { util::UnbufferedLog log; @@ -221,8 +221,8 @@ void processGuidanceTurns(const util::NodeBasedDynamicGraph &node_based_graph, guidance::TurnData{turn->instruction, turn->lane_data_id, entry_class_id, - util::guidance::TurnBearing(intersection[0].bearing), - util::guidance::TurnBearing(turn->bearing)}); + guidance::TurnBearing(intersection[0].bearing), + guidance::TurnBearing(turn->bearing)}); // when turning off a a via-way turn restriction, we need to not only // handle the normal edges for the way, but also add turns for every @@ -256,8 +256,8 @@ void processGuidanceTurns(const util::NodeBasedDynamicGraph &node_based_graph, turn->instruction, turn->lane_data_id, entry_class_id, - util::guidance::TurnBearing(intersection[0].bearing), - util::guidance::TurnBearing(turn->bearing)}); + guidance::TurnBearing(intersection[0].bearing), + guidance::TurnBearing(turn->bearing)}); } else { @@ -265,8 +265,8 @@ void processGuidanceTurns(const util::NodeBasedDynamicGraph &node_based_graph, turn->instruction, turn->lane_data_id, entry_class_id, - util::guidance::TurnBearing(intersection[0].bearing), - util::guidance::TurnBearing(turn->bearing)}); + guidance::TurnBearing(intersection[0].bearing), + guidance::TurnBearing(turn->bearing)}); } } } diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index 64faeef0517..b7f891a7ba5 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -7,11 +7,11 @@ namespace osrm { -namespace extractor -{ namespace guidance { +namespace RoadPriorityClass = extractor::RoadPriorityClass; + struct EdgeInfo { NodeID node; @@ -21,7 +21,7 @@ struct EdgeInfo // 0 - outgoing (forward), 1 - incoming (reverse), 2 - both outgoing and incoming int direction; - ClassData road_class; + extractor::ClassData road_class; RoadPriorityClass::Enum road_priority_class; @@ -125,7 +125,7 @@ bool IsSegregated(std::vector v1, return edgeLength <= threshold; } -std::unordered_set findSegregatedNodes(const NodeBasedGraphFactory &factory, +std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFactory &factory, const util::NameTable &names) { @@ -238,6 +238,6 @@ std::unordered_set findSegregatedNodes(const NodeBasedGraphFactory &fact return segregated_edges; } -} -} -} + +} // namespace guidance +} // namespace osrm diff --git a/src/storage/storage.cpp b/src/storage/storage.cpp index a940f742311..898b77bae71 100644 --- a/src/storage/storage.cpp +++ b/src/storage/storage.cpp @@ -241,10 +241,10 @@ void Storage::PopulateLayout(DataLayout &layout) const auto number_of_original_edges = edges_file.ReadElementCount64(); // note: settings this all to the same size is correct, we extract them from the same struct - layout.SetBlockSize(DataLayout::PRE_TURN_BEARING, - number_of_original_edges); - layout.SetBlockSize(DataLayout::POST_TURN_BEARING, - number_of_original_edges); + layout.SetBlockSize(DataLayout::PRE_TURN_BEARING, + number_of_original_edges); + layout.SetBlockSize(DataLayout::POST_TURN_BEARING, + number_of_original_edges); layout.SetBlockSize(DataLayout::TURN_INSTRUCTION, number_of_original_edges); layout.SetBlockSize(DataLayout::LANE_DATA_ID, number_of_original_edges); @@ -708,14 +708,14 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr) util::vector_view entry_class_ids( entry_class_id_list_ptr, layout.num_entries[storage::DataLayout::ENTRY_CLASSID]); - const auto pre_turn_bearing_ptr = layout.GetBlockPtr( + const auto pre_turn_bearing_ptr = layout.GetBlockPtr( memory_ptr, storage::DataLayout::PRE_TURN_BEARING); - util::vector_view pre_turn_bearings( + util::vector_view pre_turn_bearings( pre_turn_bearing_ptr, layout.num_entries[storage::DataLayout::PRE_TURN_BEARING]); - const auto post_turn_bearing_ptr = layout.GetBlockPtr( + const auto post_turn_bearing_ptr = layout.GetBlockPtr( memory_ptr, storage::DataLayout::POST_TURN_BEARING); - util::vector_view post_turn_bearings( + util::vector_view post_turn_bearings( post_turn_bearing_ptr, layout.num_entries[storage::DataLayout::POST_TURN_BEARING]); guidance::TurnDataView turn_data(std::move(turn_instructions), diff --git a/src/util/guidance/bearing_class.cpp b/src/util/guidance/bearing_class.cpp index c2bdffa4f39..6e49466a586 100644 --- a/src/util/guidance/bearing_class.cpp +++ b/src/util/guidance/bearing_class.cpp @@ -78,5 +78,5 @@ std::size_t BearingClass::findMatchingBearing(const double bearing) const } } // namespace guidance -} // namespace extractor +} // namespace util } // namespace osrm diff --git a/src/util/guidance/entry_class.cpp b/src/util/guidance/entry_class.cpp index 68569ed161b..34232f2443c 100644 --- a/src/util/guidance/entry_class.cpp +++ b/src/util/guidance/entry_class.cpp @@ -37,5 +37,5 @@ bool EntryClass::operator<(const EntryClass &other) const } } // namespace guidance -} // namespace extractor +} // namespace util } // namespace osrm diff --git a/src/util/guidance/turn_bearing.cpp b/src/util/guidance/turn_bearing.cpp deleted file mode 100644 index 9f70a693105..00000000000 --- a/src/util/guidance/turn_bearing.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "util/guidance/turn_bearing.hpp" - -#include - -namespace osrm -{ -namespace util -{ -namespace guidance -{ - -constexpr double bearing_scale = 360.0 / 256.0; - -// discretizes a bearing into distinct units of 1.4 degrees -TurnBearing::TurnBearing(const double value) : bearing(value / bearing_scale) -{ - BOOST_ASSERT_MSG(value >= 0 && value < 360.0, - "Bearing value needs to be between 0 and 360 (exclusive)"); -} - -double TurnBearing::Get() const { return bearing * bearing_scale; } - -} // namespace guidance -} // namespace util -} // namespace osrm diff --git a/unit_tests/engine/offline_facade.cpp b/unit_tests/engine/offline_facade.cpp index 8d2b561216d..75c9cb4871c 100644 --- a/unit_tests/engine/offline_facade.cpp +++ b/unit_tests/engine/offline_facade.cpp @@ -341,14 +341,14 @@ class ContiguousInternalMemoryDataFacade ComponentID GetComponentID(NodeID) const override { return ComponentID{}; } bool ExcludeNode(const NodeID) const override { return false; } - util::guidance::TurnBearing PreTurnBearing(const EdgeID /*eid*/) const override + guidance::TurnBearing PreTurnBearing(const EdgeID /*eid*/) const override { - return util::guidance::TurnBearing(0); + return guidance::TurnBearing(0); } - util::guidance::TurnBearing PostTurnBearing(const EdgeID /*eid*/) const override + guidance::TurnBearing PostTurnBearing(const EdgeID /*eid*/) const override { - return util::guidance::TurnBearing(0); + return guidance::TurnBearing(0); } util::guidance::BearingClass diff --git a/unit_tests/mocks/mock_datafacade.hpp b/unit_tests/mocks/mock_datafacade.hpp index fd8d75e9512..47656c43085 100644 --- a/unit_tests/mocks/mock_datafacade.hpp +++ b/unit_tests/mocks/mock_datafacade.hpp @@ -7,6 +7,7 @@ #include "extractor/class_data.hpp" #include "extractor/travel_mode.hpp" #include "extractor/turn_lane_types.hpp" +#include "guidance/turn_bearing.hpp" #include "guidance/turn_instruction.hpp" #include "engine/algorithm.hpp" @@ -15,7 +16,6 @@ #include "util/guidance/bearing_class.hpp" #include "util/guidance/entry_class.hpp" -#include "util/guidance/turn_bearing.hpp" #include "util/typedefs.hpp" namespace osrm @@ -226,13 +226,13 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade bool IsLeftHandDriving(const NodeID /*id*/) const override { return false; } bool IsSegregated(const NodeID /*id*/) const override { return false; } - util::guidance::TurnBearing PreTurnBearing(const EdgeID /*eid*/) const override final + guidance::TurnBearing PreTurnBearing(const EdgeID /*eid*/) const override final { - return util::guidance::TurnBearing{0.0}; + return guidance::TurnBearing{0.0}; } - util::guidance::TurnBearing PostTurnBearing(const EdgeID /*eid*/) const override final + guidance::TurnBearing PostTurnBearing(const EdgeID /*eid*/) const override final { - return util::guidance::TurnBearing{0.0}; + return guidance::TurnBearing{0.0}; } bool HasLaneData(const EdgeID /*id*/) const override final { return true; };