Compare commits

...

13 Commits

Author SHA1 Message Date
Michael Krasnyk
dc26f7d8b9
Release 5.15.0 2018-01-22 07:35:00 +01:00
Michael Krasnyk
791f6d02e1
Make 5.15.0-rc.3 2018-01-19 20:05:24 +01:00
Kajari Ghosh
7b7871d5aa
Refactor isThroughStreet/Intersection options (#4751)
* refactor isThroughStreet 
* refactor HaveIdenticalName
* fix a typo in the unit tests
2018-01-19 20:01:47 +01:00
Michael Krasnyk
f7613d77d5
Make 5.15.0-rc.2 2018-01-19 16:04:59 +01:00
Michael Krasnyk
c80edef46c
Ignore no_*_on_red turn restrictions (#4804) 2018-01-19 16:04:31 +01:00
Kajari Ghosh
cfae4a1923
add tunnel as a class in lua (#4812) 2018-01-19 16:03:42 +01:00
Michael Krasnyk
fd9d5af7e0
Fix formatting 2018-01-19 14:29:51 +01:00
Michael Krasnyk
c81942c167
Add assertion and adjust unit test expectations check 2018-01-19 14:29:46 +01:00
karenzshea
c5c4a1b4fe
add unit test for split submatch waypoints indices 2018-01-19 14:29:41 +01:00
karenzshea
eb13041784
only adjust waypoint index in tracepoints when waypoints parameter is specified 2018-01-19 14:29:35 +01:00
Huyen Chau Nguyen
fa1f121b02
Remove "can't parse value" log messages (#4810)
* remove log output of measure.lua
* remove unneccessary return
* quick fix of #4794
2018-01-19 12:19:09 +01:00
Patrick Niklaus
c26642de6e Fix overflow on zero duration segments, fixes #4283.
As a form of smoothing we use the previous speed value instead.
This makes sense because the zero duration segments have to be very
short, potentially also zero length.
2018-01-18 16:31:21 +00:00
Michael Krasnyk
ef1fc8a757
Make 5.15.0-rc.1 2018-01-16 13:02:32 +01:00
33 changed files with 424 additions and 143 deletions

View File

@ -12,7 +12,7 @@ notifications:
branches:
only:
- master
- 5.15
# enable building tags
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/

View File

@ -1,10 +1,16 @@
# UNRELEASED
# 5.15.0
- Changes from 5.14.3:
- Bugfixes:
- FIXED #4704: Fixed regression in bearings reordering introduced in 5.13 [#4704](https://github.com/Project-OSRM/osrm-backend/issues/4704)
- FIXED #4781: Fixed overflow exceptions in percent-encoding parsing
- FIXED #4770: Fixed exclude flags for single toll road scenario
- FIXED #4283: Fix overflow on zero duration segments
- FIXED #4804: Ignore no_*_on_red turn restrictions
- Guidance:
- CHANGED #4706: Guidance refactoring step to decouple intersection connectivity analysis and turn instructions generation [#4706](https://github.com/Project-OSRM/osrm-backend/pull/4706)
- CHANGED #3491: Refactor `isThroughStreet`/Intersection options
- Profile:
- ADDED: `tunnel` as a new class in car profile so that sections of the route with tunnel tags will be marked as such
# 5.14.3
- Changes from 5.14.2:

View File

@ -82,7 +82,7 @@ Feature: Car - Mode flag
| from | to | route | turns | classes |
| a | d | ab,cd | depart,arrive| [(restricted),(motorway,restricted),()],[()] |
Scenario: Car - We toll restricted with a class
Scenario: Car - We tag toll with a class
Given the node map
"""
a b
@ -99,6 +99,26 @@ Feature: Car - Mode flag
| from | to | route | turns | classes |
| a | d | ab,cd | depart,arrive | [(toll),(motorway,toll),()],[()] |
Scenario: Car - We tag tunnel with a class
Background:
Given a grid size of 200 meters
Given the node map
"""
a b
c d
"""
And the ways
| nodes | tunnel |
| ab | no |
| bc | yes |
| cd | |
When I route I should get
| from | to | route | turns | classes |
| a | d | ab,bc,cd,cd | depart,new name right,new name left,arrive | [()],[(tunnel)],[()],[()] |
Scenario: Car - From roundabout on toll road
Given the node map
"""

View File

@ -141,6 +141,33 @@ Feature: Car - Turn restrictions
| c | a | cj,aj,aj |
| c | b | cj,bj,bj |
@no_turning
Scenario: Car - Ignore no_*_on_red relations
Given the node map
"""
a
d j b
c
"""
And the ways
| nodes | oneway |
| cj | yes |
| aj | -1 |
| dj | -1 |
| bj | -1 |
And the relations
| type | way:from | way:to | node:via | restriction |
| restriction | cj | dj | j | no_turn_on_red |
| restriction | cj | bj | j | no_right_turn_on_red |
When I route I should get
| from | to | route |
| c | d | cj,dj,dj |
| c | a | cj,aj,aj |
| c | b | cj,bj,bj |
@only_turning
Scenario: Car - Only left turn
Given the node map

View File

@ -59,3 +59,27 @@ Feature: Annotations
| from | to | route | a:datasources | a:speed |
| a | i | abcdefghi,abcdefghi | 1:0:1:0:1:0:0:0 | 50:10:50:10:50:10:10:10 |
| i | a | abcdefghi,abcdefghi | 0:1:0:0:0:0:0:1 | 10:50:10:10:10:10:10:50 |
Scenario: Speed annotations should handle zero segments
Given the profile "testbot"
Given the node map
"""
a -- b --- c
|
d
"""
And the ways
| nodes |
| abc |
| cd |
# This test relies on the snapping to the EBN cd to introduce a zero segment after the turn
And the query options
| annotations | speed,distance,duration,nodes |
| bearings | 90,5;180,5 |
When I route I should get
| from | to | route | a:speed | a:distance | a:duration | a:nodes |
| a | c | abc,abc | 10:10:10 | 249.998641:299.931643:0 | 25:30:0 | 1:2:3 |

View File

@ -87,9 +87,9 @@ class MatchAPI final : public RouteAPI
0u, static_cast<unsigned>(sub_matchings[sub_matching_index].indices.size())))
{
// tidied_to_original: index of the input coordinate that a tidied coordinate
// corresponds to
// corresponds to.
// sub_matching indices: index of the coordinate passed to map matching plugin that
// a matched node corresponds to
// a matched node corresponds to.
trace_idx_to_matching_idx[tidy_result
.tidied_to_original[sub_matchings[sub_matching_index]
.indices[point_index]]] =
@ -97,6 +97,8 @@ class MatchAPI final : public RouteAPI
}
}
BOOST_ASSERT(parameters.waypoints.empty() || sub_matchings.size() == 1);
std::size_t was_waypoint_idx = 0;
for (auto trace_index : util::irange<std::size_t>(0UL, parameters.coordinates.size()))
{
@ -115,17 +117,23 @@ class MatchAPI final : public RouteAPI
sub_matchings[matching_index.sub_matching_index].nodes[matching_index.point_index];
auto waypoint = BaseAPI::MakeWaypoint(phantom);
waypoint.values["matchings_index"] = matching_index.sub_matching_index;
waypoint.values["waypoint_index"] = matching_index.point_index;
waypoint.values["alternatives_count"] =
sub_matchings[matching_index.sub_matching_index]
.alternatives_count[matching_index.point_index];
if (tidy_result.was_waypoint[trace_index])
// waypoint indices need to be adjusted if route legs were collapsed
// waypoint parameter assumes there is only one match object
if (!parameters.waypoints.empty())
{
waypoint.values["waypoint_index"] = was_waypoint_idx;
was_waypoint_idx++;
}
else
{
waypoint.values["waypoint_index"] = util::json::Null();
if (tidy_result.was_waypoint[trace_index])
{
waypoint.values["waypoint_index"] = was_waypoint_idx;
was_waypoint_idx++;
}
else
{
waypoint.values["waypoint_index"] = util::json::Null();
}
}
waypoints.values.push_back(std::move(waypoint));
}

View File

@ -88,11 +88,12 @@ class RouteAPI : public BaseAPI
{
util::json::Array annotations_store;
annotations_store.values.reserve(leg.annotations.size());
std::for_each(leg.annotations.begin(),
leg.annotations.end(),
[Get, &annotations_store](const auto &step) {
annotations_store.values.push_back(Get(step));
});
for (const auto &step : leg.annotations)
{
annotations_store.values.push_back(Get(step));
}
return annotations_store;
}
@ -255,10 +256,19 @@ class RouteAPI : public BaseAPI
// AnnotationsType uses bit flags, & operator checks if a property is set
if (parameters.annotations_type & RouteParameters::AnnotationsType::Speed)
{
double prev_speed = 0;
annotation.values["speed"] = GetAnnotations(
leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
auto val = std::round(anno.distance / anno.duration * 10.) / 10.;
return util::json::clamp_float(val);
leg_geometry, [&prev_speed](const guidance::LegGeometry::Annotation &anno) {
if (anno.duration < std::numeric_limits<double>::min())
{
return prev_speed;
}
else
{
auto speed = std::round(anno.distance / anno.duration * 10.) / 10.;
prev_speed = speed;
return util::json::clamp_float(speed);
}
});
}
@ -293,11 +303,10 @@ class RouteAPI : public BaseAPI
{
util::json::Array nodes;
nodes.values.reserve(leg_geometry.osm_node_ids.size());
std::for_each(leg_geometry.osm_node_ids.begin(),
leg_geometry.osm_node_ids.end(),
[this, &nodes](const OSMNodeID &node_id) {
nodes.values.push_back(static_cast<std::uint64_t>(node_id));
});
for (const auto node_id : leg_geometry.osm_node_ids)
{
nodes.values.push_back(static_cast<std::uint64_t>(node_id));
}
annotation.values["nodes"] = std::move(nodes);
}

View File

@ -0,0 +1,27 @@
#ifndef OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_
#define OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_
#include "extractor/guidance/constants.hpp"
#include "extractor/suffix_table.hpp"
#include "util/name_table.hpp"
namespace osrm
{
namespace extractor
{
namespace guidance
{
// check if two name ids can be seen as identical (in presence of refs/others)
// in our case this translates into no name announcement in either direction (lhs->rhs and
// rhs->lhs)
bool HaveIdenticalNames(const NameID lhs,
const NameID rhs,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table);
} // namespace guidance
} // namespace extractor
} // namespace osrm
#endif /*OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_*/

View File

@ -293,10 +293,11 @@ struct IntersectionView final : std::vector<IntersectionViewData>, //
};
// `Intersection` is a relative view of an intersection by an incoming edge.
// `Intersection` are streets at an intersection ordered from from sharp right counter-clockwise to
// `Intersection` are streets at an intersection stored as an ordered list of connected roads
// ordered from sharp right counter-clockwise to
// sharp left where `intersection[0]` is _always_ a u-turn
// An intersection is an ordered list of connected roads ordered from from sharp right
// An intersection is an ordered list of connected roads ordered from sharp right
// counter-clockwise to sharp left where `intersection[0]` is always a u-turn
//
// |

