Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 72441b271a | |||
| 614ee0a010 | |||
| 4b1a2cea6d | |||
| 31d6bfbf12 | |||
| 607fbce1ef | |||
| 06330a694e | |||
| cbecdf8a4f |
@@ -1,3 +1,21 @@
|
|||||||
|
# 5.15.3
|
||||||
|
- Changes from 5.15.2:
|
||||||
|
- Bugfixes: fix deduplication of route steps when waypoints are used [#4909](https://github.com/Project-OSRM/osrm-backend/issues/4909)
|
||||||
|
|
||||||
|
# 5.15.2
|
||||||
|
- Changes from 5.15.1:
|
||||||
|
- Features:
|
||||||
|
- Exposed the waypoints parameter in the node bindings interface
|
||||||
|
- Bugfixes:
|
||||||
|
- Segfault causing bug in leg collapsing map matching when traversing edges in reverse
|
||||||
|
|
||||||
|
# 5.15.1
|
||||||
|
- Changes from 5.15.0:
|
||||||
|
- Bugfixes:
|
||||||
|
- FIXED: Segfault in map matching when RouteLeg collapsing code is run on a match with multiple submatches
|
||||||
|
- Guidance:
|
||||||
|
- Set type of trivial intersections where classes change to Suppressed instead of NoTurn
|
||||||
|
|
||||||
# 5.15.0
|
# 5.15.0
|
||||||
- Changes from 5.14.3:
|
- Changes from 5.14.3:
|
||||||
- Bugfixes:
|
- Bugfixes:
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ endif()
|
|||||||
project(OSRM C CXX)
|
project(OSRM C CXX)
|
||||||
set(OSRM_VERSION_MAJOR 5)
|
set(OSRM_VERSION_MAJOR 5)
|
||||||
set(OSRM_VERSION_MINOR 15)
|
set(OSRM_VERSION_MINOR 15)
|
||||||
set(OSRM_VERSION_PATCH 0)
|
set(OSRM_VERSION_PATCH 3)
|
||||||
set(OSRM_VERSION "${OSRM_VERSION_MAJOR}.${OSRM_VERSION_MINOR}.${OSRM_VERSION_PATCH}")
|
set(OSRM_VERSION "${OSRM_VERSION_MAJOR}.${OSRM_VERSION_MINOR}.${OSRM_VERSION_PATCH}")
|
||||||
|
|
||||||
add_definitions(-DOSRM_PROJECT_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
add_definitions(-DOSRM_PROJECT_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|||||||
@@ -119,6 +119,25 @@ Feature: Car - Mode flag
|
|||||||
| from | to | route | turns | classes |
|
| from | to | route | turns | classes |
|
||||||
| a | d | ab,bc,cd,cd | depart,new name right,new name left,arrive | [()],[(tunnel)],[()],[()] |
|
| a | d | ab,bc,cd,cd | depart,new name right,new name left,arrive | [()],[(tunnel)],[()],[()] |
|
||||||
|
|
||||||
|
Scenario: Car - We tag classes without intersections
|
||||||
|
Background:
|
||||||
|
Given a grid size of 200 meters
|
||||||
|
|
||||||
|
Given the node map
|
||||||
|
"""
|
||||||
|
a b c d
|
||||||
|
"""
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | name | tunnel |
|
||||||
|
| ab | road | |
|
||||||
|
| bc | road | yes |
|
||||||
|
| cd | road | |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| from | to | route | turns | classes |
|
||||||
|
| a | d | road,road | depart,arrive | [(),(tunnel),()],[()] |
|
||||||
|
|
||||||
Scenario: Car - From roundabout on toll road
|
Scenario: Car - From roundabout on toll road
|
||||||
Given the node map
|
Given the node map
|
||||||
"""
|
"""
|
||||||
@@ -144,4 +163,3 @@ Feature: Car - Mode flag
|
|||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | turns | classes |
|
| from | to | route | turns | classes |
|
||||||
| a | f | ab,df,df,df | depart,roundabout-exit-2,exit roundabout slight right,arrive | [()],[(),(motorway)],[(toll,motorway)],[()] |
|
| a | f | ab,df,df,df | depart,roundabout-exit-2,exit roundabout slight right,arrive | [()],[(),(motorway)],[(toll,motorway)],[()] |
|
||||||
|
|
||||||
|
|||||||
@@ -98,11 +98,11 @@ Feature: Car - Guidance - Bridges and Tunnels
|
|||||||
| dce | primary | | Nebenstraße |
|
| dce | primary | | Nebenstraße |
|
||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | turns |
|
| from | to | route | turns |
|
||||||
| a | d | Hauptstraße,Nebenstraße,Nebenstraße | depart,turn left,arrive |
|
| a | d | Hauptstraße,Nebenstraße,Nebenstraße | depart,end of road left,arrive |
|
||||||
| a | e | Hauptstraße,Nebenstraße,Nebenstraße | depart,turn right,arrive |
|
| a | e | Hauptstraße,Nebenstraße,Nebenstraße | depart,end of road right,arrive |
|
||||||
| e | a | Nebenstraße,Hauptstraßentunnel,Hauptstraße | depart,turn left,arrive |
|
| e | a | Nebenstraße,Hauptstraßentunnel,Hauptstraße | depart,turn left,arrive |
|
||||||
| d | a | Nebenstraße,Hauptstraßentunnel,Hauptstraße | depart,turn right,arrive |
|
| d | a | Nebenstraße,Hauptstraßentunnel,Hauptstraße | depart,turn right,arrive |
|
||||||
|
|
||||||
Scenario: Tunnel with Immediate Turn Front and Back
|
Scenario: Tunnel with Immediate Turn Front and Back
|
||||||
Given the node map
|
Given the node map
|
||||||
@@ -129,4 +129,3 @@ Feature: Car - Guidance - Bridges and Tunnels
|
|||||||
| e | g | Nebenstraße,Hauptstraßentunnel,Anderestraße,Anderestraße | depart,turn left,turn left,arrive |
|
| e | g | Nebenstraße,Hauptstraßentunnel,Anderestraße,Anderestraße | depart,turn left,turn left,arrive |
|
||||||
| d | f | Nebenstraße,Hauptstraßentunnel,Anderestraße,Anderestraße | depart,turn right,turn right,arrive |
|
| d | f | Nebenstraße,Hauptstraßentunnel,Anderestraße,Anderestraße | depart,turn right,turn right,arrive |
|
||||||
| d | g | Nebenstraße,Hauptstraßentunnel,Anderestraße,Anderestraße | depart,turn right,turn left,arrive |
|
| d | g | Nebenstraße,Hauptstraßentunnel,Anderestraße,Anderestraße | depart,turn right,turn left,arrive |
|
||||||
|
|
||||||
|
|||||||
@@ -603,3 +603,84 @@ Feature: Basic Map Matching
|
|||||||
When I match I should get
|
When I match I should get
|
||||||
| trace | timestamps | code |
|
| trace | timestamps | code |
|
||||||
| ab1d | 0 1 2 3 | NoMatch |
|
| ab1d | 0 1 2 3 | NoMatch |
|
||||||
|
|
||||||
|
Scenario: Regression test - avoid collapsing legs of a tidied split trace
|
||||||
|
Given a grid size of 20 meters
|
||||||
|
Given the node map
|
||||||
|
"""
|
||||||
|
a--b--f
|
||||||
|
|
|
||||||
|
|
|
||||||
|
e--c---d--g
|
||||||
|
"""
|
||||||
|
Given the query options
|
||||||
|
| tidy | true |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | oneway |
|
||||||
|
| abf | no |
|
||||||
|
| be | no |
|
||||||
|
| ecdg | no |
|
||||||
|
|
||||||
|
When I match I should get
|
||||||
|
| trace | timestamps | matchings | code |
|
||||||
|
| abbecd | 10 11 27 1516914902 1516914913 1516914952 | ab,ecd | Ok |
|
||||||
|
|
||||||
|
Scenario: Regression test - waypoints trimming too much geometry
|
||||||
|
# fixes bug in map matching collapsing that was dropping path geometries
|
||||||
|
# after segments that had 0 distance in internal route results
|
||||||
|
Given the node map
|
||||||
|
"""
|
||||||
|
ad
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|e g
|
||||||
|
b--------------c
|
||||||
|
f h
|
||||||
|
"""
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes |
|
||||||
|
| ab |
|
||||||
|
| bc |
|
||||||
|
|
||||||
|
Given the query options
|
||||||
|
| waypoints | 0;4 |
|
||||||
|
| overview | full |
|
||||||
|
|
||||||
|
When I match I should get
|
||||||
|
| trace | geometry | code |
|
||||||
|
| defgh | 1,1,1,0.999461,1.000674,0.999461 | Ok |
|
||||||
|
|
||||||
|
@match @testbot
|
||||||
|
Scenario: Regression test - waypoints trimming too much geometry
|
||||||
|
Given the profile "testbot"
|
||||||
|
Given a grid size of 10 meters
|
||||||
|
Given the query options
|
||||||
|
| geometries | geojson |
|
||||||
|
Given the node map
|
||||||
|
"""
|
||||||
|
bh
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
c
|
||||||
|
g\
|
||||||
|
\k
|
||||||
|
\
|
||||||
|
\
|
||||||
|
\
|
||||||
|
j f
|
||||||
|
"""
|
||||||
|
And the ways
|
||||||
|
| nodes |
|
||||||
|
| hc |
|
||||||
|
| cf |
|
||||||
|
Given the query options
|
||||||
|
| waypoints | 0;3 |
|
||||||
|
| overview | full |
|
||||||
|
When I match I should get
|
||||||
|
| trace | geometry | code |
|
||||||
|
| bgkj | 1.000135,1,1.000135,0.99964,1.000387,0.999137 | Ok |
|
||||||
|
|||||||
@@ -48,12 +48,14 @@ inline Result keep_all(const MatchParameters ¶ms)
|
|||||||
|
|
||||||
result.can_be_removed.resize(params.coordinates.size(), false);
|
result.can_be_removed.resize(params.coordinates.size(), false);
|
||||||
result.was_waypoint.resize(params.coordinates.size(), true);
|
result.was_waypoint.resize(params.coordinates.size(), true);
|
||||||
|
// by default all input coordinates are treated as waypoints
|
||||||
if (!params.waypoints.empty())
|
if (!params.waypoints.empty())
|
||||||
{
|
{
|
||||||
for (const auto p : params.waypoints)
|
for (const auto p : params.waypoints)
|
||||||
{
|
{
|
||||||
result.was_waypoint.set(p, false);
|
result.was_waypoint.set(p, false);
|
||||||
}
|
}
|
||||||
|
// logic is a little funny, uses inversion to set the bitfield
|
||||||
result.was_waypoint.flip();
|
result.was_waypoint.flip();
|
||||||
}
|
}
|
||||||
result.tidied_to_original.reserve(params.coordinates.size());
|
result.tidied_to_original.reserve(params.coordinates.size());
|
||||||
|
|||||||
@@ -136,14 +136,11 @@ inline InternalRouteResult CollapseInternalRouteResult(const InternalRouteResult
|
|||||||
{
|
{
|
||||||
BOOST_ASSERT(!collapsed.unpacked_path_segments.empty());
|
BOOST_ASSERT(!collapsed.unpacked_path_segments.empty());
|
||||||
auto &last_segment = collapsed.unpacked_path_segments.back();
|
auto &last_segment = collapsed.unpacked_path_segments.back();
|
||||||
// deduplicate last segment (needs to be checked for empty for the same node query edge
|
|
||||||
// case)
|
|
||||||
if (!last_segment.empty())
|
|
||||||
last_segment.pop_back();
|
|
||||||
// update target phantom node of leg
|
|
||||||
BOOST_ASSERT(!collapsed.segment_end_coordinates.empty());
|
BOOST_ASSERT(!collapsed.segment_end_coordinates.empty());
|
||||||
collapsed.segment_end_coordinates.back().target_phantom =
|
collapsed.segment_end_coordinates.back().target_phantom =
|
||||||
leggy_result.segment_end_coordinates[i].target_phantom;
|
leggy_result.segment_end_coordinates[i].target_phantom;
|
||||||
|
collapsed.target_traversed_in_reverse.back() =
|
||||||
|
leggy_result.target_traversed_in_reverse[i];
|
||||||
// copy path segments into current leg
|
// copy path segments into current leg
|
||||||
last_segment.insert(last_segment.end(),
|
last_segment.insert(last_segment.end(),
|
||||||
leggy_result.unpacked_path_segments[i].begin(),
|
leggy_result.unpacked_path_segments[i].begin(),
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ class IntersectionHandler
|
|||||||
// Decide on a basic turn types
|
// Decide on a basic turn types
|
||||||
TurnType::Enum findBasicTurnType(const EdgeID via_edge, const ConnectedRoad &candidate) const;
|
TurnType::Enum findBasicTurnType(const EdgeID via_edge, const ConnectedRoad &candidate) const;
|
||||||
|
|
||||||
|
TurnType::Enum areSameClasses(const EdgeID via_edge, const ConnectedRoad &road) const;
|
||||||
|
|
||||||
// Find the most obvious turn to follow. The function returns an index into the intersection
|
// Find the most obvious turn to follow. The function returns an index into the intersection
|
||||||
// determining whether there is a road that can be seen as obvious turn in the presence of many
|
// determining whether there is a road that can be seen as obvious turn in the presence of many
|
||||||
// other possible turns. The function will consider road categories and other inputs like the
|
// other possible turns. The function will consider road categories and other inputs like the
|
||||||
|
|||||||
@@ -1171,7 +1171,7 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
|
|||||||
Nan::ThrowError("Timestamps array items must be numbers");
|
Nan::ThrowError("Timestamps array items must be numbers");
|
||||||
return match_parameters_ptr();
|
return match_parameters_ptr();
|
||||||
}
|
}
|
||||||
params->timestamps.emplace_back(static_cast<unsigned>(timestamp->NumberValue()));
|
params->timestamps.emplace_back(static_cast<std::size_t>(timestamp->NumberValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1220,6 +1220,60 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
|
|||||||
params->tidy = tidy->BooleanValue();
|
params->tidy = tidy->BooleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (obj->Has(Nan::New("waypoints").ToLocalChecked()))
|
||||||
|
{
|
||||||
|
v8::Local<v8::Value> waypoints = obj->Get(Nan::New("waypoints").ToLocalChecked());
|
||||||
|
if (waypoints.IsEmpty())
|
||||||
|
return match_parameters_ptr();
|
||||||
|
|
||||||
|
// must be array
|
||||||
|
if (!waypoints->IsArray())
|
||||||
|
{
|
||||||
|
Nan::ThrowError(
|
||||||
|
"Waypoints must be an array of integers corresponding to the input coordinates.");
|
||||||
|
return match_parameters_ptr();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto waypoints_array = v8::Local<v8::Array>::Cast(waypoints);
|
||||||
|
// must have at least two elements
|
||||||
|
if (waypoints_array->Length() < 2)
|
||||||
|
{
|
||||||
|
Nan::ThrowError("At least two waypoints must be provided");
|
||||||
|
return match_parameters_ptr();
|
||||||
|
}
|
||||||
|
auto coords_size = params->coordinates.size();
|
||||||
|
auto waypoints_array_size = waypoints_array->Length();
|
||||||
|
|
||||||
|
const auto first_index = Nan::To<std::uint32_t>(waypoints_array->Get(0)).FromJust();
|
||||||
|
const auto last_index =
|
||||||
|
Nan::To<std::uint32_t>(waypoints_array->Get(waypoints_array_size - 1)).FromJust();
|
||||||
|
if (first_index != 0 || last_index != coords_size - 1)
|
||||||
|
{
|
||||||
|
Nan::ThrowError("First and last waypoints values must correspond to first and last "
|
||||||
|
"coordinate indices");
|
||||||
|
return match_parameters_ptr();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < waypoints_array_size; ++i)
|
||||||
|
{
|
||||||
|
v8::Local<v8::Value> waypoint_value = waypoints_array->Get(i);
|
||||||
|
// all elements must be numbers
|
||||||
|
if (!waypoint_value->IsNumber())
|
||||||
|
{
|
||||||
|
Nan::ThrowError("Waypoint values must be an array of integers");
|
||||||
|
return match_parameters_ptr();
|
||||||
|
}
|
||||||
|
// check that the waypoint index corresponds with an inpute coordinate
|
||||||
|
const auto index = Nan::To<std::uint32_t>(waypoint_value).FromJust();
|
||||||
|
if (index >= coords_size)
|
||||||
|
{
|
||||||
|
Nan::ThrowError("Waypoints must correspond with the index of an input coordinate");
|
||||||
|
return match_parameters_ptr();
|
||||||
|
}
|
||||||
|
params->waypoints.emplace_back(static_cast<unsigned>(waypoint_value->NumberValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool parsedSuccessfully = parseCommonParameters(obj, params);
|
bool parsedSuccessfully = parseCommonParameters(obj, params);
|
||||||
if (!parsedSuccessfully)
|
if (!parsedSuccessfully)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "osrm",
|
"name": "osrm",
|
||||||
"version": "5.15.0",
|
"version": "5.15.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.",
|
"description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -247,6 +247,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Error: Check if user-supplied waypoints can be found in the resulting matches
|
// Error: Check if user-supplied waypoints can be found in the resulting matches
|
||||||
|
if (!parameters.waypoints.empty())
|
||||||
{
|
{
|
||||||
std::set<std::size_t> tidied_waypoints(tidied.parameters.waypoints.begin(),
|
std::set<std::size_t> tidied_waypoints(tidied.parameters.waypoints.begin(),
|
||||||
tidied.parameters.waypoints.end());
|
tidied.parameters.waypoints.end());
|
||||||
@@ -262,6 +263,9 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
"NoMatch", "Requested waypoint parameter could not be matched.", json_result);
|
"NoMatch", "Requested waypoint parameter could not be matched.", json_result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// we haven't errored yet, only allow leg collapsing if it was originally requested
|
||||||
|
BOOST_ASSERT(parameters.waypoints.empty() || sub_matchings.size() == 1);
|
||||||
|
const auto collapse_legs = !parameters.waypoints.empty();
|
||||||
|
|
||||||
// each sub_route will correspond to a MatchObject
|
// each sub_route will correspond to a MatchObject
|
||||||
std::vector<InternalRouteResult> sub_routes(sub_matchings.size());
|
std::vector<InternalRouteResult> sub_routes(sub_matchings.size());
|
||||||
@@ -286,7 +290,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
sub_routes[index] =
|
sub_routes[index] =
|
||||||
algorithms.ShortestPathSearch(sub_routes[index].segment_end_coordinates, {false});
|
algorithms.ShortestPathSearch(sub_routes[index].segment_end_coordinates, {false});
|
||||||
BOOST_ASSERT(sub_routes[index].shortest_path_weight != INVALID_EDGE_WEIGHT);
|
BOOST_ASSERT(sub_routes[index].shortest_path_weight != INVALID_EDGE_WEIGHT);
|
||||||
if (!tidied.parameters.waypoints.empty())
|
if (collapse_legs)
|
||||||
{
|
{
|
||||||
std::vector<bool> waypoint_legs;
|
std::vector<bool> waypoint_legs;
|
||||||
waypoint_legs.reserve(sub_matchings[index].indices.size());
|
waypoint_legs.reserve(sub_matchings[index].indices.size());
|
||||||
|
|||||||
@@ -102,6 +102,19 @@ TurnType::Enum IntersectionHandler::findBasicTurnType(const EdgeID via_edge,
|
|||||||
return TurnType::Turn;
|
return TurnType::Turn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TurnType::Enum IntersectionHandler::areSameClasses(const EdgeID via_edge,
|
||||||
|
const ConnectedRoad &road) const
|
||||||
|
{
|
||||||
|
const auto &in_classes =
|
||||||
|
node_data_container.GetAnnotation(node_based_graph.GetEdgeData(via_edge).annotation_data)
|
||||||
|
.classes;
|
||||||
|
const auto &out_classes =
|
||||||
|
node_data_container.GetAnnotation(node_based_graph.GetEdgeData(road.eid).annotation_data)
|
||||||
|
.classes;
|
||||||
|
|
||||||
|
return in_classes == out_classes;
|
||||||
|
}
|
||||||
|
|
||||||
TurnInstruction IntersectionHandler::getInstructionForObvious(const std::size_t num_roads,
|
TurnInstruction IntersectionHandler::getInstructionForObvious(const std::size_t num_roads,
|
||||||
const EdgeID via_edge,
|
const EdgeID via_edge,
|
||||||
const bool through_street,
|
const bool through_street,
|
||||||
@@ -195,7 +208,8 @@ TurnInstruction IntersectionHandler::getInstructionForObvious(const std::size_t
|
|||||||
if (needs_notification)
|
if (needs_notification)
|
||||||
return {TurnType::Notification, getTurnDirection(road.angle)};
|
return {TurnType::Notification, getTurnDirection(road.angle)};
|
||||||
else
|
else
|
||||||
return {num_roads == 2 ? TurnType::NoTurn : TurnType::Suppressed,
|
return {num_roads == 2 && areSameClasses(via_edge, road) ? TurnType::NoTurn
|
||||||
|
: TurnType::Suppressed,
|
||||||
getTurnDirection(road.angle)};
|
getTurnDirection(road.angle)};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -204,7 +218,7 @@ TurnInstruction IntersectionHandler::getInstructionForObvious(const std::size_t
|
|||||||
{
|
{
|
||||||
return {TurnType::Notification, getTurnDirection(road.angle)};
|
return {TurnType::Notification, getTurnDirection(road.angle)};
|
||||||
}
|
}
|
||||||
if (num_roads > 2)
|
if (num_roads > 2 || !areSameClasses(via_edge, road))
|
||||||
{
|
{
|
||||||
return {TurnType::Suppressed, getTurnDirection(road.angle)};
|
return {TurnType::Suppressed, getTurnDirection(road.angle)};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,3 +238,89 @@ test('match: match in Monaco without motorways', function(assert) {
|
|||||||
assert.equal(response.matchings.length, 1);
|
assert.equal(response.matchings.length, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('match: throws on invalid waypoints values needs at least two', function(assert) {
|
||||||
|
assert.plan(1);
|
||||||
|
var osrm = new OSRM(data_path);
|
||||||
|
var options = {
|
||||||
|
steps: true,
|
||||||
|
coordinates: three_test_coordinates,
|
||||||
|
waypoints: [0]
|
||||||
|
};
|
||||||
|
assert.throws(function() { osrm.match(options, function(err, response) {}); },
|
||||||
|
'At least two waypoints must be provided');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('match: throws on invalid waypoints values, needs first and last coordinate indices', function(assert) {
|
||||||
|
assert.plan(1);
|
||||||
|
var osrm = new OSRM(data_path);
|
||||||
|
var options = {
|
||||||
|
steps: true,
|
||||||
|
coordinates: three_test_coordinates,
|
||||||
|
waypoints: [1, 2]
|
||||||
|
};
|
||||||
|
assert.throws(function() { osrm.match(options, function(err, response) {console.log(err);}); },
|
||||||
|
'First and last waypoints values must correspond to first and last coordinate indices');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('match: throws on invalid waypoints values, order matters', function(assert) {
|
||||||
|
assert.plan(1);
|
||||||
|
var osrm = new OSRM(data_path);
|
||||||
|
var options = {
|
||||||
|
steps: true,
|
||||||
|
coordinates: three_test_coordinates,
|
||||||
|
waypoints: [2, 0]
|
||||||
|
};
|
||||||
|
assert.throws(function() { osrm.match(options, function(err, response) {console.log(err);}); },
|
||||||
|
'First and last waypoints values must correspond to first and last coordinate indices');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('match: throws on invalid waypoints values, waypoints must correspond with a coordinate index', function(assert) {
|
||||||
|
assert.plan(1);
|
||||||
|
var osrm = new OSRM(data_path);
|
||||||
|
var options = {
|
||||||
|
steps: true,
|
||||||
|
coordinates: three_test_coordinates,
|
||||||
|
waypoints: [0, 3, 2]
|
||||||
|
};
|
||||||
|
assert.throws(function() { osrm.match(options, function(err, response) {console.log(err);}); },
|
||||||
|
'Waypoints must correspond with the index of an input coordinate');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('match: error on split trace', function(assert) {
|
||||||
|
assert.plan(1);
|
||||||
|
var osrm = new OSRM(data_path);
|
||||||
|
var four_coords = Array.from(three_test_coordinates);
|
||||||
|
four_coords.push([7.41902,43.73487]);
|
||||||
|
var options = {
|
||||||
|
steps: true,
|
||||||
|
coordinates: four_coords,
|
||||||
|
timestamps: [1700, 1750, 1424684616, 1424684620],
|
||||||
|
waypoints: [0,3]
|
||||||
|
};
|
||||||
|
osrm.match(options, function(err, response) {
|
||||||
|
assert.ok(err, 'Errors with NoMatch');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('match: match in Monaco with waypoints', function(assert) {
|
||||||
|
assert.plan(6);
|
||||||
|
var osrm = new OSRM(data_path);
|
||||||
|
var options = {
|
||||||
|
steps: true,
|
||||||
|
coordinates: three_test_coordinates,
|
||||||
|
waypoints: [0,2]
|
||||||
|
};
|
||||||
|
osrm.match(options, function(err, response) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(response.matchings.length, 1);
|
||||||
|
assert.equal(response.matchings[0].legs.length, 1);
|
||||||
|
assert.ok(response.matchings.every(function(m) {
|
||||||
|
return !!m.distance && !!m.duration && Array.isArray(m.legs) && !!m.geometry && m.confidence > 0;
|
||||||
|
}))
|
||||||
|
assert.equal(response.tracepoints.length, 3);
|
||||||
|
assert.ok(response.tracepoints.every(function(t) {
|
||||||
|
return !!t.hint && !isNaN(t.matchings_index) && !isNaN(t.waypoint_index) && !!t.name;
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ BOOST_AUTO_TEST_CASE(unchanged_collapse_route_result)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(two_legs_to_one_leg)
|
BOOST_AUTO_TEST_CASE(two_legs_to_one_leg)
|
||||||
{
|
{
|
||||||
|
// turn_via_node, name_id, is_segregated, weight_until_turn,
|
||||||
|
// weight_of_turn,
|
||||||
|
// duration_until_turn, duration_of_turn, turn_instruction, lane_data, travel_mode, classes,
|
||||||
|
// entry_class, datasource_id, pre_turn_bearing, post_turn_bearing, left_hand
|
||||||
PathData pathy{2, 17, false, 2, 3, 4, 5, 0, {}, 4, 2, {}, 2, {1.0}, {1.0}, false};
|
PathData pathy{2, 17, false, 2, 3, 4, 5, 0, {}, 4, 2, {}, 2, {1.0}, {1.0}, false};
|
||||||
PathData kathy{1, 16, false, 1, 2, 3, 4, 1, {}, 3, 1, {}, 1, {2.0}, {3.0}, false};
|
PathData kathy{1, 16, false, 1, 2, 3, 4, 1, {}, 3, 1, {}, 1, {2.0}, {3.0}, false};
|
||||||
PathData cathy{3, 16, false, 1, 2, 3, 4, 1, {}, 3, 1, {}, 1, {2.0}, {3.0}, false};
|
PathData cathy{3, 16, false, 1, 2, 3, 4, 1, {}, 3, 1, {}, 1, {2.0}, {3.0}, false};
|
||||||
@@ -61,10 +65,11 @@ BOOST_AUTO_TEST_CASE(two_legs_to_one_leg)
|
|||||||
BOOST_CHECK_EQUAL(collapsed.segment_end_coordinates[0].target_phantom.forward_segment_id.id,
|
BOOST_CHECK_EQUAL(collapsed.segment_end_coordinates[0].target_phantom.forward_segment_id.id,
|
||||||
12);
|
12);
|
||||||
BOOST_CHECK_EQUAL(collapsed.segment_end_coordinates[0].source_phantom.forward_segment_id.id, 1);
|
BOOST_CHECK_EQUAL(collapsed.segment_end_coordinates[0].source_phantom.forward_segment_id.id, 1);
|
||||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0].size(), 3);
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0].size(), 4);
|
||||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0][0].turn_via_node, 2);
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0][0].turn_via_node, 2);
|
||||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0][1].turn_via_node, 1);
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0][1].turn_via_node, 1);
|
||||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0][2].turn_via_node, 3);
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0][2].turn_via_node, 1);
|
||||||
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0][3].turn_via_node, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(three_legs_to_two_legs)
|
BOOST_AUTO_TEST_CASE(three_legs_to_two_legs)
|
||||||
@@ -101,13 +106,14 @@ BOOST_AUTO_TEST_CASE(three_legs_to_two_legs)
|
|||||||
BOOST_CHECK_EQUAL(collapsed.segment_end_coordinates[1].target_phantom.forward_segment_id.id,
|
BOOST_CHECK_EQUAL(collapsed.segment_end_coordinates[1].target_phantom.forward_segment_id.id,
|
||||||
18);
|
18);
|
||||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0].size(), 2);
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0].size(), 2);
|
||||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[1].size(), 4);
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[1].size(), 5);
|
||||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0][0].turn_via_node, 2);
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0][0].turn_via_node, 2);
|
||||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0][1].turn_via_node, 1);
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[0][1].turn_via_node, 1);
|
||||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[1][0].turn_via_node, 1);
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[1][0].turn_via_node, 1);
|
||||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[1][1].turn_via_node, 5);
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[1][1].turn_via_node, 5);
|
||||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[1][2].turn_via_node, 3);
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[1][2].turn_via_node, 3);
|
||||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[1][3].turn_via_node, 4);
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[1][3].turn_via_node, 3);
|
||||||
|
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments[1][4].turn_via_node, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(two_legs_to_two_legs)
|
BOOST_AUTO_TEST_CASE(two_legs_to_two_legs)
|
||||||
|
|||||||
Reference in New Issue
Block a user