Split intersection analysis and guidance code

Intersection analysis occupy in osrm::extractor::intersection namespace
and guidance code osrm::guidance
This commit is contained in:
Michael Krasnyk
2018-01-05 14:33:53 +01:00
parent 36877e4de5
commit 988b6e3311
100 changed files with 1406 additions and 1380 deletions
+7 -7
View File
@@ -19,9 +19,9 @@
#include <utility>
#include <vector>
namespace TurnType = osrm::extractor::guidance::TurnType;
namespace DirectionModifier = osrm::extractor::guidance::DirectionModifier;
using TurnInstruction = osrm::extractor::guidance::TurnInstruction;
namespace TurnType = osrm::guidance::TurnType;
namespace DirectionModifier = osrm::guidance::DirectionModifier;
using TurnInstruction = osrm::guidance::TurnInstruction;
namespace osrm
{
@@ -56,7 +56,7 @@ util::json::Array lanesFromIntersection(const guidance::IntermediateIntersection
{
--lane_id;
util::json::Object lane;
lane.values["indications"] = extractor::guidance::TurnLaneType::toJsonArray(lane_desc);
lane.values["indications"] = extractor::TurnLaneType::toJsonArray(lane_desc);
if (lane_id >= intersection.lanes.first_lane_from_the_right &&
lane_id <
intersection.lanes.first_lane_from_the_right + intersection.lanes.lanes_in_turn)
@@ -97,7 +97,7 @@ util::json::Object makeStepManeuver(const guidance::StepManeuver &maneuver)
std::string maneuver_type;
if (maneuver.waypoint_type == guidance::WaypointType::None)
maneuver_type = extractor::guidance::instructionTypeToString(maneuver.instruction.type);
maneuver_type = osrm::guidance::instructionTypeToString(maneuver.instruction.type);
else
maneuver_type = detail::waypointTypeToString(maneuver.waypoint_type);
@@ -107,8 +107,8 @@ util::json::Object makeStepManeuver(const guidance::StepManeuver &maneuver)
step_maneuver.values["type"] = std::move(maneuver_type);
if (detail::isValidModifier(maneuver))
step_maneuver.values["modifier"] = extractor::guidance::instructionModifierToString(
maneuver.instruction.direction_modifier);
step_maneuver.values["modifier"] =
osrm::guidance::instructionModifierToString(maneuver.instruction.direction_modifier);
step_maneuver.values["location"] = detail::coordinateToLonLat(maneuver.location);
step_maneuver.values["bearing_before"] = detail::roundAndClampBearing(maneuver.bearing_before);
@@ -12,6 +12,7 @@ namespace engine
{
namespace guidance
{
using namespace osrm::guidance;
namespace
{
+4 -7
View File
@@ -10,16 +10,14 @@
#include <boost/assert.hpp>
using osrm::extractor::guidance::TurnInstruction;
using osrm::util::angularDeviation;
using namespace osrm::extractor::guidance;
namespace osrm
{
namespace engine
{
namespace guidance
{
using osrm::util::angularDeviation;
using namespace osrm::guidance;
namespace
{
@@ -53,7 +51,7 @@ double findTotalTurnAngle(const RouteStep &entry_step, const RouteStep &exit_ste
// both angles are in the same direction, the total turn gets increased
//
// a ---- b
// \
// \ 
// c
// |
// d
@@ -286,8 +284,7 @@ void StaggeredTurnStrategy::operator()(RouteStep &step_at_turn_location,
: TurnType::NewName;
}
SetFixedInstructionStrategy::SetFixedInstructionStrategy(
const extractor::guidance::TurnInstruction instruction)
SetFixedInstructionStrategy::SetFixedInstructionStrategy(const TurnInstruction instruction)
: instruction(instruction)
{
}
+1 -4
View File
@@ -9,16 +9,13 @@
#include <unordered_set>
#include <utility>
using osrm::extractor::guidance::TurnInstruction;
using osrm::extractor::guidance::isLeftTurn;
using osrm::extractor::guidance::isRightTurn;
namespace osrm
{
namespace engine
{
namespace guidance
{
using namespace osrm::guidance;
std::vector<RouteStep> anticipateLaneChange(std::vector<RouteStep> steps,
const double min_distance_needed_for_lane_change)
+5 -10
View File
@@ -23,20 +23,15 @@
#include <limits>
#include <utility>
using osrm::util::angularDeviation;
using osrm::extractor::guidance::getTurnDirection;
using osrm::extractor::guidance::hasRampType;
using osrm::extractor::guidance::mirrorDirectionModifier;
using osrm::extractor::guidance::bearingToDirectionModifier;
using RouteStepIterator = std::vector<osrm::engine::guidance::RouteStep>::iterator;
namespace osrm
{
namespace engine
{
namespace guidance
{
using namespace osrm::guidance;
using RouteStepIterator = std::vector<osrm::engine::guidance::RouteStep>::iterator;
namespace
{
@@ -465,7 +460,7 @@ std::vector<RouteStep> assignRelativeLocations(std::vector<RouteStep> steps,
distance_to_start <= MAXIMAL_RELATIVE_DISTANCE
? bearingToDirectionModifier(util::coordinate_calculation::computeAngle(
source_node.input_location, leg_geometry.locations[0], leg_geometry.locations[1]))
: extractor::guidance::DirectionModifier::UTurn;
: DirectionModifier::UTurn;
steps.front().maneuver.instruction.direction_modifier = initial_modifier;
@@ -478,7 +473,7 @@ std::vector<RouteStep> assignRelativeLocations(std::vector<RouteStep> steps,
leg_geometry.locations[leg_geometry.locations.size() - 2],
leg_geometry.locations[leg_geometry.locations.size() - 1],
target_node.input_location))
: extractor::guidance::DirectionModifier::UTurn;
: DirectionModifier::UTurn;
steps.back().maneuver.instruction.direction_modifier = final_modifier;
@@ -10,6 +10,8 @@ namespace engine
{
namespace guidance
{
using namespace osrm::guidance;
std::vector<RouteStep> suppressShortNameSegments(std::vector<RouteStep> steps)
{
// guard against empty routes, even though they shouldn't happen
+3 -4
View File
@@ -765,11 +765,10 @@ void encodeVectorTile(const DataFacadeBase &facade,
auto weight_idx =
point_float_index.add(t.weight / 10.0); // Note conversion to float here
auto turntype_idx =
point_string_index.add(extractor::guidance::internalInstructionTypeToString(
t.turn_instruction.type));
auto turntype_idx = point_string_index.add(
osrm::guidance::internalInstructionTypeToString(t.turn_instruction.type));
auto turnmodifier_idx =
point_string_index.add(extractor::guidance::instructionModifierToString(
point_string_index.add(osrm::guidance::instructionModifierToString(
t.turn_instruction.direction_modifier));
return EncodedTurnData{t.coordinate,
angle_idx,
+32 -36
View File
@@ -2,14 +2,16 @@
#include "extractor/conditional_turn_penalty.hpp"
#include "extractor/edge_based_edge.hpp"
#include "extractor/files.hpp"
#include "extractor/intersection/intersection_analysis.hpp"
#include "extractor/scripting_environment.hpp"
#include "extractor/serialization.hpp"
#include "extractor/suffix_table.hpp"
#include "guidance/files.hpp"
#include "guidance/turn_analysis.hpp"
#include "guidance/turn_data_container.hpp"
#include "guidance/turn_lane_handler.hpp"
#include "extractor/intersection/intersection_analysis.hpp"
#include "extractor/serialization.hpp"
#include "storage/io.hpp"
#include "util/assert.hpp"
@@ -73,7 +75,7 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(
const std::vector<util::Coordinate> &coordinates,
const util::NameTable &name_table,
const std::unordered_set<EdgeID> &segregated_edges,
guidance::LaneDescriptionMap &lane_description_map)
extractor::LaneDescriptionMap &lane_description_map)
: m_edge_based_node_container(node_data_container), m_number_of_edge_based_nodes(0),
m_coordinates(coordinates), m_node_based_graph(std::move(node_based_graph)),
m_barrier_nodes(barrier_nodes), m_traffic_lights(traffic_lights),
@@ -424,19 +426,19 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
storage::io::FileWriter turn_penalties_index_file(turn_penalties_index_filename,
storage::io::FileWriter::HasNoFingerprint);
TurnDataExternalContainer turn_data_container;
guidance::TurnDataExternalContainer turn_data_container;
SuffixTable street_name_suffix_table(scripting_environment);
const auto &turn_lanes_data = transformTurnLaneMapIntoArrays(lane_description_map);
guidance::MergableRoadDetector mergable_road_detector(m_node_based_graph,
m_edge_based_node_container,
m_coordinates,
m_compressed_edge_container,
node_restriction_map,
m_barrier_nodes,
turn_lanes_data,
name_table,
street_name_suffix_table);
intersection::MergableRoadDetector mergable_road_detector(m_node_based_graph,
m_edge_based_node_container,
m_coordinates,
m_compressed_edge_container,
node_restriction_map,
m_barrier_nodes,
turn_lanes_data,
name_table,
street_name_suffix_table);
// Loop over all turns and generate new set of edges.
// Three nested loop look super-linear, but we are dealing with a (kind of)
@@ -526,8 +528,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
{
std::size_t nodes_processed = 0;
std::vector<TurnData> continuous_turn_data; // populate answers from guidance
std::vector<TurnData> delayed_turn_data; // populate answers from guidance
std::vector<guidance::TurnData> continuous_turn_data; // populate answers from guidance
std::vector<guidance::TurnData> delayed_turn_data; // populate answers from guidance
};
using TurnsPipelineBufferPtr = std::shared_ptr<TurnsPipelineBuffer>;
@@ -607,7 +609,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
// compute weight and duration penalties
const auto is_traffic_light = m_traffic_lights.count(intersection_node);
const auto is_uturn = guidance::getTurnDirection(turn_angle) == guidance::DirectionModifier::UTurn;
const auto is_uturn =
guidance::getTurnDirection(turn_angle) == guidance::DirectionModifier::UTurn;
ExtractionTurn extracted_turn(
// general info
@@ -810,7 +813,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
};
// all connected roads on the right of a u turn
const auto is_uturn = guidance::getTurnDirection(turn->angle) == guidance::DirectionModifier::UTurn;
const auto is_uturn = guidance::getTurnDirection(turn->angle) ==
guidance::DirectionModifier::UTurn;
if (is_uturn)
{
if (turn != intersection_view.begin())
@@ -876,10 +880,6 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
// a via way restriction. If that should be the case, we switch the id
// of the edge-based-node for the target to the ID of the duplicated
// node associated with the turn. (e.g. ab via bc switches bc to bc_dup)
const auto turn_angle = util::bearing::angleBetween(
incoming_bearing,
findEdgeBearing(edge_geometries, outgoing_edge.edge));
auto const target_id = way_restriction_map.RemapIfRestricted(
nbe_to_ebn_mapping[outgoing_edge.edge],
incoming_edge.node,
@@ -1094,10 +1094,6 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
const auto turning_off_via_way =
way_restriction_map.IsViaWay(incoming_edge.node, intersection_node);
// Save reversed incoming bearing to compute turn angles
const auto reversed_incoming_bearing = util::bearing::reverse(
findEdgeBearing(edge_geometries, incoming_edge.edge));
for (const auto &outgoing_edge : outgoing_edges)
{
if (!intersection::isTurnAllowed(m_node_based_graph,
@@ -1120,12 +1116,12 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
OSRM_ASSERT(turn != intersection.end(),
m_coordinates[intersection_node]);
buffer->continuous_turn_data.push_back(
TurnData{turn->instruction,
turn->lane_data_id,
entry_class_id,
util::guidance::TurnBearing(intersection[0].bearing),
util::guidance::TurnBearing(turn->bearing)});
buffer->continuous_turn_data.push_back(guidance::TurnData{
turn->instruction,
turn->lane_data_id,
entry_class_id,
util::guidance::TurnBearing(intersection[0].bearing),
util::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
@@ -1155,7 +1151,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
if (restriction.condition.empty())
continue;
buffer->delayed_turn_data.push_back(TurnData{
buffer->delayed_turn_data.push_back(guidance::TurnData{
turn->instruction,
turn->lane_data_id,
entry_class_id,
@@ -1164,7 +1160,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
}
else
{
buffer->delayed_turn_data.push_back(TurnData{
buffer->delayed_turn_data.push_back(guidance::TurnData{
turn->instruction,
turn->lane_data_id,
entry_class_id,
@@ -1212,7 +1208,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
// Last part of the pipeline puts all the calculated data into the serial buffers
util::Percent guidance_progress(log, node_count);
std::vector<TurnData> delayed_turn_data;
std::vector<guidance::TurnData> delayed_turn_data;
tbb::filter_t<TurnsPipelineBufferPtr, void> guidance_output_stage(
tbb::filter::serial_in_order, [&](auto buffer) {
@@ -1320,7 +1316,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
}
util::Log() << "done.";
files::writeTurnData(turn_data_filename, turn_data_container);
guidance::files::writeTurnData(turn_data_filename, turn_data_container);
util::Log() << "Generated " << m_edge_based_node_segments.size() << " edge based node segments";
util::Log() << "Node-based graph contains " << node_based_edge_counter << " edges";
+6 -6
View File
@@ -196,7 +196,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
: tbb::task_scheduler_init::automatic);
BOOST_ASSERT(init.is_active());
guidance::LaneDescriptionMap turn_lane_map;
LaneDescriptionMap turn_lane_map;
std::vector<TurnRestriction> turn_restrictions;
std::vector<ConditionalTurnRestriction> conditional_turn_restrictions;
std::tie(turn_lane_map, turn_restrictions, conditional_turn_restrictions) =
@@ -345,7 +345,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
return 0;
}
std::tuple<guidance::LaneDescriptionMap,
std::tuple<LaneDescriptionMap,
std::vector<TurnRestriction>,
std::vector<ConditionalTurnRestriction>>
Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
@@ -394,7 +394,7 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
// Extraction containers and restriction parser
ExtractionContainers extraction_containers;
ExtractorCallbacks::ClassesMap classes_map;
guidance::LaneDescriptionMap turn_lane_map;
LaneDescriptionMap turn_lane_map;
auto extractor_callbacks =
std::make_unique<ExtractorCallbacks>(extraction_containers,
classes_map,
@@ -673,7 +673,7 @@ EdgeID Extractor::BuildEdgeExpandedGraph(
const std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions,
const std::unordered_set<EdgeID> &segregated_edges,
// might have to be updated to add new lane combinations
guidance::LaneDescriptionMap &turn_lane_map,
LaneDescriptionMap &turn_lane_map,
// for calculating turn penalties
ScriptingEnvironment &scripting_environment,
// output data
@@ -731,9 +731,9 @@ EdgeID Extractor::BuildEdgeExpandedGraph(
{
std::vector<std::uint32_t> turn_lane_offsets;
std::vector<guidance::TurnLaneType::Mask> turn_lane_masks;
std::vector<TurnLaneType::Mask> turn_lane_masks;
std::tie(turn_lane_offsets, turn_lane_masks) =
guidance::transformTurnLaneMapIntoArrays(turn_lane_map);
transformTurnLaneMapIntoArrays(turn_lane_map);
files::writeTurnLaneDescriptions(
config.GetPath(".osrm.tls"), turn_lane_offsets, turn_lane_masks);
}
+5 -9
View File
@@ -5,7 +5,7 @@
#include "extractor/profile_properties.hpp"
#include "extractor/query_node.hpp"
#include "extractor/restriction.hpp"
#include "guidance/road_classification.hpp"
#include "extractor/road_classification.hpp"
#include "util/for_each_pair.hpp"
#include "util/guidance/turn_lanes.hpp"
@@ -29,13 +29,9 @@ namespace osrm
{
namespace extractor
{
using TurnLaneDescription = guidance::TurnLaneDescription;
namespace TurnLaneType = guidance::TurnLaneType;
ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers &extraction_containers_,
std::unordered_map<std::string, ClassData> &classes_map,
guidance::LaneDescriptionMap &lane_description_map,
LaneDescriptionMap &lane_description_map,
const ProfileProperties &properties)
: external_memory(extraction_containers_), classes_map(classes_map),
lane_description_map(lane_description_map),
@@ -260,9 +256,9 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
for (auto iter = tokens.begin(); iter != tokens.end(); ++iter)
{
tokenizer inner_tokens(*iter, inner_sep);
guidance::TurnLaneType::Mask lane_mask = inner_tokens.begin() == inner_tokens.end()
? TurnLaneType::none
: TurnLaneType::empty;
TurnLaneType::Mask lane_mask = inner_tokens.begin() == inner_tokens.end()
? TurnLaneType::none
: TurnLaneType::empty;
for (auto token_itr = inner_tokens.begin(); token_itr != inner_tokens.end();
++token_itr)
{
@@ -1,5 +1,5 @@
#include "guidance/coordinate_extractor.hpp"
#include "guidance/constants.hpp"
#include "extractor/intersection/coordinate_extractor.hpp"
#include "extractor/intersection/constants.hpp"
#include <algorithm>
#include <cstddef>
@@ -17,7 +17,7 @@ namespace osrm
{
namespace extractor
{
namespace guidance
namespace intersection
{
namespace
@@ -1,13 +1,10 @@
#ifndef OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_
#define OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_
#include "util/guidance/name_announcements.hpp"
namespace osrm
{
namespace extractor
{
namespace guidance
namespace intersection
{
// check if two name ids can be seen as identical (in presence of refs/others)
@@ -16,7 +13,7 @@ namespace guidance
bool HaveIdenticalNames(const NameID lhs,
const NameID rhs,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
const extractor::SuffixTable &street_name_suffix_table)
{
const auto non_empty = (lhs != EMPTY_NAMEID) && (rhs != EMPTY_NAMEID);
@@ -29,5 +26,3 @@ bool HaveIdenticalNames(const NameID lhs,
} // namespace guidance
} // namespace extractor
} // namespace osrm
#endif /*OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_*/
@@ -0,0 +1,44 @@
#include "guidance/intersection.hpp"
#include <limits>
#include <string>
#include <boost/range/adaptors.hpp>
using osrm::util::angularDeviation;
namespace osrm
{
namespace extractor
{
namespace intersection
{
bool IntersectionViewData::CompareByAngle(const IntersectionViewData &other) const
{
return angle < other.angle;
}
std::string toString(const IntersectionShapeData &shape)
{
std::string result =
"[shape] " + std::to_string(shape.eid) + " bearing: " + std::to_string(shape.bearing);
return result;
}
std::string toString(const IntersectionViewData &view)
{
std::string result = "[view] ";
result += std::to_string(view.eid);
result += " allows entry: ";
result += std::to_string(view.entry_allowed);
result += " angle: ";
result += std::to_string(view.angle);
result += " bearing: ";
result += std::to_string(view.bearing);
return result;
}
} // namespace intersection
} // namespace extractor
} // namespace osrm
@@ -1,11 +1,10 @@
#include "extractor/intersection/intersection_analysis.hpp"
#include "extractor/intersection/coordinate_extractor.hpp"
#include "util/assert.hpp"
#include "util/bearing.hpp"
#include "util/coordinate_calculation.hpp"
#include "guidance/coordinate_extractor.hpp"
#include <boost/optional/optional_io.hpp>
namespace osrm
@@ -116,8 +115,6 @@ std::pair<bool, double> findMergedBearing(const util::NodeBasedDynamicGraph &gra
// Function returns a pair with a flag and a value of bearing for merged roads
// If the flag is false the bearing must not be used as a merged value at neighbor intersections
using guidance::STRAIGHT_ANGLE;
using guidance::MAXIMAL_ALLOWED_NO_TURN_DEVIATION;
using util::bearing::angleBetween;
using util::angularDeviation;
@@ -166,7 +163,7 @@ std::pair<bool, double> findMergedBearing(const util::NodeBasedDynamicGraph &gra
return {true, merged_bearing};
}
bool isRoadsPairMergeable(const guidance::MergableRoadDetector &detector,
bool isRoadsPairMergeable(const MergableRoadDetector &detector,
const IntersectionEdgeGeometries &edge_geometries,
const NodeID intersection_node,
const std::size_t index)
@@ -212,8 +209,7 @@ getIntersectionOutgoingGeometries(const util::NodeBasedDynamicGraph &graph,
IntersectionEdgeGeometries edge_geometries;
// TODO: keep CoordinateExtractor to reproduce bearings, simplify later
const guidance::CoordinateExtractor coordinate_extractor(
graph, compressed_geometries, node_coordinates);
const CoordinateExtractor coordinate_extractor(graph, compressed_geometries, node_coordinates);
const auto max_lanes_intersection = getIntersectionLanes(graph, intersection_node);
@@ -263,7 +259,7 @@ std::pair<IntersectionEdgeGeometries, std::unordered_set<EdgeID>>
getIntersectionGeometries(const util::NodeBasedDynamicGraph &graph,
const extractor::CompressedEdgeContainer &compressed_geometries,
const std::vector<util::Coordinate> &node_coordinates,
const guidance::MergableRoadDetector &detector,
const MergableRoadDetector &detector,
const NodeID intersection_node)
{
IntersectionEdgeGeometries edge_geometries = getIntersectionOutgoingGeometries<false>(
@@ -462,7 +458,7 @@ bool isTurnAllowed(const util::NodeBasedDynamicGraph &graph,
const RestrictionMap &restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const IntersectionEdgeGeometries &geometries,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const TurnLanesIndexedArray &turn_lanes_data,
const IntersectionEdge &from,
const IntersectionEdge &to)
{
@@ -567,7 +563,7 @@ bool isTurnAllowed(const util::NodeBasedDynamicGraph &graph,
if (std::any_of(turn_lanes.begin() + turn_lane_offsets[lane_description_id],
turn_lanes.begin() + turn_lane_offsets[lane_description_id + 1],
[](const auto &lane) { return lane & guidance::TurnLaneType::uturn; }))
[](const auto &lane) { return lane & TurnLaneType::uturn; }))
return true;
}
@@ -620,16 +616,15 @@ bool isTurnAllowed(const util::NodeBasedDynamicGraph &graph,
}
// The function adapts intersection geometry data to TurnAnalysis
guidance::IntersectionView
convertToIntersectionView(const util::NodeBasedDynamicGraph &graph,
const EdgeBasedNodeDataContainer &node_data_container,
const RestrictionMap &restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const IntersectionEdgeGeometries &edge_geometries,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const IntersectionEdge &incoming_edge,
const IntersectionEdges &outgoing_edges,
const std::unordered_set<EdgeID> &merged_edges)
IntersectionView convertToIntersectionView(const util::NodeBasedDynamicGraph &graph,
const EdgeBasedNodeDataContainer &node_data_container,
const RestrictionMap &restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const IntersectionEdgeGeometries &edge_geometries,
const TurnLanesIndexedArray &turn_lanes_data,
const IntersectionEdge &incoming_edge,
const IntersectionEdges &outgoing_edges,
const std::unordered_set<EdgeID> &merged_edges)
{
using util::bearing::angleBetween;
@@ -637,9 +632,9 @@ convertToIntersectionView(const util::NodeBasedDynamicGraph &graph,
const auto incoming_bearing = edge_it->perceived_bearing;
const auto initial_incoming_bearing = edge_it->initial_bearing;
using IntersectionViewDataWithAngle = std::pair<guidance::IntersectionViewData, double>;
using IntersectionViewDataWithAngle = std::pair<IntersectionViewData, double>;
std::vector<IntersectionViewDataWithAngle> pre_intersection_view;
guidance::IntersectionViewData uturn{{SPECIAL_EDGEID, 0., 0.}, false, 0.};
IntersectionViewData uturn{{SPECIAL_EDGEID, 0., 0.}, false, 0.};
std::size_t allowed_uturns_number = 0;
for (const auto &outgoing_edge : outgoing_edges)
{
@@ -678,7 +673,7 @@ convertToIntersectionView(const util::NodeBasedDynamicGraph &graph,
const auto is_uturn_angle = is_uturn(turn_angle);
guidance::IntersectionViewData road{
IntersectionViewData road{
{outgoing_edge.edge, outgoing_bearing, segment_length}, is_turn_allowed, turn_angle};
if (graph.GetTarget(outgoing_edge.edge) == incoming_edge.node)
@@ -733,7 +728,7 @@ convertToIntersectionView(const util::NodeBasedDynamicGraph &graph,
}
// Copy intersection view data
guidance::IntersectionView intersection_view;
IntersectionView intersection_view;
intersection_view.reserve(pre_intersection_view.size());
std::transform(pre_intersection_view.begin(),
pre_intersection_view.end(),
@@ -757,15 +752,14 @@ convertToIntersectionView(const util::NodeBasedDynamicGraph &graph,
// but also (from_node, turn_node, a), (from_node, turn_node, b). These turns are
// marked as invalid and only needed for intersection classification.
template <bool USE_CLOSE_COORDINATE>
guidance::IntersectionView
getConnectedRoads(const util::NodeBasedDynamicGraph &graph,
const EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &node_coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const IntersectionEdge &incoming_edge)
IntersectionView getConnectedRoads(const util::NodeBasedDynamicGraph &graph,
const EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &node_coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const TurnLanesIndexedArray &turn_lanes_data,
const IntersectionEdge &incoming_edge)
{
const auto intersection_node = graph.GetTarget(incoming_edge.edge);
const auto &outgoing_edges = intersection::getOutgoingEdges(graph, intersection_node);
@@ -800,24 +794,24 @@ getConnectedRoads(const util::NodeBasedDynamicGraph &graph,
std::unordered_set<EdgeID>());
}
template guidance::IntersectionView
template IntersectionView
getConnectedRoads<false>(const util::NodeBasedDynamicGraph &graph,
const EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &node_coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const TurnLanesIndexedArray &turn_lanes_data,
const IntersectionEdge &incoming_edge);
template guidance::IntersectionView
template IntersectionView
getConnectedRoads<true>(const util::NodeBasedDynamicGraph &graph,
const EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &node_coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const TurnLanesIndexedArray &turn_lanes_data,
const IntersectionEdge &incoming_edge);
IntersectionEdge skipDegreeTwoNodes(const util::NodeBasedDynamicGraph &graph, IntersectionEdge road)
@@ -1,9 +1,9 @@
#include "guidance/mergable_road_detector.hpp"
#include "extractor/intersection/mergable_road_detector.hpp"
#include "extractor/intersection/intersection_analysis.hpp"
#include "extractor/intersection/node_based_graph_walker.hpp"
#include "extractor/query_node.hpp"
#include "extractor/suffix_table.hpp"
#include "guidance/constants.hpp"
#include "guidance/node_based_graph_walker.hpp"
#include "util/bearing.hpp"
#include "util/coordinate_calculation.hpp"
@@ -16,7 +16,7 @@ namespace osrm
{
namespace extractor
{
namespace guidance
namespace intersection
{
namespace
@@ -58,7 +58,7 @@ MergableRoadDetector::MergableRoadDetector(
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const extractor::TurnLanesIndexedArray &turn_lanes_data,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
: node_based_graph(node_based_graph), node_data_container(node_data_container),
@@ -1,4 +1,4 @@
#include "guidance/node_based_graph_walker.hpp"
#include "extractor/intersection/node_based_graph_walker.hpp"
#include "extractor/intersection/intersection_analysis.hpp"
#include "util/bearing.hpp"
#include "util/coordinate_calculation.hpp"
@@ -11,7 +11,7 @@ namespace osrm
{
namespace extractor
{
namespace guidance
namespace intersection
{
// ---------------------------------------------------------------------------------
@@ -22,7 +22,7 @@ NodeBasedGraphWalker::NodeBasedGraphWalker(
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data)
const TurnLanesIndexedArray &turn_lanes_data)
: node_based_graph(node_based_graph), node_data_container(node_data_container),
node_coordinates(node_coordinates), compressed_geometries(compressed_geometries),
node_restriction_map(node_restriction_map), barrier_nodes(barrier_nodes),
@@ -31,7 +31,7 @@ NodeBasedGraphWalker::NodeBasedGraphWalker(
}
LengthLimitedCoordinateAccumulator::LengthLimitedCoordinateAccumulator(
const extractor::guidance::CoordinateExtractor &coordinate_extractor, const double max_length)
const CoordinateExtractor &coordinate_extractor, const double max_length)
: accumulated_length(0), coordinate_extractor(coordinate_extractor), max_length(max_length)
{
}
@@ -250,7 +250,7 @@ IntersectionFinderAccumulator::IntersectionFinderAccumulator(
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data)
const TurnLanesIndexedArray &turn_lanes_data)
: hops(0), hop_limit(hop_limit), node_based_graph(node_based_graph),
node_data_container(node_data_container), node_coordinates(node_coordinates),
compressed_geometries(compressed_geometries), node_restriction_map(node_restriction_map),
@@ -289,6 +289,6 @@ void IntersectionFinderAccumulator::update(const NodeID from_node,
{from_node, via_edge});
}
} // namespace guidance
} // namespace intersection
} // namespace extractor
} // namespace osrm
+61 -61
View File
@@ -11,6 +11,9 @@
#include "extractor/query_node.hpp"
#include "extractor/raster_source.hpp"
#include "extractor/restriction_parser.hpp"
#include "guidance/turn_instruction.hpp"
#include "util/coordinate.hpp"
#include "util/exception.hpp"
#include "util/log.hpp"
@@ -135,27 +138,27 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
context.state.new_enum("road_priority_class",
"motorway",
extractor::guidance::RoadPriorityClass::MOTORWAY,
extractor::RoadPriorityClass::MOTORWAY,
"trunk",
extractor::guidance::RoadPriorityClass::TRUNK,
extractor::RoadPriorityClass::TRUNK,
"primary",
extractor::guidance::RoadPriorityClass::PRIMARY,
extractor::RoadPriorityClass::PRIMARY,
"secondary",
extractor::guidance::RoadPriorityClass::SECONDARY,
extractor::RoadPriorityClass::SECONDARY,
"tertiary",
extractor::guidance::RoadPriorityClass::TERTIARY,
extractor::RoadPriorityClass::TERTIARY,
"main_residential",
extractor::guidance::RoadPriorityClass::MAIN_RESIDENTIAL,
extractor::RoadPriorityClass::MAIN_RESIDENTIAL,
"side_residential",
extractor::guidance::RoadPriorityClass::SIDE_RESIDENTIAL,
extractor::RoadPriorityClass::SIDE_RESIDENTIAL,
"link_road",
extractor::guidance::RoadPriorityClass::LINK_ROAD,
extractor::RoadPriorityClass::LINK_ROAD,
"bike_path",
extractor::guidance::RoadPriorityClass::BIKE_PATH,
extractor::RoadPriorityClass::BIKE_PATH,
"foot_path",
extractor::guidance::RoadPriorityClass::FOOT_PATH,
extractor::RoadPriorityClass::FOOT_PATH,
"connectivity",
extractor::guidance::RoadPriorityClass::CONNECTIVITY);
extractor::RoadPriorityClass::CONNECTIVITY);
context.state.new_enum("item_type",
"node",
@@ -263,23 +266,20 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
"barrier",
&ExtractionNode::barrier);
context.state.new_usertype<guidance::RoadClassification>(
context.state.new_usertype<RoadClassification>(
"RoadClassification",
"motorway_class",
sol::property(&guidance::RoadClassification::IsMotorwayClass,
&guidance::RoadClassification::SetMotorwayFlag),
sol::property(&RoadClassification::IsMotorwayClass, &RoadClassification::SetMotorwayFlag),
"link_class",
sol::property(&guidance::RoadClassification::IsLinkClass,
&guidance::RoadClassification::SetLinkClass),
sol::property(&RoadClassification::IsLinkClass, &RoadClassification::SetLinkClass),
"may_be_ignored",
sol::property(&guidance::RoadClassification::IsLowPriorityRoadClass,
&guidance::RoadClassification::SetLowPriorityFlag),
sol::property(&RoadClassification::IsLowPriorityRoadClass,
&RoadClassification::SetLowPriorityFlag),
"road_priority_class",
sol::property(&guidance::RoadClassification::GetClass,
&guidance::RoadClassification::SetClass),
sol::property(&RoadClassification::GetClass, &RoadClassification::SetClass),
"num_lanes",
sol::property(&guidance::RoadClassification::GetNumberOfLanes,
&guidance::RoadClassification::SetNumberOfLanes));
sol::property(&RoadClassification::GetNumberOfLanes,
&RoadClassification::SetNumberOfLanes));
context.state.new_usertype<ExtractionWay>(
"ResultWay",
@@ -573,16 +573,16 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
sol::property([](const ExtractionTurn &turn) {
if (turn.number_of_roads > 2 || turn.source_mode != turn.target_mode ||
turn.is_u_turn)
return guidance::TurnType::Turn;
return osrm::guidance::TurnType::Turn;
else
return guidance::TurnType::NoTurn;
return osrm::guidance::TurnType::NoTurn;
}),
"direction_modifier",
sol::property([](const ExtractionTurn &turn) {
if (turn.is_u_turn)
return guidance::DirectionModifier::UTurn;
return osrm::guidance::DirectionModifier::UTurn;
else
return guidance::DirectionModifier::Straight;
return osrm::guidance::DirectionModifier::Straight;
}),
"has_traffic_light",
&ExtractionTurn::has_traffic_light,
@@ -599,77 +599,77 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
context.state.new_enum("turn_type",
"invalid",
extractor::guidance::TurnType::Invalid,
osrm::guidance::TurnType::Invalid,
"new_name",
extractor::guidance::TurnType::NewName,
osrm::guidance::TurnType::NewName,
"continue",
extractor::guidance::TurnType::Continue,
osrm::guidance::TurnType::Continue,
"turn",
extractor::guidance::TurnType::Turn,
osrm::guidance::TurnType::Turn,
"merge",
extractor::guidance::TurnType::Merge,
osrm::guidance::TurnType::Merge,
"on_ramp",
extractor::guidance::TurnType::OnRamp,
osrm::guidance::TurnType::OnRamp,
"off_ramp",
extractor::guidance::TurnType::OffRamp,
osrm::guidance::TurnType::OffRamp,
"fork",
extractor::guidance::TurnType::Fork,
osrm::guidance::TurnType::Fork,
"end_of_road",
extractor::guidance::TurnType::EndOfRoad,
osrm::guidance::TurnType::EndOfRoad,
"notification",
extractor::guidance::TurnType::Notification,
osrm::guidance::TurnType::Notification,
"enter_roundabout",
extractor::guidance::TurnType::EnterRoundabout,
osrm::guidance::TurnType::EnterRoundabout,
"enter_and_exit_roundabout",
extractor::guidance::TurnType::EnterAndExitRoundabout,
osrm::guidance::TurnType::EnterAndExitRoundabout,
"enter_rotary",
extractor::guidance::TurnType::EnterRotary,
osrm::guidance::TurnType::EnterRotary,
"enter_and_exit_rotary",
extractor::guidance::TurnType::EnterAndExitRotary,
osrm::guidance::TurnType::EnterAndExitRotary,
"enter_roundabout_intersection",
extractor::guidance::TurnType::EnterRoundaboutIntersection,
osrm::guidance::TurnType::EnterRoundaboutIntersection,
"enter_and_exit_roundabout_intersection",
extractor::guidance::TurnType::EnterAndExitRoundaboutIntersection,
osrm::guidance::TurnType::EnterAndExitRoundaboutIntersection,
"use_lane",
extractor::guidance::TurnType::Suppressed,
osrm::guidance::TurnType::Suppressed,
"no_turn",
extractor::guidance::TurnType::NoTurn,
osrm::guidance::TurnType::NoTurn,
"suppressed",
extractor::guidance::TurnType::Suppressed,
osrm::guidance::TurnType::Suppressed,
"enter_roundabout_at_exit",
extractor::guidance::TurnType::EnterRoundaboutAtExit,
osrm::guidance::TurnType::EnterRoundaboutAtExit,
"exit_roundabout",
extractor::guidance::TurnType::ExitRoundabout,
osrm::guidance::TurnType::ExitRoundabout,
"enter_rotary_at_exit",
extractor::guidance::TurnType::EnterRotaryAtExit,
osrm::guidance::TurnType::EnterRotaryAtExit,
"exit_rotary",
extractor::guidance::TurnType::ExitRotary,
osrm::guidance::TurnType::ExitRotary,
"enter_roundabout_intersection_at_exit",
extractor::guidance::TurnType::EnterRoundaboutIntersectionAtExit,
osrm::guidance::TurnType::EnterRoundaboutIntersectionAtExit,
"exit_roundabout_intersection",
extractor::guidance::TurnType::ExitRoundaboutIntersection,
osrm::guidance::TurnType::ExitRoundaboutIntersection,
"stay_on_roundabout",
extractor::guidance::TurnType::StayOnRoundabout,
osrm::guidance::TurnType::StayOnRoundabout,
"sliproad",
extractor::guidance::TurnType::Sliproad);
osrm::guidance::TurnType::Sliproad);
context.state.new_enum("direction_modifier",
"u_turn",
extractor::guidance::DirectionModifier::UTurn,
osrm::guidance::DirectionModifier::UTurn,
"sharp_right",
extractor::guidance::DirectionModifier::SharpRight,
osrm::guidance::DirectionModifier::SharpRight,
"right",
extractor::guidance::DirectionModifier::Right,
osrm::guidance::DirectionModifier::Right,
"slight_right",
extractor::guidance::DirectionModifier::SlightRight,
osrm::guidance::DirectionModifier::SlightRight,
"straight",
extractor::guidance::DirectionModifier::Straight,
osrm::guidance::DirectionModifier::Straight,
"slight_left",
extractor::guidance::DirectionModifier::SlightLeft,
osrm::guidance::DirectionModifier::SlightLeft,
"left",
extractor::guidance::DirectionModifier::Left,
osrm::guidance::DirectionModifier::Left,
"sharp_left",
extractor::guidance::DirectionModifier::SharpLeft);
osrm::guidance::DirectionModifier::SharpLeft);
};
switch (context.api_version)
+5 -8
View File
@@ -2,25 +2,23 @@
#include "util/assert.hpp"
using osrm::extractor::guidance::getTurnDirection;
using osrm::guidance::getTurnDirection;
using osrm::util::angularDeviation;
namespace osrm
{
namespace extractor
{
namespace guidance
{
DrivewayHandler::DrivewayHandler(const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &node_data_container,
const extractor::EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &node_coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const extractor::RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const extractor::TurnLanesIndexedArray &turn_lanes_data,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
const extractor::SuffixTable &street_name_suffix_table)
: IntersectionHandler(node_based_graph,
node_data_container,
node_coordinates,
@@ -84,5 +82,4 @@ operator()(const NodeID nid, const EdgeID source_edge_id, Intersection intersect
}
} // namespace guidance
} // namespace extractor
} // namespace osrm
-92
View File
@@ -1,92 +0,0 @@
#include "guidance/intersection.hpp"
#include <limits>
#include <string>
#include <boost/range/adaptors.hpp>
using osrm::util::angularDeviation;
namespace osrm
{
namespace extractor
{
namespace guidance
{
bool IntersectionViewData::CompareByAngle(const IntersectionViewData &other) const
{
return angle < other.angle;
}
bool ConnectedRoad::compareByAngle(const ConnectedRoad &other) const { return angle < other.angle; }
void ConnectedRoad::mirror()
{
const constexpr DirectionModifier::Enum mirrored_modifiers[] = {DirectionModifier::UTurn,
DirectionModifier::SharpLeft,
DirectionModifier::Left,
DirectionModifier::SlightLeft,
DirectionModifier::Straight,
DirectionModifier::SlightRight,
DirectionModifier::Right,
DirectionModifier::SharpRight};
static_assert(sizeof(mirrored_modifiers) / sizeof(DirectionModifier::Enum) ==
DirectionModifier::MaxDirectionModifier,
"The list of mirrored modifiers needs to match the available modifiers in size.");
if (util::angularDeviation(angle, 0) > std::numeric_limits<double>::epsilon())
{
angle = 360 - angle;
instruction.direction_modifier = mirrored_modifiers[instruction.direction_modifier];
}
}
ConnectedRoad ConnectedRoad::getMirroredCopy() const
{
ConnectedRoad copy(*this);
copy.mirror();
return copy;
}
std::string toString(const IntersectionShapeData &shape)
{
std::string result =
"[shape] " + std::to_string(shape.eid) + " bearing: " + std::to_string(shape.bearing);
return result;
}
std::string toString(const IntersectionViewData &view)
{
std::string result = "[view] ";
result += std::to_string(view.eid);
result += " allows entry: ";
result += std::to_string(view.entry_allowed);
result += " angle: ";
result += std::to_string(view.angle);
result += " bearing: ";
result += std::to_string(view.bearing);
return result;
}
std::string toString(const ConnectedRoad &road)
{
std::string result = "[connection] ";
result += std::to_string(road.eid);
result += " allows entry: ";
result += std::to_string(road.entry_allowed);
result += " angle: ";
result += std::to_string(road.angle);
result += " bearing: ";
result += std::to_string(road.bearing);
result += " instruction: ";
result += std::to_string(static_cast<std::int32_t>(road.instruction.type)) + " " +
std::to_string(static_cast<std::int32_t>(road.instruction.direction_modifier)) + " " +
std::to_string(static_cast<std::int32_t>(road.lane_data_id));
return result;
}
} // namespace guidance
} // namespace extractor
} // namespace osrm
+15 -18
View File
@@ -13,13 +13,11 @@
#include <cstddef>
using EdgeData = osrm::util::NodeBasedDynamicGraph::EdgeData;
using osrm::extractor::guidance::getTurnDirection;
using osrm::guidance::getTurnDirection;
using osrm::util::angularDeviation;
namespace osrm
{
namespace extractor
{
namespace guidance
{
@@ -27,7 +25,7 @@ namespace detail
{
// TODO check flags!
inline bool requiresAnnouncement(const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &node_data_container,
const extractor::EdgeBasedNodeDataContainer &node_data_container,
const EdgeID from,
const EdgeID to)
{
@@ -48,14 +46,14 @@ inline bool requiresAnnouncement(const util::NodeBasedDynamicGraph &node_based_g
IntersectionHandler::IntersectionHandler(
const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &node_data_container,
const extractor::EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &node_coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const extractor::RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const extractor::TurnLanesIndexedArray &turn_lanes_data,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
const extractor::SuffixTable &street_name_suffix_table)
: node_based_graph(node_based_graph), node_data_container(node_data_container),
node_coordinates(node_coordinates), compressed_geometries(compressed_geometries),
node_restriction_map(node_restriction_map), barrier_nodes(barrier_nodes),
@@ -450,7 +448,7 @@ IntersectionHandler::getNextIntersection(const NodeID at, const EdgeID via) cons
// writing `tl` (traffic signal) node and the edge `e1` which has the intersection as target.
const auto intersection_parameters =
intersection::skipDegreeTwoNodes(node_based_graph, {at, via});
extractor::intersection::skipDegreeTwoNodes(node_based_graph, {at, via});
// This should never happen, guard against nevertheless
if (intersection_parameters.node == SPECIAL_NODEID ||
intersection_parameters.edge == SPECIAL_EDGEID)
@@ -458,14 +456,14 @@ IntersectionHandler::getNextIntersection(const NodeID at, const EdgeID via) cons
return boost::none;
}
auto intersection = intersection::getConnectedRoads<false>(node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data,
intersection_parameters);
auto intersection = extractor::intersection::getConnectedRoads<false>(node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data,
intersection_parameters);
auto intersection_node = node_based_graph.GetTarget(intersection_parameters.edge);
if (intersection.size() <= 2 || intersection.isTrafficSignalOrBarrier())
@@ -493,5 +491,4 @@ bool IntersectionHandler::isSameName(const EdgeID source_edge_id, const EdgeID t
}
} // namespace guidance
} // namespace extractor
} // namespace osrm
+8 -11
View File
@@ -1,6 +1,6 @@
#include "guidance/motorway_handler.hpp"
#include "extractor/road_classification.hpp"
#include "guidance/constants.hpp"
#include "guidance/road_classification.hpp"
#include "util/assert.hpp"
#include "util/bearing.hpp"
@@ -12,12 +12,10 @@
#include <boost/assert.hpp>
using osrm::util::angularDeviation;
using osrm::extractor::guidance::getTurnDirection;
using osrm::guidance::getTurnDirection;
namespace osrm
{
namespace extractor
{
namespace guidance
{
namespace
@@ -27,8 +25,8 @@ inline bool isMotorwayClass(EdgeID eid, const util::NodeBasedDynamicGraph &node_
{
return node_based_graph.GetEdgeData(eid).flags.road_classification.IsMotorwayClass();
}
inline RoadClassification roadClass(const ConnectedRoad &road,
const util::NodeBasedDynamicGraph &graph)
inline extractor::RoadClassification roadClass(const ConnectedRoad &road,
const util::NodeBasedDynamicGraph &graph)
{
return graph.GetEdgeData(road.eid).flags.road_classification;
}
@@ -41,14 +39,14 @@ inline bool isRampClass(EdgeID eid, const util::NodeBasedDynamicGraph &node_base
} // namespace
MotorwayHandler::MotorwayHandler(const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &node_data_container,
const extractor::EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const extractor::RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const extractor::TurnLanesIndexedArray &turn_lanes_data,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
const extractor::SuffixTable &street_name_suffix_table)
: IntersectionHandler(node_based_graph,
node_data_container,
coordinates,
@@ -564,5 +562,4 @@ Intersection MotorwayHandler::fallback(Intersection intersection) const
}
} // namespace guidance
} // namespace extractor
} // namespace osrm
+5 -8
View File
@@ -14,25 +14,23 @@
#include <boost/assert.hpp>
using osrm::extractor::guidance::getTurnDirection;
using osrm::guidance::getTurnDirection;
namespace osrm
{
namespace extractor
{
namespace guidance
{
RoundaboutHandler::RoundaboutHandler(
const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &node_data_container,
const extractor::EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const extractor::RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const extractor::TurnLanesIndexedArray &turn_lanes_data,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
const extractor::SuffixTable &street_name_suffix_table)
: IntersectionHandler(node_based_graph,
node_data_container,
coordinates,
@@ -501,5 +499,4 @@ Intersection RoundaboutHandler::handleRoundabouts(const RoundaboutType roundabou
}
} // namespace guidance
} // namespace extractor
} // namespace osrm
@@ -1,6 +1,6 @@
#include "guidance/segregated_intersection_classification.hpp"
#include "extractor/intersection/coordinate_extractor.hpp"
#include "extractor/node_based_graph_factory.hpp"
#include "guidance/coordinate_extractor.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/name_table.hpp"
@@ -132,7 +132,7 @@ std::unordered_set<EdgeID> findSegregatedNodes(const NodeBasedGraphFactory &fact
auto const &graph = factory.GetGraph();
auto const &annotation = factory.GetAnnotationData();
CoordinateExtractor coordExtractor(
extractor::intersection::CoordinateExtractor coordExtractor(
graph, factory.GetCompressedEdges(), factory.GetCoordinates());
auto const get_edge_length = [&](NodeID from_node, EdgeID edgeID, NodeID to_node) {
+55 -52
View File
@@ -12,25 +12,23 @@
#include <boost/assert.hpp>
using osrm::extractor::guidance::getTurnDirection;
using osrm::guidance::getTurnDirection;
using osrm::util::angularDeviation;
namespace osrm
{
namespace extractor
{
namespace guidance
{
SliproadHandler::SliproadHandler(const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &node_data_container,
const extractor::EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &node_coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const extractor::RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const extractor::TurnLanesIndexedArray &turn_lanes_data,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
const extractor::SuffixTable &street_name_suffix_table)
: IntersectionHandler(node_based_graph,
node_data_container,
node_coordinates,
@@ -250,15 +248,16 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
// Starting out at the intersection and going onto the Sliproad we skip artificial
// degree two intersections and limit the max hop count in doing so.
IntersectionFinderAccumulator intersection_finder{10,
node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data};
const SkipTrafficSignalBarrierRoadSelector road_selector{};
extractor::intersection::IntersectionFinderAccumulator intersection_finder{
10,
node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data};
const extractor::intersection::SkipTrafficSignalBarrierRoadSelector road_selector{};
(void)graph_walker.TraverseRoad(intersection_node_id, // start node
sliproad_edge, // onto edge
intersection_finder, // accumulator
@@ -269,7 +268,7 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
if (target_intersection.isDeadEnd())
continue;
const auto find_valid = [](const IntersectionView &view) {
const auto find_valid = [](const extractor::intersection::IntersectionView &view) {
// according to our current sliproad idea, there should only be one valid turn
auto itr = std::find_if(
view.begin(), view.end(), [](const auto &road) { return road.entry_allowed; });
@@ -353,12 +352,13 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
auto index_of_sliproad_in_target_intersection =
sliproad_in_target_intersection - target_intersection.begin();
if (isThroughStreet<IntersectionView>(index_of_sliproad_in_target_intersection,
target_intersection,
node_based_graph,
node_data_container,
name_table,
street_name_suffix_table))
if (isThroughStreet<extractor::intersection::IntersectionView>(
index_of_sliproad_in_target_intersection,
target_intersection,
node_based_graph,
node_data_container,
name_table,
street_name_suffix_table))
{
continue;
}
@@ -573,15 +573,16 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
}
else
{
const auto skip_traffic_light_intersection = intersection::getConnectedRoads<false>(
node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data,
{node_based_graph.GetTarget(sliproad_edge), candidate_road.eid});
const auto skip_traffic_light_intersection =
extractor::intersection::getConnectedRoads<false>(
node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data,
{node_based_graph.GetTarget(sliproad_edge), candidate_road.eid});
if (skip_traffic_light_intersection.isTrafficSignalOrBarrier() &&
node_based_graph.GetTarget(skip_traffic_light_intersection[1].eid) ==
main_road_intersection->node)
@@ -695,9 +696,9 @@ bool SliproadHandler::nextIntersectionIsTooFarAway(const NodeID start, const Edg
const auto threshold = scaledThresholdByRoadClass(MAX_SLIPROAD_THRESHOLD, // <- scales down
data.road_classification);
DistanceToNextIntersectionAccumulator accumulator{
extractor::intersection::DistanceToNextIntersectionAccumulator accumulator{
coordinate_extractor, node_based_graph, threshold};
const SkipTrafficSignalBarrierRoadSelector selector{};
const extractor::intersection::SkipTrafficSignalBarrierRoadSelector selector{};
(void)graph_walker.TraverseRoad(start, onto, accumulator, selector);
@@ -755,9 +756,10 @@ bool SliproadHandler::isValidSliproadArea(const double max_area,
return true;
}
bool SliproadHandler::isValidSliproadLink(const IntersectionViewData &sliproad,
const IntersectionViewData & /*first*/,
const IntersectionViewData &second) const
bool SliproadHandler::isValidSliproadLink(
const extractor::intersection::IntersectionViewData &sliproad,
const extractor::intersection::IntersectionViewData & /*first*/,
const extractor::intersection::IntersectionViewData &second) const
{
// If the Sliproad is not a link we don't care
const auto &sliproad_data = node_based_graph.GetEdgeData(sliproad.eid).flags;
@@ -791,7 +793,8 @@ bool SliproadHandler::allSameMode(const EdgeID from,
(target_annotation.travel_mode == sliproad_annotation.travel_mode);
}
bool SliproadHandler::canBeTargetOfSliproad(const IntersectionView &intersection)
bool SliproadHandler::canBeTargetOfSliproad(
const extractor::intersection::IntersectionView &intersection)
{
// Example to handle:
// .
@@ -819,44 +822,45 @@ bool SliproadHandler::canBeTargetOfSliproad(const IntersectionView &intersection
return true;
}
double SliproadHandler::scaledThresholdByRoadClass(const double max_threshold,
const RoadClassification &classification)
double
SliproadHandler::scaledThresholdByRoadClass(const double max_threshold,
const extractor::RoadClassification &classification)
{
double factor = 1.0;
switch (classification.GetPriority())
{
case RoadPriorityClass::MOTORWAY:
case extractor::RoadPriorityClass::MOTORWAY:
factor = 1.0;
break;
case RoadPriorityClass::TRUNK:
case extractor::RoadPriorityClass::TRUNK:
factor = 0.8;
break;
case RoadPriorityClass::PRIMARY:
case extractor::RoadPriorityClass::PRIMARY:
factor = 0.8;
break;
case RoadPriorityClass::SECONDARY:
case extractor::RoadPriorityClass::SECONDARY:
factor = 0.6;
break;
case RoadPriorityClass::TERTIARY:
case extractor::RoadPriorityClass::TERTIARY:
factor = 0.5;
break;
case RoadPriorityClass::MAIN_RESIDENTIAL:
case extractor::RoadPriorityClass::MAIN_RESIDENTIAL:
factor = 0.4;
break;
case RoadPriorityClass::SIDE_RESIDENTIAL:
case extractor::RoadPriorityClass::SIDE_RESIDENTIAL:
factor = 0.3;
break;
case RoadPriorityClass::LINK_ROAD:
case extractor::RoadPriorityClass::LINK_ROAD:
factor = 0.3;
break;
case RoadPriorityClass::CONNECTIVITY:
case extractor::RoadPriorityClass::CONNECTIVITY:
factor = 0.1;
break;
// What
case RoadPriorityClass::BIKE_PATH:
case RoadPriorityClass::FOOT_PATH:
case extractor::RoadPriorityClass::BIKE_PATH:
case extractor::RoadPriorityClass::FOOT_PATH:
default:
factor = 0.1;
}
@@ -868,5 +872,4 @@ double SliproadHandler::scaledThresholdByRoadClass(const double max_threshold,
}
} // namespace guidance
} // namespace extractor
} // namespace osrm
+4 -7
View File
@@ -6,21 +6,19 @@
namespace osrm
{
namespace extractor
{
namespace guidance
{
SuppressModeHandler::SuppressModeHandler(
const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &node_data_container,
const extractor::EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const extractor::RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const extractor::TurnLanesIndexedArray &turn_lanes_data,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
const extractor::SuffixTable &street_name_suffix_table)
: IntersectionHandler(node_based_graph,
node_data_container,
coordinates,
@@ -81,4 +79,3 @@ operator()(const NodeID, const EdgeID, Intersection intersection) const
}
}
}
}
+12 -14
View File
@@ -1,6 +1,6 @@
#include "guidance/turn_analysis.hpp"
#include "extractor/road_classification.hpp"
#include "guidance/constants.hpp"
#include "guidance/road_classification.hpp"
#include "util/coordinate.hpp"
#include "util/coordinate_calculation.hpp"
@@ -10,26 +10,24 @@
#include <unordered_set>
#include <utility>
using osrm::extractor::guidance::getTurnDirection;
using osrm::guidance::getTurnDirection;
namespace osrm
{
namespace extractor
{
namespace guidance
{
using EdgeData = util::NodeBasedDynamicGraph::EdgeData;
TurnAnalysis::TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &node_data_container,
const extractor::EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &node_coordinates,
const CompressedEdgeContainer &compressed_edge_container,
const RestrictionMap &restriction_map,
const extractor::CompressedEdgeContainer &compressed_edge_container,
const extractor::RestrictionMap &restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const extractor::TurnLanesIndexedArray &turn_lanes_data,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
const extractor::SuffixTable &street_name_suffix_table)
: node_based_graph(node_based_graph), roundabout_handler(node_based_graph,
node_data_container,
node_coordinates,
@@ -96,9 +94,10 @@ TurnAnalysis::TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph,
{
}
Intersection TurnAnalysis::AssignTurnTypes(const NodeID node_prior_to_intersection,
const EdgeID entering_via_edge,
const IntersectionView &intersection_view) const
Intersection TurnAnalysis::AssignTurnTypes(
const NodeID node_prior_to_intersection,
const EdgeID entering_via_edge,
const extractor::intersection::IntersectionView &intersection_view) const
{
// Roundabouts are a main priority. If there is a roundabout instruction present, we process the
// turn as a roundabout
@@ -110,7 +109,7 @@ Intersection TurnAnalysis::AssignTurnTypes(const NodeID node_prior_to_intersecti
std::transform(intersection_view.begin(),
intersection_view.end(),
std::back_inserter(intersection),
[&](const IntersectionViewData &data) {
[&](const extractor::intersection::IntersectionViewData &data) {
return ConnectedRoad(data,
{TurnType::Invalid, DirectionModifier::UTurn},
INVALID_LANE_DATAID);
@@ -203,5 +202,4 @@ Intersection TurnAnalysis::setTurnTypes(const NodeID node_prior_to_intersection,
}
} // namespace guidance
} // namespace extractor
} // namespace osrm
-3
View File
@@ -6,8 +6,6 @@
namespace osrm
{
namespace extractor
{
namespace guidance
{
@@ -87,5 +85,4 @@ classifyIntersection(Intersection intersection, const osrm::util::Coordinate &lo
}
} // namespace guidance
} // namespace extractor
} // namespace osrm
+35 -35
View File
@@ -1,7 +1,7 @@
#include "guidance/turn_discovery.hpp"
#include "extractor/intersection/coordinate_extractor.hpp"
#include "extractor/intersection/intersection_analysis.hpp"
#include "guidance/constants.hpp"
#include "guidance/coordinate_extractor.hpp"
#include "util/bearing.hpp"
#include "util/coordinate_calculation.hpp"
@@ -9,8 +9,6 @@ using osrm::util::angularDeviation;
namespace osrm
{
namespace extractor
{
namespace guidance
{
namespace lanes
@@ -20,16 +18,16 @@ bool findPreviousIntersection(const NodeID node_v,
const EdgeID via_edge,
const Intersection &intersection,
const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &node_data_container,
const extractor::EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &node_coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const extractor::RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const extractor::TurnLanesIndexedArray &turn_lanes_data,
// output parameters
NodeID &result_node,
EdgeID &result_via_edge,
IntersectionView &result_intersection)
extractor::intersection::IntersectionView &result_intersection)
{
/* We need to find the intersection that is located prior to via_edge.
@@ -45,7 +43,7 @@ bool findPreviousIntersection(const NodeID node_v,
*/
const constexpr double COMBINE_DISTANCE_CUTOFF = 30;
const CoordinateExtractor coordinate_extractor(
const extractor::intersection::CoordinateExtractor coordinate_extractor(
node_based_graph, compressed_geometries, node_coordinates);
const auto coordinates_along_via_edge =
@@ -75,14 +73,14 @@ bool findPreviousIntersection(const NodeID node_v,
return false;
const auto node_v_reverse_intersection =
intersection::getConnectedRoads<true>(node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data,
{node_w, u_turn_at_node_w});
extractor::intersection::getConnectedRoads<true>(node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data,
{node_w, u_turn_at_node_w});
// Continue along the straightmost turn. If there is no straight turn, we cannot find a valid
// previous intersection.
const auto straightmost_at_v_in_reverse =
@@ -94,15 +92,15 @@ bool findPreviousIntersection(const NodeID node_v,
return false;
const auto node_u = node_based_graph.GetTarget(straightmost_at_v_in_reverse->eid);
const auto node_u_reverse_intersection =
intersection::getConnectedRoads<true>(node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data,
{node_v, straightmost_at_v_in_reverse->eid});
const auto node_u_reverse_intersection = extractor::intersection::getConnectedRoads<true>(
node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data,
{node_v, straightmost_at_v_in_reverse->eid});
// now check that the u-turn at the given intersection connects to via-edge
// The u-turn at the now found intersection should, hopefully, represent the previous edge.
@@ -120,19 +118,22 @@ bool findPreviousIntersection(const NodeID node_v,
return false;
}
result_intersection = intersection::getConnectedRoads<false>(node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data,
{node_u, result_via_edge});
result_intersection =
extractor::intersection::getConnectedRoads<false>(node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data,
{node_u, result_via_edge});
const auto check_via_edge =
result_intersection.end() !=
std::find_if(result_intersection.begin(),
result_intersection.end(),
[via_edge](const IntersectionViewData &road) { return road.eid == via_edge; });
[via_edge](const extractor::intersection::IntersectionViewData &road) {
return road.eid == via_edge;
});
if (!check_via_edge)
{
@@ -146,5 +147,4 @@ bool findPreviousIntersection(const NodeID node_v,
} // namespace lanes
} // namespace guidance
} // namespace extractor
} // namespace osrm
+6 -9
View File
@@ -11,13 +11,13 @@
#include <boost/assert.hpp>
#include <boost/optional.hpp>
using osrm::extractor::guidance::getTurnDirection;
using osrm::guidance::getTurnDirection;
using osrm::util::angularDeviation;
namespace
{
using namespace osrm::extractor::guidance;
using namespace osrm::guidance;
// given two adjacent roads in clockwise order and `road1` being a candidate for a fork,
// return false, if next road `road2` is also a fork candidate or
// return true, if `road2` is not a suitable fork candidate and thus, `road1` the outermost fork
@@ -72,8 +72,6 @@ InputIt findOutermostForkCandidate(const InputIt begin, const InputIt end)
namespace osrm
{
namespace extractor
{
namespace guidance
{
@@ -111,14 +109,14 @@ std::size_t TurnHandler::Fork::getLeftIndex() const
}
TurnHandler::TurnHandler(const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &node_data_container,
const extractor::EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const extractor::RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
const extractor::TurnLanesIndexedArray &turn_lanes_data,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
const extractor::SuffixTable &street_name_suffix_table)
: IntersectionHandler(node_based_graph,
node_data_container,
coordinates,
@@ -844,5 +842,4 @@ void TurnHandler::handleDistinctConflict(const EdgeID via_edge,
}
} // namespace guidance
} // namespace extractor
} // namespace osrm
+39 -36
View File
@@ -1,5 +1,6 @@
#include "guidance/turn_lane_augmentation.hpp"
#include "guidance/turn_lane_types.hpp"
#include "extractor/turn_lane_types.hpp"
#include "util/log.hpp"
#include <algorithm>
@@ -9,8 +10,6 @@
namespace osrm
{
namespace extractor
{
namespace guidance
{
namespace lanes
@@ -19,14 +18,15 @@ namespace lanes
namespace
{
const constexpr TurnLaneType::Mask tag_by_modifier[] = {TurnLaneType::uturn,
TurnLaneType::sharp_right,
TurnLaneType::right,
TurnLaneType::slight_right,
TurnLaneType::straight,
TurnLaneType::slight_left,
TurnLaneType::left,
TurnLaneType::sharp_left};
const constexpr extractor::TurnLaneType::Mask tag_by_modifier[] = {
extractor::TurnLaneType::uturn,
extractor::TurnLaneType::sharp_right,
extractor::TurnLaneType::right,
extractor::TurnLaneType::slight_right,
extractor::TurnLaneType::straight,
extractor::TurnLaneType::slight_left,
extractor::TurnLaneType::left,
extractor::TurnLaneType::sharp_left};
std::size_t getNumberOfTurns(const Intersection &intersection)
{
@@ -214,12 +214,13 @@ LaneDataVector handleRenamingSituations(const std::size_t none_index,
// find missing tag and augment neighboring, if possible
if (none_index == 0)
{
if (has_right &&
(lane_data.size() == 1 || (lane_data[none_index + 1].tag != TurnLaneType::sharp_right &&
lane_data[none_index + 1].tag != TurnLaneType::right)))
if (has_right && (lane_data.size() == 1 ||
(lane_data[none_index + 1].tag != extractor::TurnLaneType::sharp_right &&
lane_data[none_index + 1].tag != extractor::TurnLaneType::right)))
{
lane_data[none_index].tag = TurnLaneType::right;
if (lane_data.size() > 1 && lane_data[none_index + 1].tag == TurnLaneType::straight)
lane_data[none_index].tag = extractor::TurnLaneType::right;
if (lane_data.size() > 1 &&
lane_data[none_index + 1].tag == extractor::TurnLaneType::straight)
{
lane_data[none_index + 1].from = lane_data[none_index].from;
// turning right through a possible through lane is not possible
@@ -227,39 +228,40 @@ LaneDataVector handleRenamingSituations(const std::size_t none_index,
}
}
else if (has_through &&
(lane_data.size() == 1 || lane_data[none_index + 1].tag != TurnLaneType::straight))
(lane_data.size() == 1 ||
lane_data[none_index + 1].tag != extractor::TurnLaneType::straight))
{
lane_data[none_index].tag = TurnLaneType::straight;
lane_data[none_index].tag = extractor::TurnLaneType::straight;
}
}
else if (none_index + 1 == lane_data.size())
{
if (has_left && ((lane_data[none_index - 1].tag != TurnLaneType::sharp_left &&
lane_data[none_index - 1].tag != TurnLaneType::left)))
if (has_left && ((lane_data[none_index - 1].tag != extractor::TurnLaneType::sharp_left &&
lane_data[none_index - 1].tag != extractor::TurnLaneType::left)))
{
lane_data[none_index].tag = TurnLaneType::left;
if (lane_data[none_index - 1].tag == TurnLaneType::straight)
lane_data[none_index].tag = extractor::TurnLaneType::left;
if (lane_data[none_index - 1].tag == extractor::TurnLaneType::straight)
{
lane_data[none_index - 1].to = lane_data[none_index].to;
// turning left through a possible through lane is not possible
lane_data[none_index].from = lane_data[none_index].to;
}
}
else if (has_through && lane_data[none_index - 1].tag != TurnLaneType::straight)
else if (has_through && lane_data[none_index - 1].tag != extractor::TurnLaneType::straight)
{
lane_data[none_index].tag = TurnLaneType::straight;
lane_data[none_index].tag = extractor::TurnLaneType::straight;
}
}
else
{
if ((lane_data[none_index + 1].tag == TurnLaneType::left ||
lane_data[none_index + 1].tag == TurnLaneType::slight_left ||
lane_data[none_index + 1].tag == TurnLaneType::sharp_left) &&
(lane_data[none_index - 1].tag == TurnLaneType::right ||
lane_data[none_index - 1].tag == TurnLaneType::slight_right ||
lane_data[none_index - 1].tag == TurnLaneType::sharp_right))
if ((lane_data[none_index + 1].tag == extractor::TurnLaneType::left ||
lane_data[none_index + 1].tag == extractor::TurnLaneType::slight_left ||
lane_data[none_index + 1].tag == extractor::TurnLaneType::sharp_left) &&
(lane_data[none_index - 1].tag == extractor::TurnLaneType::right ||
lane_data[none_index - 1].tag == extractor::TurnLaneType::slight_right ||
lane_data[none_index - 1].tag == extractor::TurnLaneType::sharp_right))
{
lane_data[none_index].tag = TurnLaneType::straight;
lane_data[none_index].tag = extractor::TurnLaneType::straight;
}
}
return lane_data;
@@ -275,8 +277,8 @@ LaneDataVector handleRenamingSituations(const std::size_t none_index,
LaneDataVector handleNoneValueAtSimpleTurn(LaneDataVector lane_data,
const Intersection &intersection)
{
const bool needs_no_processing =
(intersection.empty() || lane_data.empty() || !hasTag(TurnLaneType::none, lane_data));
const bool needs_no_processing = (intersection.empty() || lane_data.empty() ||
!hasTag(extractor::TurnLaneType::none, lane_data));
if (needs_no_processing)
return lane_data;
@@ -305,11 +307,13 @@ LaneDataVector handleNoneValueAtSimpleTurn(LaneDataVector lane_data,
const std::size_t connection_count =
getNumberOfTurns(intersection) -
((intersection[0].entry_allowed && lane_data.back().tag != TurnLaneType::uturn) ? 1 : 0);
((intersection[0].entry_allowed && lane_data.back().tag != extractor::TurnLaneType::uturn)
? 1
: 0);
// TODO check for impossible turns to see whether the turn lane is at the correct place
const std::size_t none_index =
std::distance(lane_data.begin(), findTag(TurnLaneType::none, lane_data));
std::distance(lane_data.begin(), findTag(extractor::TurnLaneType::none, lane_data));
BOOST_ASSERT(none_index != lane_data.size());
// we have to create multiple turns
if (connection_count > lane_data.size())
@@ -348,5 +352,4 @@ LaneDataVector handleNoneValueAtSimpleTurn(LaneDataVector lane_data,
} // namespace lanes
} // namespace guidance
} // namespace extractor
} // namespace osrm
+2 -3
View File
@@ -10,12 +10,12 @@
namespace osrm
{
namespace extractor
{
namespace guidance
{
namespace lanes
{
namespace TurnLaneType = extractor::TurnLaneType;
using TurnLaneDescription = extractor::TurnLaneDescription;
bool TurnLaneData::operator<(const TurnLaneData &other) const
{
@@ -156,5 +156,4 @@ bool hasTag(const TurnLaneType::Mask tag, const LaneDataVector &data)
} // namespace lanes
} // namespace guidance
} // namespace extractor
} // namespace osrm
+15 -16
View File
@@ -17,12 +17,12 @@ using osrm::util::angularDeviation;
namespace osrm
{
namespace extractor
{
namespace guidance
{
namespace lanes
{
namespace TurnLaneType = extractor::TurnLaneType;
using TurnLaneDescription = extractor::TurnLaneDescription;
namespace
{
@@ -35,13 +35,13 @@ std::size_t getNumberOfTurns(const Intersection &intersection)
} // namespace
TurnLaneHandler::TurnLaneHandler(const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &node_data_container,
const extractor::EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &node_coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const RestrictionMap &node_restriction_map,
const extractor::RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data,
LaneDescriptionMap &lane_description_map,
const extractor::TurnLanesIndexedArray &turn_lanes_data,
extractor::LaneDescriptionMap &lane_description_map,
const TurnAnalysis &turn_analysis,
util::guidance::LaneDataIdMap &id_map)
: node_based_graph(node_based_graph), node_data_container(node_data_container),
@@ -209,7 +209,7 @@ TurnLaneScenario TurnLaneHandler::deduceScenario(const NodeID at,
// Due to sliproads, we might need access to the previous intersection at this point already;
previous_node = SPECIAL_NODEID;
previous_via_edge = SPECIAL_EDGEID;
IntersectionView previous_intersection_view;
extractor::intersection::IntersectionView previous_intersection_view;
if (findPreviousIntersection(at,
via_edge,
intersection,
@@ -575,14 +575,14 @@ std::pair<LaneDataVector, LaneDataVector> TurnLaneHandler::partitionLaneData(
const auto next_intersection = turn_analysis.AssignTurnTypes(
at,
straightmost->eid,
intersection::getConnectedRoads<false>(node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data,
{at, straightmost->eid}));
extractor::intersection::getConnectedRoads<false>(node_based_graph,
node_data_container,
node_coordinates,
compressed_geometries,
node_restriction_map,
barrier_nodes,
turn_lanes_data,
{at, straightmost->eid}));
// check where we can match turn lanes
std::size_t straightmost_tag_index = turn_lane_data.size();
@@ -815,5 +815,4 @@ Intersection TurnLaneHandler::handleSliproadTurn(Intersection intersection,
} // namespace lanes
} // namespace guidance
} // namespace extractor
} // namespace osrm
+1 -5
View File
@@ -10,12 +10,11 @@ using osrm::util::angularDeviation;
namespace osrm
{
namespace extractor
{
namespace guidance
{
namespace lanes
{
namespace TurnLaneType = extractor::TurnLaneType;
// Translate Turn Tags into a Matching Direction Modifier
DirectionModifier::Enum getMatchingModifier(const TurnLaneType::Mask tag)
@@ -54,8 +53,6 @@ DirectionModifier::Enum getMatchingModifier(const TurnLaneType::Mask tag)
// check whether a match of a given tag and a turn instruction can be seen as valid
bool isValidMatch(const TurnLaneType::Mask tag, const TurnInstruction instruction)
{
using extractor::guidance::hasLeftModifier;
using extractor::guidance::hasRightModifier;
const auto isMirroredModifier = [](const TurnInstruction instruction) {
return instruction.type == TurnType::Merge;
};
@@ -277,5 +274,4 @@ Intersection triviallyMatchLanesToTurns(Intersection intersection,
} // namespace lane_matching
} // namespace guidance
} // namespace extractor
} // namespace osrm
+18 -18
View File
@@ -17,11 +17,12 @@
#include "extractor/edge_based_edge.hpp"
#include "extractor/edge_based_node.hpp"
#include "extractor/files.hpp"
#include "extractor/original_edge_data.hpp"
#include "extractor/packed_osm_ids.hpp"
#include "extractor/profile_properties.hpp"
#include "extractor/query_node.hpp"
#include "extractor/travel_mode.hpp"
#include "guidance/files.hpp"
#include "guidance/turn_instruction.hpp"
#include "partitioner/cell_storage.hpp"
@@ -227,11 +228,11 @@ void Storage::PopulateLayout(DataLayout &layout)
{
io::FileReader reader(config.GetPath(".osrm.tls"), io::FileReader::VerifyFingerprint);
auto num_offsets = reader.ReadVectorSize<std::uint32_t>();
auto num_masks = reader.ReadVectorSize<extractor::guidance::TurnLaneType::Mask>();
auto num_masks = reader.ReadVectorSize<extractor::TurnLaneType::Mask>();
layout.SetBlockSize<std::uint32_t>(DataLayout::LANE_DESCRIPTION_OFFSETS, num_offsets);
layout.SetBlockSize<extractor::guidance::TurnLaneType::Mask>(
DataLayout::LANE_DESCRIPTION_MASKS, num_masks);
layout.SetBlockSize<extractor::TurnLaneType::Mask>(DataLayout::LANE_DESCRIPTION_MASKS,
num_masks);
}
// Loading information for original edges
@@ -244,8 +245,8 @@ void Storage::PopulateLayout(DataLayout &layout)
number_of_original_edges);
layout.SetBlockSize<util::guidance::TurnBearing>(DataLayout::POST_TURN_BEARING,
number_of_original_edges);
layout.SetBlockSize<extractor::guidance::TurnInstruction>(DataLayout::TURN_INSTRUCTION,
number_of_original_edges);
layout.SetBlockSize<guidance::TurnInstruction>(DataLayout::TURN_INSTRUCTION,
number_of_original_edges);
layout.SetBlockSize<LaneDataID>(DataLayout::LANE_DATA_ID, number_of_original_edges);
layout.SetBlockSize<EntryClassID>(DataLayout::ENTRY_CLASSID, number_of_original_edges);
}
@@ -661,9 +662,9 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
util::vector_view<std::uint32_t> offsets(
offsets_ptr, layout.num_entries[storage::DataLayout::LANE_DESCRIPTION_OFFSETS]);
auto masks_ptr = layout.GetBlockPtr<extractor::guidance::TurnLaneType::Mask, true>(
auto masks_ptr = layout.GetBlockPtr<extractor::TurnLaneType::Mask, true>(
memory_ptr, storage::DataLayout::LANE_DESCRIPTION_MASKS);
util::vector_view<extractor::guidance::TurnLaneType::Mask> masks(
util::vector_view<extractor::TurnLaneType::Mask> masks(
masks_ptr, layout.num_entries[storage::DataLayout::LANE_DESCRIPTION_MASKS]);
extractor::files::readTurnLaneDescriptions(config.GetPath(".osrm.tls"), offsets, masks);
@@ -697,10 +698,9 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
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, true>(
memory_ptr, storage::DataLayout::TURN_INSTRUCTION);
util::vector_view<extractor::guidance::TurnInstruction> turn_instructions(
const auto turn_instruction_list_ptr = layout.GetBlockPtr<guidance::TurnInstruction, true>(
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 =
@@ -718,13 +718,13 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
util::vector_view<util::guidance::TurnBearing> post_turn_bearings(
post_turn_bearing_ptr, layout.num_entries[storage::DataLayout::POST_TURN_BEARING]);
extractor::TurnDataView turn_data(std::move(turn_instructions),
std::move(lane_data_ids),
std::move(entry_class_ids),
std::move(pre_turn_bearings),
std::move(post_turn_bearings));
guidance::TurnDataView turn_data(std::move(turn_instructions),
std::move(lane_data_ids),
std::move(entry_class_ids),
std::move(pre_turn_bearings),
std::move(post_turn_bearings));
extractor::files::readTurnData(config.GetPath(".osrm.edges"), turn_data);
guidance::files::readTurnData(config.GetPath(".osrm.edges"), turn_data);
}
// load compressed geometry
+2
View File
@@ -9,6 +9,8 @@
#include "extractor/restriction.hpp"
#include "extractor/serialization.hpp"
#include "guidance/files.hpp"
#include "storage/io.hpp"
#include "util/exception.hpp"