View File

@ -96,9 +96,6 @@ class IntersectionHandler
const std::size_t begin,
const std::size_t end) const;
// Checks the intersection for a through street connected to `intersection[index]`
bool isThroughStreet(const std::size_t index, const Intersection &intersection) const;
// See `getNextIntersection`
struct IntersectionViewAndNode final
{

View File

@ -0,0 +1,63 @@
#ifndef OSRM_EXTRACTOR_GUIDANCE_IS_THROUGH_STREET_HPP_
#define OSRM_EXTRACTOR_GUIDANCE_IS_THROUGH_STREET_HPP_
#include "extractor/guidance/constants.hpp"
#include "extractor/suffix_table.hpp"
#include "util/guidance/name_announcements.hpp"
using osrm::util::angularDeviation;
namespace osrm
{
namespace extractor
{
namespace guidance
{
template <typename IntersectionType>
inline bool isThroughStreet(const std::size_t index,
const IntersectionType &intersection,
const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &node_data_container,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
{
const auto &data_at_index = node_data_container.GetAnnotation(
node_based_graph.GetEdgeData(intersection[index].eid).annotation_data);
if (data_at_index.name_id == EMPTY_NAMEID)
return false;
// a through street cannot start at our own position -> index 1
for (std::size_t road_index = 1; road_index < intersection.size(); ++road_index)
{
if (road_index == index)
continue;
const auto &road = intersection[road_index];
const auto &road_data = node_data_container.GetAnnotation(
node_based_graph.GetEdgeData(road.eid).annotation_data);
// roads have a near straight angle (180 degree)
const bool is_nearly_straight = angularDeviation(road.angle, intersection[index].angle) >
(STRAIGHT_ANGLE - FUZZY_ANGLE_DIFFERENCE);
const bool have_same_name = HaveIdenticalNames(
data_at_index.name_id, road_data.name_id, name_table, street_name_suffix_table);
const bool have_same_category =
node_based_graph.GetEdgeData(intersection[index].eid).flags.road_classification ==
node_based_graph.GetEdgeData(road.eid).flags.road_classification;
if (is_nearly_straight && have_same_name && have_same_category)
return true;
}
return false;
}
} // namespace guidance
} // namespace extractor
} // namespace osrm
#endif /*OSRM_EXTRACTOR_GUIDANCE_IS_THROUGH_STREET_HPP_*/

View File

@ -3,6 +3,7 @@
#include "extractor/compressed_edge_container.hpp"
#include "extractor/guidance/coordinate_extractor.hpp"
#include "extractor/guidance/have_identical_names.hpp"
#include "extractor/guidance/intersection.hpp"
#include "extractor/guidance/turn_lane_types.hpp"
#include "extractor/restriction_index.hpp"
@ -78,11 +79,6 @@ class MergableRoadDetector
bool IsDistinctFrom(const MergableRoadData &lhs, const MergableRoadData &rhs) const;
private:
// check if two name ids can be seen as identical (in presence of refs/others)
// in our case this translates into no name announcement in either direction (lhs->rhs and
// rhs->lhs)
bool HaveIdenticalNames(const NameID lhs, const NameID rhs) const;
// When it comes to merging roads, we need to find out if two ways actually represent the
// same road. This check tries to identify roads which are the same road in opposite directions
bool EdgeDataSupportsMerge(const NodeBasedEdgeClassification &lhs_flags,

View File

@ -3,6 +3,7 @@
#include "extractor/guidance/intersection.hpp"
#include "extractor/guidance/intersection_handler.hpp"
#include "extractor/guidance/is_through_street.hpp"
#include "extractor/query_node.hpp"
#include "util/attributes.hpp"

View File

@ -5,6 +5,7 @@
#include "extractor/guidance/coordinate_extractor.hpp"
#include "extractor/guidance/intersection.hpp"
#include "extractor/guidance/intersection_handler.hpp"
#include "extractor/guidance/is_through_street.hpp"
#include "extractor/guidance/roundabout_type.hpp"
#include "extractor/query_node.hpp"

View File

@ -3,6 +3,7 @@
#include "extractor/guidance/intersection.hpp"
#include "extractor/guidance/intersection_handler.hpp"
#include "extractor/guidance/is_through_street.hpp"
#include "extractor/query_node.hpp"
#include "util/name_table.hpp"
@ -53,9 +54,6 @@ class SliproadHandler final : public IntersectionHandler
// Next intersection from `start` onto `onto` is too far away for a Siproad scenario
bool nextIntersectionIsTooFarAway(const NodeID start, const EdgeID onto) const;
// Through street: does a road continue with from's name at the intersection
bool isThroughStreet(const EdgeID from, const IntersectionView &intersection) const;
// Does the road from `current` to `next` continue
bool roadContinues(const EdgeID current, const EdgeID next) const;

View File

@ -3,6 +3,7 @@
#include "extractor/guidance/intersection.hpp"
#include "extractor/guidance/intersection_handler.hpp"
#include "extractor/guidance/is_through_street.hpp"
#include "extractor/query_node.hpp"
#include "util/attributes.hpp"

View File

@ -1,6 +1,6 @@
{
"name": "osrm",
"version": "5.15.0-latest.4",
"version": "5.15.0",
"private": false,
"description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.",
"dependencies": {

View File

@ -104,7 +104,7 @@ function setup()
},
classes = Sequence {
'toll', 'motorway', 'ferry', 'restricted'
'toll', 'motorway', 'ferry', 'restricted', 'tunnel'
},
-- classes to support for exclude flags

View File

@ -23,8 +23,6 @@ function Measure.parse_value_meters(value)
end
return n
end
print("Can't parse value: ", value)
end
--- according to http://wiki.openstreetmap.org/wiki/Map_Features/Units#Explicit_specifications
@ -55,10 +53,6 @@ function Measure.parse_value_kilograms(value)
return tonumber(m) * 1000
end
end
--
print("Can't parse value: ", value)
return
end
--- Get maxheight of specified way in meters. If there are no

View File

@ -283,6 +283,12 @@ end
function WayHandlers.classes(profile,way,result,data)
local forward_toll, backward_toll = Tags.get_forward_backward_by_key(way, data, "toll")
local forward_route, backward_route = Tags.get_forward_backward_by_key(way, data, "route")
local tunnel = way:get_value_by_key("tunnel")
if tunnel and tunnel ~= "no" then
result.forward_classes["tunnel"] = true
result.backward_classes["tunnel"] = true
end
if forward_toll == "yes" then
result.forward_classes["toll"] = true

View File

@ -0,0 +1,33 @@
#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
{
// check if two name ids can be seen as identical (in presence of refs/others)
// in our case this translates into no name announcement in either direction (lhs->rhs and
// rhs->lhs)
bool HaveIdenticalNames(const NameID lhs,
const NameID rhs,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
{
const auto non_empty = (lhs != EMPTY_NAMEID) && (rhs != EMPTY_NAMEID);
// symmetrical check for announcements
return non_empty &&
!util::guidance::requiresNameAnnounced(lhs, rhs, name_table, street_name_suffix_table) &&
!util::guidance::requiresNameAnnounced(rhs, lhs, name_table, street_name_suffix_table);
}
} // namespace guidance
} // namespace extractor
} // namespace osrm
#endif /*OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_*/

View File

@ -418,44 +418,6 @@ void IntersectionHandler::assignTrivialTurns(const EdgeID via_eid,
}
}
bool IntersectionHandler::isThroughStreet(const std::size_t index,
const Intersection &intersection) const
{
const auto &data_at_index = node_data_container.GetAnnotation(
node_based_graph.GetEdgeData(intersection[index].eid).annotation_data);
if (data_at_index.name_id == EMPTY_NAMEID)
return false;
// a through street cannot start at our own position -> index 1
for (std::size_t road_index = 1; road_index < intersection.size(); ++road_index)
{
if (road_index == index)
continue;
const auto &road = intersection[road_index];
const auto &road_data = node_data_container.GetAnnotation(
node_based_graph.GetEdgeData(road.eid).annotation_data);
// roads have a near straight angle (180 degree)
const bool is_nearly_straight = angularDeviation(road.angle, intersection[index].angle) >
(STRAIGHT_ANGLE - FUZZY_ANGLE_DIFFERENCE);
const bool have_same_name =
road_data.name_id != EMPTY_NAMEID &&
!util::guidance::requiresNameAnnounced(
data_at_index.name_id, road_data.name_id, name_table, street_name_suffix_table);
const bool have_same_category =
node_based_graph.GetEdgeData(intersection[index].eid).flags.road_classification ==
node_based_graph.GetEdgeData(road.eid).flags.road_classification;
if (is_nearly_straight && have_same_name && have_same_category)
return true;
}
return false;
}
boost::optional<IntersectionHandler::IntersectionViewAndNode>
IntersectionHandler::getNextIntersection(const NodeID at, const EdgeID via) const
{

View File

@ -122,16 +122,6 @@ bool MergableRoadDetector::CanMergeRoad(const NodeID intersection_node,
!IsCircularShape(intersection_node, lhs, rhs);
}
bool MergableRoadDetector::HaveIdenticalNames(const NameID lhs, const NameID rhs) const
{
const auto non_empty = (lhs != EMPTY_NAMEID) && (rhs != EMPTY_NAMEID);
// symmetrical check for announcements
return non_empty &&
!util::guidance::requiresNameAnnounced(lhs, rhs, name_table, street_name_suffix_table) &&
!util::guidance::requiresNameAnnounced(rhs, lhs, name_table, street_name_suffix_table);
}
bool MergableRoadDetector::IsDistinctFrom(const MergableRoadData &lhs,
const MergableRoadData &rhs) const
{
@ -143,7 +133,9 @@ bool MergableRoadDetector::IsDistinctFrom(const MergableRoadData &lhs,
node_data_container.GetAnnotation(node_based_graph.GetEdgeData(lhs.eid).annotation_data)
.name_id,
node_data_container.GetAnnotation(node_based_graph.GetEdgeData(rhs.eid).annotation_data)
.name_id);
.name_id,
name_table,
street_name_suffix_table);
}
bool MergableRoadDetector::EdgeDataSupportsMerge(
@ -165,7 +157,8 @@ bool MergableRoadDetector::EdgeDataSupportsMerge(
return false;
// we require valid names
if (!HaveIdenticalNames(lhs_annotation.name_id, rhs_annotation.name_id))
if (!HaveIdenticalNames(
lhs_annotation.name_id, rhs_annotation.name_id, name_table, street_name_suffix_table))
return false;
return lhs_flags.road_classification == rhs_flags.road_classification;

View File

@ -239,7 +239,12 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
intersection[1].instruction =
getInstructionForObvious(intersection.size(),
via_eid,
isThroughStreet(1, intersection),
isThroughStreet(1,
intersection,
node_based_graph,
node_data_container,
name_table,
street_name_suffix_table),
intersection[1]);
}
else
@ -253,8 +258,16 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
if (road.angle == continue_angle)
{
road.instruction = getInstructionForObvious(
intersection.size(), via_eid, isThroughStreet(1, intersection), road);
road.instruction =
getInstructionForObvious(intersection.size(),
via_eid,
isThroughStreet(1,
intersection,
node_based_graph,
node_data_container,
name_table,
street_name_suffix_table),
road);
}
else if (road.angle < continue_angle)
{
@ -353,8 +366,16 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
BOOST_ASSERT(!intersection[0].entry_allowed);
BOOST_ASSERT(isMotorwayClass(intersection[1].eid, node_based_graph));
intersection[1].instruction = getInstructionForObvious(
intersection.size(), via_eid, isThroughStreet(1, intersection), intersection[1]);
intersection[1].instruction =
getInstructionForObvious(intersection.size(),
via_eid,
isThroughStreet(1,
intersection,
node_based_graph,
node_data_container,
name_table,
street_name_suffix_table),
intersection[1]);
}
else if (intersection.size() == 3)
{
@ -404,7 +425,12 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
intersection[1].instruction =
getInstructionForObvious(intersection.size(),
via_eid,
isThroughStreet(1, intersection),
isThroughStreet(1,
intersection,
node_based_graph,
node_data_container,
name_table,
street_name_suffix_table),
intersection[1]);
}
}
@ -429,7 +455,12 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
intersection[2].instruction =
getInstructionForObvious(intersection.size(),
via_eid,
isThroughStreet(2, intersection),
isThroughStreet(2,
intersection,
node_based_graph,
node_data_container,
name_table,
street_name_suffix_table),
intersection[2]);
}
}

