move hardcoded road priorities into profiles, change road classification
This commit is contained in:
committed by
Patrick Niklaus
parent
fd6bb5ec1f
commit
1fc63e1e72
@@ -425,7 +425,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
const int32_t turn_penalty = scripting_environment.GetTurnPenalty(180. - turn.angle);
|
||||
const auto turn_instruction = turn.instruction;
|
||||
|
||||
if (guidance::isUturn(turn_instruction))
|
||||
if (turn_instruction.direction_modifier == guidance::DirectionModifier::UTurn)
|
||||
{
|
||||
distance += profile_properties.u_turn_penalty;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include "extractor/extractor_callbacks.hpp"
|
||||
#include "extractor/external_memory_node.hpp"
|
||||
#include "extractor/extraction_containers.hpp"
|
||||
#include "extractor/extraction_node.hpp"
|
||||
#include "extractor/extraction_way.hpp"
|
||||
#include "extractor/extractor_callbacks.hpp"
|
||||
#include "extractor/guidance/road_classification.hpp"
|
||||
#include "extractor/restriction.hpp"
|
||||
|
||||
#include "util/for_each_pair.hpp"
|
||||
@@ -140,13 +141,7 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
||||
}
|
||||
|
||||
// FIXME this need to be moved into the profiles
|
||||
const char *data = input_way.get_value_by_key("highway");
|
||||
guidance::RoadClassificationData road_classification;
|
||||
if (data)
|
||||
{
|
||||
road_classification.road_class = guidance::functionalRoadClassFromTag(data);
|
||||
}
|
||||
|
||||
const guidance::RoadClassification road_classification = parsed_way.road_classification;
|
||||
const auto laneStringToDescription = [](std::string lane_string) -> TurnLaneDescription {
|
||||
if (lane_string.empty())
|
||||
return {};
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
#include "extractor/guidance/classification_data.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
FunctionalRoadClass functionalRoadClassFromTag(std::string const &value)
|
||||
{
|
||||
// FIXME at some point this should be part of the profiles
|
||||
const static auto class_hash = [] {
|
||||
std::unordered_map<std::string, FunctionalRoadClass> hash;
|
||||
hash["motorway"] = FunctionalRoadClass::MOTORWAY;
|
||||
hash["motorway_link"] = FunctionalRoadClass::MOTORWAY_LINK;
|
||||
hash["trunk"] = FunctionalRoadClass::TRUNK;
|
||||
hash["trunk_link"] = FunctionalRoadClass::TRUNK_LINK;
|
||||
hash["primary"] = FunctionalRoadClass::PRIMARY;
|
||||
hash["primary_link"] = FunctionalRoadClass::PRIMARY_LINK;
|
||||
hash["secondary"] = FunctionalRoadClass::SECONDARY;
|
||||
hash["secondary_link"] = FunctionalRoadClass::SECONDARY_LINK;
|
||||
hash["tertiary"] = FunctionalRoadClass::TERTIARY;
|
||||
hash["tertiary_link"] = FunctionalRoadClass::TERTIARY_LINK;
|
||||
hash["unclassified"] = FunctionalRoadClass::UNCLASSIFIED;
|
||||
hash["residential"] = FunctionalRoadClass::RESIDENTIAL;
|
||||
hash["service"] = FunctionalRoadClass::SERVICE;
|
||||
hash["living_street"] = FunctionalRoadClass::LIVING_STREET;
|
||||
hash["track"] = FunctionalRoadClass::LOW_PRIORITY_ROAD;
|
||||
hash["road"] = FunctionalRoadClass::LOW_PRIORITY_ROAD;
|
||||
hash["path"] = FunctionalRoadClass::LOW_PRIORITY_ROAD;
|
||||
hash["driveway"] = FunctionalRoadClass::LOW_PRIORITY_ROAD;
|
||||
return hash;
|
||||
}();
|
||||
|
||||
if (class_hash.find(value) != class_hash.end())
|
||||
{
|
||||
return class_hash.find(value)->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO activate again, when road classes are moved to the profile
|
||||
// util::SimpleLogger().Write(logDEBUG) << "Unknown road class encountered: " << value;
|
||||
return FunctionalRoadClass::UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
} // ns guidance
|
||||
} // ns extractor
|
||||
} // ns osrm
|
||||
@@ -48,9 +48,9 @@ TurnType::Enum IntersectionHandler::findBasicTurnType(const EdgeID via_edge,
|
||||
const auto &in_data = node_based_graph.GetEdgeData(via_edge);
|
||||
const auto &out_data = node_based_graph.GetEdgeData(road.turn.eid);
|
||||
|
||||
bool on_ramp = isRampClass(in_data.road_classification.road_class);
|
||||
bool on_ramp = in_data.road_classification.IsRampClass();
|
||||
|
||||
bool onto_ramp = isRampClass(out_data.road_classification.road_class);
|
||||
bool onto_ramp = out_data.road_classification.IsRampClass();
|
||||
|
||||
if (!on_ramp && onto_ramp)
|
||||
return TurnType::OnRamp;
|
||||
@@ -130,10 +130,10 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
|
||||
ConnectedRoad &right) const
|
||||
{
|
||||
const auto &in_data = node_based_graph.GetEdgeData(via_edge);
|
||||
const bool low_priority_left = isLowPriorityRoadClass(
|
||||
node_based_graph.GetEdgeData(left.turn.eid).road_classification.road_class);
|
||||
const bool low_priority_right = isLowPriorityRoadClass(
|
||||
node_based_graph.GetEdgeData(right.turn.eid).road_classification.road_class);
|
||||
const bool low_priority_left =
|
||||
node_based_graph.GetEdgeData(left.turn.eid).road_classification.IsLowPriorityRoadClass();
|
||||
const bool low_priority_right =
|
||||
node_based_graph.GetEdgeData(right.turn.eid).road_classification.IsLowPriorityRoadClass();
|
||||
if ((angularDeviation(left.turn.angle, STRAIGHT_ANGLE) < MAXIMAL_ALLOWED_NO_TURN_DEVIATION &&
|
||||
angularDeviation(right.turn.angle, STRAIGHT_ANGLE) > FUZZY_ANGLE_DIFFERENCE))
|
||||
{
|
||||
@@ -339,6 +339,7 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
double best_continue_deviation = 180;
|
||||
|
||||
const EdgeData &in_data = node_based_graph.GetEdgeData(via_edge);
|
||||
const auto in_classification = in_data.road_classification;
|
||||
for (std::size_t i = 1; i < intersection.size(); ++i)
|
||||
{
|
||||
const double deviation = angularDeviation(intersection[i].turn.angle, STRAIGHT_ANGLE);
|
||||
@@ -349,12 +350,16 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
}
|
||||
|
||||
const auto out_data = node_based_graph.GetEdgeData(intersection[i].turn.eid);
|
||||
auto continue_class = node_based_graph.GetEdgeData(intersection[best_continue].turn.eid)
|
||||
.road_classification.road_class;
|
||||
auto continue_class =
|
||||
node_based_graph.GetEdgeData(intersection[best_continue].turn.eid).road_classification;
|
||||
if (intersection[i].entry_allowed && out_data.name_id == in_data.name_id &&
|
||||
(best_continue == 0 || continue_class > out_data.road_classification.road_class ||
|
||||
(best_continue == 0 ||
|
||||
(continue_class.GetPriority() > out_data.road_classification.GetPriority() &&
|
||||
in_classification != continue_class) ||
|
||||
(deviation < best_continue_deviation &&
|
||||
out_data.road_classification.road_class == continue_class)))
|
||||
out_data.road_classification == continue_class) ||
|
||||
(continue_class != in_classification &&
|
||||
out_data.road_classification == continue_class)))
|
||||
{
|
||||
best_continue_deviation = deviation;
|
||||
best_continue = i;
|
||||
@@ -368,10 +373,8 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
return 0;
|
||||
// has no obvious continued road
|
||||
if (best_continue == 0 || best_continue_deviation >= 2 * NARROW_TURN_ANGLE ||
|
||||
(node_based_graph.GetEdgeData(intersection[best_continue].turn.eid)
|
||||
.road_classification.road_class ==
|
||||
node_based_graph.GetEdgeData(intersection[best].turn.eid)
|
||||
.road_classification.road_class &&
|
||||
(node_based_graph.GetEdgeData(intersection[best_continue].turn.eid).road_classification ==
|
||||
node_based_graph.GetEdgeData(intersection[best].turn.eid).road_classification &&
|
||||
std::abs(best_continue_deviation) > 1 && best_deviation / best_continue_deviation < 0.75))
|
||||
{
|
||||
// Find left/right deviation
|
||||
@@ -418,9 +421,8 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
continue;
|
||||
|
||||
if (angularDeviation(intersection[i].turn.angle, STRAIGHT_ANGLE) / deviation < 1.1 &&
|
||||
continue_data.road_classification.road_class ==
|
||||
node_based_graph.GetEdgeData(intersection[i].turn.eid)
|
||||
.road_classification.road_class)
|
||||
continue_data.road_classification ==
|
||||
node_based_graph.GetEdgeData(intersection[i].turn.eid).road_classification)
|
||||
return 0;
|
||||
}
|
||||
return best_continue; // no obvious turn
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "extractor/guidance/motorway_handler.hpp"
|
||||
#include "extractor/guidance/classification_data.hpp"
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/motorway_handler.hpp"
|
||||
#include "extractor/guidance/road_classification.hpp"
|
||||
#include "extractor/guidance/toolkit.hpp"
|
||||
|
||||
#include "util/guidance/toolkit.hpp"
|
||||
@@ -20,25 +20,26 @@ namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
namespace detail
|
||||
namespace
|
||||
{
|
||||
|
||||
inline bool isMotorwayClass(EdgeID eid, const util::NodeBasedDynamicGraph &node_based_graph)
|
||||
{
|
||||
return isMotorwayClass(node_based_graph.GetEdgeData(eid).road_classification.road_class);
|
||||
return node_based_graph.GetEdgeData(eid).road_classification.IsMotorwayClass();
|
||||
}
|
||||
inline FunctionalRoadClass roadClass(const ConnectedRoad &road,
|
||||
const util::NodeBasedDynamicGraph &graph)
|
||||
inline RoadClassification roadClass(const ConnectedRoad &road,
|
||||
const util::NodeBasedDynamicGraph &graph)
|
||||
{
|
||||
return graph.GetEdgeData(road.turn.eid).road_classification.road_class;
|
||||
return graph.GetEdgeData(road.turn.eid).road_classification;
|
||||
}
|
||||
|
||||
inline bool isRampClass(EdgeID eid, const util::NodeBasedDynamicGraph &node_based_graph)
|
||||
{
|
||||
return isRampClass(node_based_graph.GetEdgeData(eid).road_classification.road_class);
|
||||
}
|
||||
return node_based_graph.GetEdgeData(eid).road_classification.IsRampClass();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MotorwayHandler::MotorwayHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
const util::NameTable &name_table,
|
||||
@@ -56,36 +57,29 @@ bool MotorwayHandler::canProcess(const NodeID,
|
||||
|
||||
for (const auto &road : intersection)
|
||||
{
|
||||
const auto &out_data = node_based_graph.GetEdgeData(road.turn.eid);
|
||||
// not merging or forking?
|
||||
if (road.entry_allowed && angularDeviation(road.turn.angle, STRAIGHT_ANGLE) > 60)
|
||||
return false;
|
||||
else if (out_data.road_classification.road_class == FunctionalRoadClass::MOTORWAY ||
|
||||
out_data.road_classification.road_class == FunctionalRoadClass::TRUNK)
|
||||
else if (isMotorwayClass(road.turn.eid, node_based_graph))
|
||||
{
|
||||
if (road.entry_allowed)
|
||||
has_motorway = true;
|
||||
}
|
||||
else if (!isRampClass(out_data.road_classification.road_class))
|
||||
else if (!isRampClass(road.turn.eid, node_based_graph))
|
||||
has_normal_roads = true;
|
||||
}
|
||||
|
||||
if (has_normal_roads)
|
||||
return false;
|
||||
|
||||
const auto &in_data = node_based_graph.GetEdgeData(via_eid);
|
||||
return has_motorway ||
|
||||
in_data.road_classification.road_class == FunctionalRoadClass::MOTORWAY ||
|
||||
in_data.road_classification.road_class == FunctionalRoadClass::TRUNK;
|
||||
return has_motorway || isMotorwayClass(via_eid, node_based_graph);
|
||||
}
|
||||
|
||||
Intersection MotorwayHandler::
|
||||
operator()(const NodeID, const EdgeID via_eid, Intersection intersection) const
|
||||
{
|
||||
const auto &in_data = node_based_graph.GetEdgeData(via_eid);
|
||||
|
||||
// coming from motorway
|
||||
if (isMotorwayClass(in_data.road_classification.road_class))
|
||||
if (isMotorwayClass(via_eid, node_based_graph))
|
||||
{
|
||||
intersection = fromMotorway(via_eid, std::move(intersection));
|
||||
std::for_each(intersection.begin(), intersection.end(), [](ConnectedRoad &road) {
|
||||
@@ -104,13 +98,13 @@ operator()(const NodeID, const EdgeID via_eid, Intersection intersection) const
|
||||
Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection intersection) const
|
||||
{
|
||||
const auto &in_data = node_based_graph.GetEdgeData(via_eid);
|
||||
BOOST_ASSERT(isMotorwayClass(in_data.road_classification.road_class));
|
||||
BOOST_ASSERT(isMotorwayClass(via_eid, node_based_graph));
|
||||
|
||||
const auto countExitingMotorways = [this](const Intersection &intersection) {
|
||||
unsigned count = 0;
|
||||
for (const auto &road : intersection)
|
||||
{
|
||||
if (road.entry_allowed && detail::isMotorwayClass(road.turn.eid, node_based_graph))
|
||||
if (road.entry_allowed && isMotorwayClass(road.turn.eid, node_based_graph))
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
@@ -122,8 +116,7 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
{
|
||||
const auto &out_data = node_based_graph.GetEdgeData(road.turn.eid);
|
||||
if (road.turn.angle != 0 && in_data.name_id == out_data.name_id &&
|
||||
in_data.name_id != EMPTY_NAMEID &&
|
||||
isMotorwayClass(out_data.road_classification.road_class))
|
||||
in_data.name_id != EMPTY_NAMEID && isMotorwayClass(road.turn.eid, node_based_graph))
|
||||
return road.turn.angle;
|
||||
}
|
||||
return intersection[0].turn.angle;
|
||||
@@ -134,8 +127,7 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
double best = 180;
|
||||
for (const auto &road : intersection)
|
||||
{
|
||||
const auto &out_data = node_based_graph.GetEdgeData(road.turn.eid);
|
||||
if (isMotorwayClass(out_data.road_classification.road_class) &&
|
||||
if (isMotorwayClass(road.turn.eid, node_based_graph) &&
|
||||
angularDeviation(road.turn.angle, STRAIGHT_ANGLE) < best)
|
||||
{
|
||||
best = angularDeviation(road.turn.angle, STRAIGHT_ANGLE);
|
||||
@@ -183,10 +175,10 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
}
|
||||
}
|
||||
else if (intersection.size() == 4 &&
|
||||
detail::roadClass(intersection[1], node_based_graph) ==
|
||||
detail::roadClass(intersection[2], node_based_graph) &&
|
||||
detail::roadClass(intersection[2], node_based_graph) ==
|
||||
detail::roadClass(intersection[3], node_based_graph))
|
||||
roadClass(intersection[1], node_based_graph) ==
|
||||
roadClass(intersection[2], node_based_graph) &&
|
||||
roadClass(intersection[2], node_based_graph) ==
|
||||
roadClass(intersection[3], node_based_graph))
|
||||
{
|
||||
// tripple fork at the end
|
||||
assignFork(via_eid, intersection[3], intersection[2], intersection[1]);
|
||||
@@ -212,7 +204,7 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
{
|
||||
if (road.entry_allowed)
|
||||
{
|
||||
BOOST_ASSERT(detail::isRampClass(road.turn.eid, node_based_graph));
|
||||
BOOST_ASSERT(isRampClass(road.turn.eid, node_based_graph));
|
||||
road.turn.instruction =
|
||||
TurnInstruction::SUPPRESSED(getTurnDirection(road.turn.angle));
|
||||
}
|
||||
@@ -223,7 +215,7 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
// normal motorway passing some ramps or mering onto another motorway
|
||||
if (intersection.size() == 2)
|
||||
{
|
||||
BOOST_ASSERT(!detail::isRampClass(intersection[1].turn.eid, node_based_graph));
|
||||
BOOST_ASSERT(!isRampClass(intersection[1].turn.eid, node_based_graph));
|
||||
|
||||
intersection[1].turn.instruction =
|
||||
getInstructionForObvious(intersection.size(),
|
||||
@@ -248,16 +240,16 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
else if (road.turn.angle < continue_angle)
|
||||
{
|
||||
road.turn.instruction = {
|
||||
detail::isRampClass(road.turn.eid, node_based_graph) ? TurnType::OffRamp
|
||||
: TurnType::Turn,
|
||||
isRampClass(road.turn.eid, node_based_graph) ? TurnType::OffRamp
|
||||
: TurnType::Turn,
|
||||
(road.turn.angle < 145) ? DirectionModifier::Right
|
||||
: DirectionModifier::SlightRight};
|
||||
}
|
||||
else if (road.turn.angle > continue_angle)
|
||||
{
|
||||
road.turn.instruction = {
|
||||
detail::isRampClass(road.turn.eid, node_based_graph) ? TurnType::OffRamp
|
||||
: TurnType::Turn,
|
||||
isRampClass(road.turn.eid, node_based_graph) ? TurnType::OffRamp
|
||||
: TurnType::Turn,
|
||||
(road.turn.angle > 215) ? DirectionModifier::Left
|
||||
: DirectionModifier::SlightLeft};
|
||||
}
|
||||
@@ -285,7 +277,7 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
for (std::size_t i = 0; i < intersection.size(); ++i)
|
||||
{
|
||||
if (intersection[i].entry_allowed &&
|
||||
detail::isMotorwayClass(intersection[i].turn.eid, node_based_graph))
|
||||
isMotorwayClass(intersection[i].turn.eid, node_based_graph))
|
||||
{
|
||||
if (first_valid < intersection.size())
|
||||
{
|
||||
@@ -309,7 +301,7 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
for (std::size_t i = 0; i < intersection.size(); ++i)
|
||||
{
|
||||
if (intersection[i].entry_allowed &&
|
||||
detail::isMotorwayClass(intersection[i].turn.eid, node_based_graph))
|
||||
isMotorwayClass(intersection[i].turn.eid, node_based_graph))
|
||||
{
|
||||
if (second_valid < intersection.size())
|
||||
{
|
||||
@@ -349,7 +341,7 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
|
||||
if (intersection.size() == 2 && num_valid_turns == 1)
|
||||
{
|
||||
BOOST_ASSERT(!intersection[0].entry_allowed);
|
||||
BOOST_ASSERT(detail::isMotorwayClass(intersection[1].turn.eid, node_based_graph));
|
||||
BOOST_ASSERT(isMotorwayClass(intersection[1].turn.eid, node_based_graph));
|
||||
|
||||
intersection[1].turn.instruction = getInstructionForObvious(
|
||||
intersection.size(), via_eid, isThroughStreet(1, intersection), intersection[1]);
|
||||
@@ -370,7 +362,7 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
|
||||
// 0
|
||||
if (intersection[1].entry_allowed)
|
||||
{
|
||||
if (detail::isMotorwayClass(intersection[1].turn.eid, node_based_graph) &&
|
||||
if (isMotorwayClass(intersection[1].turn.eid, node_based_graph) &&
|
||||
node_based_graph.GetEdgeData(intersection[2].turn.eid).name_id !=
|
||||
EMPTY_NAMEID &&
|
||||
node_based_graph.GetEdgeData(intersection[2].turn.eid).name_id ==
|
||||
@@ -397,7 +389,7 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(intersection[2].entry_allowed);
|
||||
if (detail::isMotorwayClass(intersection[2].turn.eid, node_based_graph) &&
|
||||
if (isMotorwayClass(intersection[2].turn.eid, node_based_graph) &&
|
||||
node_based_graph.GetEdgeData(intersection[1].turn.eid).name_id !=
|
||||
EMPTY_NAMEID &&
|
||||
node_based_graph.GetEdgeData(intersection[2].turn.eid).name_id ==
|
||||
@@ -434,8 +426,8 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
|
||||
// \ /
|
||||
// |
|
||||
// R
|
||||
if (detail::isMotorwayClass(intersection[1].turn.eid, node_based_graph) &&
|
||||
detail::isMotorwayClass(intersection[2].turn.eid, node_based_graph))
|
||||
if (isMotorwayClass(intersection[1].turn.eid, node_based_graph) &&
|
||||
isMotorwayClass(intersection[2].turn.eid, node_based_graph))
|
||||
{
|
||||
assignFork(via_eid, intersection[2], intersection[1]);
|
||||
}
|
||||
@@ -446,8 +438,7 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
|
||||
// M R
|
||||
// | /
|
||||
// R
|
||||
if (isMotorwayClass(node_based_graph.GetEdgeData(intersection[1].turn.eid)
|
||||
.road_classification.road_class))
|
||||
if (isMotorwayClass(intersection[1].turn.eid, node_based_graph))
|
||||
{
|
||||
intersection[1].turn.instruction = {TurnType::Turn,
|
||||
DirectionModifier::SlightRight};
|
||||
@@ -467,12 +458,11 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
|
||||
bool passed_highway_entry = false;
|
||||
for (auto &road : intersection)
|
||||
{
|
||||
const auto &edge_data = node_based_graph.GetEdgeData(road.turn.eid);
|
||||
if (!road.entry_allowed && isMotorwayClass(edge_data.road_classification.road_class))
|
||||
if (!road.entry_allowed && isMotorwayClass(road.turn.eid, node_based_graph))
|
||||
{
|
||||
passed_highway_entry = true;
|
||||
}
|
||||
else if (isMotorwayClass(edge_data.road_classification.road_class))
|
||||
else if (isMotorwayClass(road.turn.eid, node_based_graph))
|
||||
{
|
||||
road.turn.instruction = {TurnType::Merge,
|
||||
passed_highway_entry ? DirectionModifier::SlightRight
|
||||
@@ -480,7 +470,7 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(isRampClass(edge_data.road_classification.road_class));
|
||||
BOOST_ASSERT(isRampClass(road.turn.eid, node_based_graph));
|
||||
road.turn.instruction = {TurnType::OffRamp, getTurnDirection(road.turn.angle)};
|
||||
}
|
||||
}
|
||||
@@ -503,13 +493,13 @@ Intersection MotorwayHandler::fallback(Intersection intersection) const
|
||||
|
||||
util::SimpleLogger().Write(logDEBUG)
|
||||
<< "road: " << toString(road) << " Name: " << out_data.name_id
|
||||
<< " Road Class: " << (int)out_data.road_classification.road_class;
|
||||
<< " Road Class: " << out_data.road_classification.ToString();
|
||||
|
||||
if (!road.entry_allowed)
|
||||
continue;
|
||||
|
||||
const auto type = isMotorwayClass(out_data.road_classification.road_class) ? TurnType::Merge
|
||||
: TurnType::Turn;
|
||||
const auto type =
|
||||
isMotorwayClass(road.turn.eid, node_based_graph) ? TurnType::Merge : TurnType::Turn;
|
||||
|
||||
if (type == TurnType::Turn)
|
||||
{
|
||||
|
||||
@@ -74,8 +74,8 @@ operator()(const NodeID, const EdgeID source_edge_id, Intersection intersection)
|
||||
const auto check_valid = [this, source_edge_data](const ConnectedRoad &road) {
|
||||
const auto road_edge_data = node_based_graph.GetEdgeData(road.turn.eid);
|
||||
// Test to see if the source edge and the one we're looking at are the same road
|
||||
return road_edge_data.road_classification.road_class ==
|
||||
source_edge_data.road_classification.road_class &&
|
||||
return road_edge_data.road_classification ==
|
||||
source_edge_data.road_classification &&
|
||||
road_edge_data.name_id != EMPTY_NAMEID &&
|
||||
road_edge_data.name_id == source_edge_data.name_id && road.entry_allowed;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "extractor/guidance/classification_data.hpp"
|
||||
#include "extractor/guidance/road_classification.hpp"
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/turn_analysis.hpp"
|
||||
|
||||
@@ -86,7 +86,8 @@ Intersection TurnAnalysis::assignTurnTypes(const NodeID from_nid,
|
||||
intersection = sliproad_handler(from_nid, via_eid, std::move(intersection));
|
||||
|
||||
// Turn On Ramps Into Off Ramps, if we come from a motorway-like road
|
||||
if (isMotorwayClass(node_based_graph.GetEdgeData(via_eid).road_classification.road_class))
|
||||
if (node_based_graph.GetEdgeData(via_eid)
|
||||
.road_classification.IsMotorwayClass())
|
||||
{
|
||||
std::for_each(intersection.begin(), intersection.end(), [](ConnectedRoad &road) {
|
||||
if (road.turn.instruction.type == TurnType::OnRamp)
|
||||
|
||||
@@ -75,25 +75,28 @@ bool TurnHandler::isObviousOfTwo(const EdgeID via_edge,
|
||||
const ConnectedRoad &other) const
|
||||
{
|
||||
const auto &in_data = node_based_graph.GetEdgeData(via_edge);
|
||||
const auto first_class =
|
||||
node_based_graph.GetEdgeData(road.turn.eid).road_classification.road_class;
|
||||
|
||||
const auto second_class =
|
||||
node_based_graph.GetEdgeData(other.turn.eid).road_classification.road_class;
|
||||
|
||||
const bool is_ramp = isRampClass(first_class);
|
||||
const auto &first_data = node_based_graph.GetEdgeData(road.turn.eid);
|
||||
const auto &second_data = node_based_graph.GetEdgeData(other.turn.eid);
|
||||
const auto &first_classification = first_data.road_classification;
|
||||
const auto &second_classification = second_data.road_classification;
|
||||
const bool is_ramp = first_classification.IsRampClass();
|
||||
const bool is_obvious_by_road_class =
|
||||
(!is_ramp && (2 * getPriority(first_class) < getPriority(second_class)) &&
|
||||
in_data.road_classification.road_class == first_class) ||
|
||||
(!isLowPriorityRoadClass(first_class) && isLowPriorityRoadClass(second_class));
|
||||
(!is_ramp &&
|
||||
(2 * first_classification.GetPriority() < second_classification.GetPriority()) &&
|
||||
in_data.road_classification == first_classification) ||
|
||||
(!first_classification.IsLowPriorityRoadClass() &&
|
||||
second_classification.IsLowPriorityRoadClass());
|
||||
|
||||
if (is_obvious_by_road_class)
|
||||
return true;
|
||||
|
||||
const bool other_is_obvious_by_road_class =
|
||||
(!isRampClass(second_class) && (2 * getPriority(second_class) < getPriority(first_class)) &&
|
||||
in_data.road_classification.road_class == second_class) ||
|
||||
(!isLowPriorityRoadClass(second_class) && isLowPriorityRoadClass(first_class));
|
||||
(!second_classification.IsRampClass() &&
|
||||
(2 * second_classification.GetPriority() < first_classification.GetPriority()) &&
|
||||
in_data.road_classification == second_classification) ||
|
||||
(!second_classification.IsLowPriorityRoadClass() &&
|
||||
first_classification.IsLowPriorityRoadClass());
|
||||
|
||||
if (other_is_obvious_by_road_class)
|
||||
return false;
|
||||
@@ -114,7 +117,7 @@ bool TurnHandler::isObviousOfTwo(const EdgeID via_edge,
|
||||
FUZZY_ANGLE_DIFFERENCE;
|
||||
|
||||
return is_much_narrower_than_other;
|
||||
};
|
||||
}
|
||||
|
||||
Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection intersection) const
|
||||
{
|
||||
@@ -256,13 +259,13 @@ Intersection TurnHandler::handleComplexTurn(const EdgeID via_edge, Intersection
|
||||
{
|
||||
auto &left = intersection[fork_range.second];
|
||||
auto &right = intersection[fork_range.first];
|
||||
const auto left_class =
|
||||
node_based_graph.GetEdgeData(left.turn.eid).road_classification.road_class;
|
||||
const auto right_class =
|
||||
node_based_graph.GetEdgeData(right.turn.eid).road_classification.road_class;
|
||||
if (canBeSeenAsFork(left_class, right_class))
|
||||
const auto left_classification =
|
||||
node_based_graph.GetEdgeData(left.turn.eid).road_classification;
|
||||
const auto right_classification =
|
||||
node_based_graph.GetEdgeData(right.turn.eid).road_classification;
|
||||
if (canBeSeenAsFork(left_classification, right_classification))
|
||||
assignFork(via_edge, left, right);
|
||||
else if (getPriority(left_class) > getPriority(right_class))
|
||||
else if (left_classification.GetPriority() > right_classification.GetPriority())
|
||||
{
|
||||
right.turn.instruction =
|
||||
getInstructionForObvious(intersection.size(), via_edge, false, right);
|
||||
@@ -541,13 +544,12 @@ std::pair<std::size_t, std::size_t> TurnHandler::findFork(const EdgeID via_edge,
|
||||
}();
|
||||
|
||||
const bool has_compatible_classes = [&]() {
|
||||
const bool ramp_class =
|
||||
isLinkClass(node_based_graph.GetEdgeData(intersection[right].turn.eid)
|
||||
.road_classification.road_class);
|
||||
const bool ramp_class = node_based_graph.GetEdgeData(intersection[right].turn.eid)
|
||||
.road_classification.IsLinkClass();
|
||||
for (std::size_t index = right + 1; index <= left; ++index)
|
||||
if (ramp_class !=
|
||||
isLinkClass(node_based_graph.GetEdgeData(intersection[index].turn.eid)
|
||||
.road_classification.road_class))
|
||||
node_based_graph.GetEdgeData(intersection[index].turn.eid)
|
||||
.road_classification.IsLinkClass())
|
||||
return false;
|
||||
return true;
|
||||
}();
|
||||
@@ -581,13 +583,13 @@ void TurnHandler::handleDistinctConflict(const EdgeID via_edge,
|
||||
getTurnDirection(left.turn.angle) == DirectionModifier::SlightLeft ||
|
||||
getTurnDirection(right.turn.angle) == DirectionModifier::SlightRight)
|
||||
{
|
||||
const auto left_class =
|
||||
node_based_graph.GetEdgeData(left.turn.eid).road_classification.road_class;
|
||||
const auto right_class =
|
||||
node_based_graph.GetEdgeData(right.turn.eid).road_classification.road_class;
|
||||
if (canBeSeenAsFork(left_class, right_class))
|
||||
const auto left_classification =
|
||||
node_based_graph.GetEdgeData(left.turn.eid).road_classification;
|
||||
const auto right_classification =
|
||||
node_based_graph.GetEdgeData(right.turn.eid).road_classification;
|
||||
if (canBeSeenAsFork(left_classification, right_classification))
|
||||
assignFork(via_edge, left, right);
|
||||
else if (getPriority(left_class) > getPriority(right_class))
|
||||
else if (left_classification.GetPriority() > right_classification.GetPriority())
|
||||
{
|
||||
// FIXME this should possibly know about the actual roads?
|
||||
// here we don't know about the intersection size. To be on the save side,
|
||||
|
||||
@@ -95,6 +95,24 @@ void LuaScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
||||
luabind::value("river_up", TRAVEL_MODE_RIVER_UP),
|
||||
luabind::value("river_down", TRAVEL_MODE_RIVER_DOWN),
|
||||
luabind::value("route", TRAVEL_MODE_ROUTE)],
|
||||
|
||||
luabind::class_<extractor::guidance::RoadPriorityClass::Enum>("road_priority_class")
|
||||
.enum_("enums")
|
||||
[luabind::value("motorway", extractor::guidance::RoadPriorityClass::MOTORWAY),
|
||||
luabind::value("trunk", extractor::guidance::RoadPriorityClass::TRUNK),
|
||||
luabind::value("primary", extractor::guidance::RoadPriorityClass::PRIMARY),
|
||||
luabind::value("secondary", extractor::guidance::RoadPriorityClass::SECONDARY),
|
||||
luabind::value("tertiary", extractor::guidance::RoadPriorityClass::TERTIARY),
|
||||
luabind::value("main_residential",
|
||||
extractor::guidance::RoadPriorityClass::MAIN_RESIDENTIAL),
|
||||
luabind::value("side_residential",
|
||||
extractor::guidance::RoadPriorityClass::SIDE_RESIDENTIAL),
|
||||
luabind::value("link_road", extractor::guidance::RoadPriorityClass::LINK_ROAD),
|
||||
luabind::value("bike_path", extractor::guidance::RoadPriorityClass::BIKE_PATH),
|
||||
luabind::value("foot_path", extractor::guidance::RoadPriorityClass::FOOT_PATH),
|
||||
luabind::value("connectivity",
|
||||
extractor::guidance::RoadPriorityClass::CONNECTIVITY)],
|
||||
|
||||
luabind::class_<SourceContainer>("sources")
|
||||
.def(luabind::constructor<>())
|
||||
.def("load", &SourceContainer::LoadRasterSource)
|
||||
@@ -135,6 +153,21 @@ void LuaScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
||||
.def_readwrite("traffic_lights", &ExtractionNode::traffic_lights)
|
||||
.def_readwrite("barrier", &ExtractionNode::barrier),
|
||||
|
||||
// road classification to be set in profile
|
||||
luabind::class_<guidance::RoadClassification>("RoadClassification")
|
||||
.property("motorway_class",
|
||||
&guidance::RoadClassification::IsMotorwayClass,
|
||||
&guidance::RoadClassification::SetMotorwayFlag)
|
||||
.property("link_class",
|
||||
&guidance::RoadClassification::IsLinkClass,
|
||||
&guidance::RoadClassification::SetLinkClass)
|
||||
.property("may_be_ignored",
|
||||
&guidance::RoadClassification::IsLowPriorityRoadClass,
|
||||
&guidance::RoadClassification::SetLowPriorityFlag)
|
||||
.property("road_priority_class",
|
||||
&guidance::RoadClassification::GetClass,
|
||||
&guidance::RoadClassification::SetClass),
|
||||
|
||||
luabind::class_<ExtractionWay>("ResultWay")
|
||||
// .def(luabind::constructor<>())
|
||||
.def_readwrite("forward_speed", &ExtractionWay::forward_speed)
|
||||
@@ -148,6 +181,7 @@ void LuaScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
||||
.def_readwrite("duration", &ExtractionWay::duration)
|
||||
.def_readwrite("turn_lanes_forward", &ExtractionWay::turn_lanes_forward)
|
||||
.def_readwrite("turn_lanes_backward", &ExtractionWay::turn_lanes_backward)
|
||||
.def_readwrite("road_classification", &ExtractionWay::road_classification)
|
||||
.property(
|
||||
"forward_mode", &ExtractionWay::get_forward_mode, &ExtractionWay::set_forward_mode)
|
||||
.property("backward_mode",
|
||||
|
||||
Reference in New Issue
Block a user