View File

@ -478,8 +478,16 @@ Intersection RoundaboutHandler::handleRoundabouts(const RoundaboutType roundabou
if (util::angularDeviation(turn.angle, STRAIGHT_ANGLE) < FUZZY_ANGLE_DIFFERENCE &&
crossing_roundabout)
{
turn.instruction = getInstructionForObvious(
intersection.size(), via_eid, isThroughStreet(idx, intersection), turn);
turn.instruction =
getInstructionForObvious(intersection.size(),
via_eid,
isThroughStreet(idx,
intersection,
node_based_graph,
node_data_container,
name_table,
street_name_suffix_table),
turn);
}
else
{

View File

@ -344,9 +344,24 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
}
// If the sliproad candidate is a through street, we cannot handle it as a sliproad.
if (isThroughStreet(sliproad_edge, target_intersection))
auto sliproad_in_target_intersection =
std::find_if(begin(target_intersection),
end(target_intersection),
[&](const auto &road) { return road.eid == sliproad_edge; });
if (sliproad_in_target_intersection != target_intersection.end())
{
continue;
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))
{
continue;
}
}
// The turn off of the Sliproad has to be obvious and a narrow turn and must not be a
@ -689,32 +704,6 @@ bool SliproadHandler::nextIntersectionIsTooFarAway(const NodeID start, const Edg
return accumulator.too_far_away;
}
bool SliproadHandler::isThroughStreet(const EdgeID from, const IntersectionView &intersection) const
{
BOOST_ASSERT(from != SPECIAL_EDGEID);
BOOST_ASSERT(!intersection.empty());
const auto from_annotation_id = node_based_graph.GetEdgeData(from).annotation_data;
const auto &edge_name_id = node_data_container.GetAnnotation(from_annotation_id).name_id;
auto first = begin(intersection) + 1; // Skip UTurn road
auto last = end(intersection);
auto same_name = [&](const auto &road) {
const auto annotation_id = node_based_graph.GetEdgeData(road.eid).annotation_data;
const auto &road_name_id = node_data_container.GetAnnotation(annotation_id).name_id;
return edge_name_id != EMPTY_NAMEID && //
road_name_id != EMPTY_NAMEID && //
!util::guidance::requiresNameAnnounced(edge_name_id,
road_name_id,
name_table,
street_name_suffix_table); //
};
return std::find_if(first, last, same_name) != last;
}
bool SliproadHandler::roadContinues(const EdgeID current, const EdgeID next) const
{
const auto &current_data =

View File

@ -287,8 +287,16 @@ Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection
const auto direction_at_two = getTurnDirection(intersection[2].angle);
if (obvious_index == 1)
{
intersection[1].instruction = getInstructionForObvious(
3, via_edge, isThroughStreet(1, intersection), intersection[1]);
intersection[1].instruction =
getInstructionForObvious(3,
via_edge,
isThroughStreet(1,
intersection,
node_based_graph,
node_data_container,
name_table,
street_name_suffix_table),
intersection[1]);
const auto second_direction = (direction_at_one == direction_at_two &&
direction_at_two == DirectionModifier::Straight)
? DirectionModifier::SlightLeft
@ -300,8 +308,16 @@ Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection
else
{
BOOST_ASSERT(obvious_index == 2);
intersection[2].instruction = getInstructionForObvious(
3, via_edge, isThroughStreet(2, intersection), intersection[2]);
intersection[2].instruction =
getInstructionForObvious(3,
via_edge,
isThroughStreet(2,
intersection,
node_based_graph,
node_data_container,
name_table,
street_name_suffix_table),
intersection[2]);
const auto first_direction = (direction_at_one == direction_at_two &&
direction_at_one == DirectionModifier::Straight)
? DirectionModifier::SlightRight
@ -336,7 +352,12 @@ Intersection TurnHandler::handleComplexTurn(const EdgeID via_edge, Intersection
intersection[obvious_index].instruction =
getInstructionForObvious(intersection.size(),
via_edge,
isThroughStreet(obvious_index, intersection),
isThroughStreet(obvious_index,
intersection,
node_based_graph,
node_data_container,
name_table,
street_name_suffix_table),
intersection[obvious_index]);
// assign left/right turns

View File

@ -107,12 +107,12 @@ RestrictionParser::TryParse(const osmium::Relation &relation) const
const std::string value(fi_begin->value());
// documented OSM restriction tags start either with only_* or no_*;
// check and return on these values, and ignore unrecognized values
// check and return on these values, and ignore no_*_on_red or unrecognized values
if (value.find("only_") == 0)
{
is_only_restriction = true;
}
else if (value.find("no_") == 0)
else if (value.find("no_") == 0 && !boost::algorithm::ends_with(value, "_on_red"))
{
is_only_restriction = false;
}

View File

@ -10,7 +10,7 @@ exports.three_test_coordinates = [[7.41337, 43.72956],
exports.two_test_coordinates = exports.three_test_coordinates.slice(0, 2)
exports.test_tile = {'at': [17059, 11948, 15], 'size': 168606};
exports.test_tile = {'at': [17059, 11948, 15], 'size': 169239};
// Test files generated by the routing engine; check test/data

View File

@ -13,6 +13,14 @@ using Latitude = osrm::util::FloatLatitude;
using Location = osrm::util::Coordinate;
using Locations = std::vector<Location>;
inline Locations get_split_trace_locations()
{
return {{Longitude{7.420202}, Latitude{43.732274}},
{Longitude{7.422369}, Latitude{43.732282}},
{Longitude{7.421511}, Latitude{43.734181}},
{Longitude{7.421489}, Latitude{43.736553}}};
}
inline Location get_dummy_location()
{
return {osrm::util::FloatLongitude{7.437069}, osrm::util::FloatLatitude{43.749249}};

View File

@ -64,4 +64,61 @@ BOOST_AUTO_TEST_CASE(test_match)
}
}
BOOST_AUTO_TEST_CASE(test_match_split)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
MatchParameters params;
params.coordinates = get_split_trace_locations();
params.timestamps = {1, 2, 1700, 1800};
json::Object result;
const auto rc = osrm.Match(params, result);
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
const auto code = result.values.at("code").get<json::String>().value;
BOOST_CHECK_EQUAL(code, "Ok");
const auto &tracepoints = result.values.at("tracepoints").get<json::Array>().values;
BOOST_CHECK_EQUAL(tracepoints.size(), params.coordinates.size());
const auto &matchings = result.values.at("matchings").get<json::Array>().values;
const auto &number_of_matchings = matchings.size();
BOOST_CHECK_EQUAL(number_of_matchings, 2);
std::size_t current_matchings_index = 0, expected_waypoint_index = 0;
for (const auto &waypoint : tracepoints)
{
if (waypoint.is<mapbox::util::recursive_wrapper<util::json::Object>>())
{
BOOST_CHECK(waypoint_check(waypoint));
const auto &waypoint_object = waypoint.get<json::Object>();
const auto matchings_index =
waypoint_object.values.at("matchings_index").get<json::Number>().value;
const auto waypoint_index =
waypoint_object.values.at("waypoint_index").get<json::Number>().value;
const auto &route_legs = matchings[matchings_index]
.get<json::Object>()
.values.at("legs")
.get<json::Array>()
.values;
BOOST_CHECK_LT(matchings_index, number_of_matchings);
expected_waypoint_index =
(current_matchings_index != matchings_index) ? 0 : expected_waypoint_index;
BOOST_CHECK_EQUAL(waypoint_index, expected_waypoint_index);
current_matchings_index = matchings_index;
++expected_waypoint_index;
}
else
{
BOOST_CHECK(waypoint.is<json::Null>());
}
}
}
BOOST_AUTO_TEST_SUITE_END()

View File

@ -44,7 +44,7 @@ class MockScriptingEnvironment : public extractor::ScriptingEnvironment
{
}
bool HasLocationDependentData() const { return false; };
bool HasLocationDependentData() const override { return false; };
};
} // namespace test

View File

@ -1,4 +1,4 @@
#define BOOST_TEST_MODULE customizer tests
#define BOOST_TEST_MODULE updater tests
#include <boost/test/unit_test.hpp>