Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8e0b8e43d0 | ||
|
43e67241a0 | ||
|
217d2afbb4 | ||
|
6e9bb4ad75 | ||
|
165dba8fcc | ||
|
2bd511f194 | ||
|
2d5ef1f4cf | ||
|
76457a423f | ||
|
9ec4348bd1 | ||
|
309d00c5e3 | ||
|
effc85fa07 | ||
|
e0eedbc5f6 | ||
|
655d03592f | ||
|
6fadc4d8b8 | ||
|
00230967af | ||
|
f4bf76c98e | ||
|
1142a9e49b | ||
|
b168eca6d5 |
@ -17,6 +17,7 @@ notifications:
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- "5.8"
|
||||
# enable building tags
|
||||
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
|
||||
|
||||
|
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,3 +1,12 @@
|
||||
# 5.8.1
|
||||
- Changes from 5.8.0:
|
||||
- Bugfixes:
|
||||
- Fixes #4152: Superflous turn left instruction, when crossing a service-road.
|
||||
- Fixes #4189: Fixes missing turn lane information after a traffic light.
|
||||
- Fixes #4199: Data race-condition when updating segment speeds.
|
||||
- Fixes #3987: Fixes obvious turn detection at T-intersections with slip-roads.
|
||||
- Fixes #4161: Don't collapse U-Turns with other steps.
|
||||
|
||||
# 5.8.0
|
||||
- Changes from 5.7
|
||||
- API:
|
||||
@ -26,6 +35,7 @@
|
||||
- Fixed a copy/paste issue assigning wrong directions in similar turns (left over right)
|
||||
- #4074: fixed a bug that would announce entering highway ramps as u-turns
|
||||
- #4122: osrm-routed/libosrm should throw exception when a dataset incompatible with the requested algorithm is loaded
|
||||
- Avoid collapsing u-turns into combined turn instructions
|
||||
|
||||
# 5.7.1
|
||||
- Bugfixes
|
||||
|
@ -55,7 +55,7 @@ endif()
|
||||
project(OSRM C CXX)
|
||||
set(OSRM_VERSION_MAJOR 5)
|
||||
set(OSRM_VERSION_MINOR 8)
|
||||
set(OSRM_VERSION_PATCH 0)
|
||||
set(OSRM_VERSION_PATCH 1)
|
||||
set(OSRM_VERSION "${OSRM_VERSION_MAJOR}.${OSRM_VERSION_MINOR}.${OSRM_VERSION_PATCH}")
|
||||
|
||||
add_definitions(-DOSRM_PROJECT_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
@ -35,10 +35,10 @@ Feature: Turn Lane Guidance
|
||||
| restriction | bc | cd | c | no_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns | lanes |
|
||||
| a,e | in,cross,cross | depart,turn left,arrive | ,left:true straight:false right:false, |
|
||||
| a,g | in,straight,straight | depart,new name straight,arrive | ,left:false straight:true right:false, |
|
||||
| a,f | in,cross,cross | depart,turn right,arrive | ,left:false straight:false right:true, |
|
||||
| waypoints | route | turns | lanes |
|
||||
| a,e | in,cross,cross | depart,turn left,arrive | ,left:true straight:false, |
|
||||
| a,g | in,straight,straight | depart,new name straight,arrive | ,left:false straight:true, |
|
||||
| a,f | in,cross,cross | depart,continue right,arrive | ,, |
|
||||
|
||||
@sliproads
|
||||
Scenario: Separate Turn Lanes
|
||||
|
@ -359,7 +359,7 @@ Feature: Collapse
|
||||
| a,g | first,second,second | depart,turn left,arrive | a,b,g |
|
||||
| d,g | first,second,second | depart,turn right,arrive | d,e,g |
|
||||
| g,f | second,first,first | depart,turn right,arrive | g,e,f |
|
||||
| g,c | second,first,first | depart,end of road left,arrive | g,b,c |
|
||||
| g,c | second,first,first | depart,turn left,arrive | g,e,c |
|
||||
|
||||
Scenario: Do not collapse turning roads
|
||||
Given the node map
|
||||
@ -399,7 +399,7 @@ Feature: Collapse
|
||||
| waypoints | route | turns |
|
||||
| a,d | , | depart,arrive |
|
||||
|
||||
# This scenario could be considered to require a `turn left`. The danger to create random/unwanted instructions
|
||||
# This scenario could be considered to require a `turn left`. The danger to create random/unwanted instructions
|
||||
# from a setting like this are just to big, though. Therefore I opted to use `depart,arrive` only
|
||||
Scenario: Crossing Bridge into Segregated Turn
|
||||
Given the node map
|
||||
@ -690,9 +690,9 @@ Feature: Collapse
|
||||
| restriction | bc | dc | c | no_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns | locations |
|
||||
| a,g | road,cross,cross | depart,turn left,arrive | a,b,g |
|
||||
| a,e | road,road | depart,arrive | a,e |
|
||||
| waypoints | route | turns | locations |
|
||||
| a,g | road,road,cross,cross | depart,continue slight left,turn left,arrive | a,b,c,g |
|
||||
| a,e | road,road | depart,arrive | a,e |
|
||||
|
||||
Scenario: On-Off on Highway
|
||||
Given the node map
|
||||
@ -996,8 +996,8 @@ Feature: Collapse
|
||||
a . . b .'
|
||||
` d.
|
||||
f e
|
||||
"""
|
||||
#Check collapse.detail for a similar case (shorter) that does not classify these turns as a sliproad anymore
|
||||
"""
|
||||
#Check collapse.detail for a similar case (shorter) that does not classify these turns as a sliproad anymore
|
||||
|
||||
And the ways
|
||||
| nodes | name | oneway | highway |
|
||||
@ -1016,9 +1016,9 @@ Feature: Collapse
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns | locations |
|
||||
| a,g | road,cross,cross | depart,fork left,arrive | a,b,g |
|
||||
| a,e | road,road,road | depart,fork slight right,arrive | a,b,e |
|
||||
| a,f | road,road,cross,cross | depart,fork slight right,turn right,arrive | a,b,d,f |
|
||||
| a,g | road,road,cross,cross | depart,fork slight left,turn left,arrive | a,b,c,g |
|
||||
| a,e | road,road,road | depart,fork slight right,arrive | a,b,e |
|
||||
| a,f | road,road,cross,cross | depart,fork slight right,turn right,arrive | a,b,d,f |
|
||||
|
||||
|
||||
# http://www.openstreetmap.org/way/92415447 #3933
|
||||
@ -1055,3 +1055,22 @@ Feature: Collapse
|
||||
When I route I should get
|
||||
| waypoints | route | turns | locations |
|
||||
| a,i | President Avenue,Princes Highway,Princes Highway | depart,turn left,arrive | a,b,i |
|
||||
|
||||
|
||||
Scenario: Don't combine uturns
|
||||
Given the node map
|
||||
"""
|
||||
2 d
|
||||
a - - b - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - c
|
||||
1
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| ab | tertiary |
|
||||
| bc | tertiary |
|
||||
| bd | service |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | bearings | route | turns | locations |
|
||||
| 1,2 | 90 270 | ab,bd,bd,ab,ab | depart,turn left,continue uturn,turn right,arrive | _,b,d,b,_ |
|
||||
|
48
features/guidance/driveway.feature
Normal file
48
features/guidance/driveway.feature
Normal file
@ -0,0 +1,48 @@
|
||||
@driveway @guidance
|
||||
Feature: Driveways intersections
|
||||
|
||||
Background:
|
||||
Given the profile "car"
|
||||
Given a grid size of 5 meters
|
||||
|
||||
Scenario: Road with a turn to service road
|
||||
Given the node map
|
||||
"""
|
||||
a
|
||||
~.
|
||||
b----c----d
|
||||
|
|
||||
e
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes | highway | name | oneway |
|
||||
| abc | trunk | first | yes |
|
||||
| cd | trunk | second | yes |
|
||||
| be | service | parking | yes |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns | locations |
|
||||
| a,d | first,second | depart,arrive | a,d |
|
||||
|
||||
|
||||
Scenario: Turn Instead of Ramp
|
||||
Given the node map
|
||||
"""
|
||||
a
|
||||
~.
|
||||
b----c----d
|
||||
|
|
||||
e
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes | highway | name | oneway |
|
||||
| ab | trunk | | yes |
|
||||
| bc | trunk | | yes |
|
||||
| cd | trunk | second | yes |
|
||||
| be | service | parking | yes |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns | locations |
|
||||
| a,d | ,second | depart,arrive | a,d |
|
@ -201,14 +201,14 @@ Feature: Simple Turns
|
||||
| ef | residential | road | 2 | yes |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns | locations |
|
||||
| a,c | road,road | depart,arrive | a,c |
|
||||
| c,a | road,road | depart,arrive | c,a |
|
||||
| g,a | turn,road,road | depart,turn left,arrive | g,b,a |
|
||||
| g,c | turn,road,road | depart,turn right,arrive | g,b,c |
|
||||
| g,f | turn,road,road | depart,turn left,arrive | g,e,f |
|
||||
| c,f | road,road,road | depart,continue right,arrive | c,b,f |
|
||||
| a,f | road,road,road | depart,continue uturn,arrive | a,b,f |
|
||||
| waypoints | route | turns | locations |
|
||||
| a,c | road,road | depart,arrive | a,c |
|
||||
| c,a | road,road | depart,arrive | c,a |
|
||||
| g,a | turn,road,road | depart,turn left,arrive | g,b,a |
|
||||
| g,c | turn,road,road | depart,turn right,arrive | g,b,c |
|
||||
| g,f | turn,road,road | depart,end of road left,arrive | g,e,f |
|
||||
| c,f | road,road,road | depart,turn right,arrive | c,b,f |
|
||||
| a,f | road,road,road | depart,continue uturn,arrive | a,b,f |
|
||||
|
||||
# http://www.openstreetmap.org/#map=19/52.48753/13.52838
|
||||
Scenario: Traffic Circle
|
||||
@ -1312,8 +1312,8 @@ Feature: Simple Turns
|
||||
|
||||
# we don't care for turn instructions, this is a coordinate extraction bug check
|
||||
When I route I should get
|
||||
| waypoints | route | intersections |
|
||||
| a,g | ab,bcdefgh | true:90,true:45 false:180 false:270;true:180 |
|
||||
| waypoints | route | intersections |
|
||||
| a,g | ab,bcdefgh,bcdefgh | true:90;true:45 false:180 false:270;true:180 |
|
||||
|
||||
#https://github.com/Project-OSRM/osrm-backend/pull/3469#issuecomment-270806580
|
||||
Scenario: Oszillating Lower Priority Road
|
||||
|
@ -1215,3 +1215,32 @@ Feature: Turn Lane Guidance
|
||||
| waypoints | route | turns | lanes |
|
||||
| a,d | road,cross,cross | depart,turn left,arrive | ,none:true none:false right:false, |
|
||||
| a,c | road,road | depart,arrive | , |
|
||||
|
||||
@4189
|
||||
Scenario: U-turn after a traffic light
|
||||
Given the node map
|
||||
"""
|
||||
j k
|
||||
: :
|
||||
f---g-h-i
|
||||
: :
|
||||
a-b-c-d-e
|
||||
: :
|
||||
l m
|
||||
"""
|
||||
|
||||
And the nodes
|
||||
| node | highway |
|
||||
| b | traffic_signals |
|
||||
|
||||
And the ways
|
||||
| nodes | name | lanes | turn:lanes | oneway |
|
||||
| ab | road1 | 3 | left\|through\|through;right | yes |
|
||||
| bcde | road1 | 2 | | yes |
|
||||
| ihgf | road1 | 2 | | yes |
|
||||
| jgcl | road2 | 2 | | yes |
|
||||
| mdhk | road2 | 2 | | yes |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns | lanes | locations |
|
||||
| a,f | road1,road1,road1 | depart,continue uturn,arrive | ,left:true straight:false straight;right:false, | a,d,f |
|
||||
|
@ -1319,3 +1319,33 @@ Feature: Simple Turns
|
||||
When I route I should get
|
||||
| waypoints | route | ref | turns |
|
||||
| a,h | Road,,, | C 42,,C 42,C 42 | depart,on ramp right,merge slight left,arrive |
|
||||
|
||||
Scenario: End of road, T-intersection, no obvious turn, only one road allowed
|
||||
Given the node map
|
||||
"""
|
||||
d
|
||||
.
|
||||
a . b . . c
|
||||
' .
|
||||
'e
|
||||
.
|
||||
f
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes | highway | oneway | ref |
|
||||
| ab | primary | | B 191 |
|
||||
| bc | primary | | B 191 |
|
||||
| be | primary_link | yes | |
|
||||
| dc | primary | | B 4;B 191 |
|
||||
| ce | primary | | B 4 |
|
||||
| ef | primary | | B 4 |
|
||||
|
||||
And the relations
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | bc | ce | c | no_right_turn |
|
||||
| restriction | be | ef | e | only_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,d | ab,dc,dc | depart,turn left,arrive |
|
||||
|
40
include/extractor/guidance/driveway_handler.hpp
Normal file
40
include/extractor/guidance/driveway_handler.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_DRIVEWAY_HANDLER_HPP
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_DRIVEWAY_HANDLER_HPP
|
||||
|
||||
#include "extractor/guidance/intersection_handler.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
// Intersection handlers deal with all issues related to intersections.
|
||||
class DrivewayHandler final : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
DrivewayHandler(const IntersectionGenerator &intersection_generator,
|
||||
const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
|
||||
~DrivewayHandler() override final = default;
|
||||
|
||||
// check whether the handler can actually handle the intersection
|
||||
bool canProcess(const NodeID nid,
|
||||
const EdgeID via_eid,
|
||||
const Intersection &intersection) const override final;
|
||||
|
||||
// process the intersection
|
||||
Intersection operator()(const NodeID nid,
|
||||
const EdgeID via_eid,
|
||||
Intersection intersection) const override final;
|
||||
};
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /* OSRM_EXTRACTOR_GUIDANCE_DRIVEWAY_HANDLER_HPP */
|
@ -27,7 +27,6 @@ namespace guidance
|
||||
{
|
||||
|
||||
// Intersection handlers deal with all issues related to intersections.
|
||||
// They assign appropriate turn operations to the TurnOperations.
|
||||
// This base class provides both the interface and implementations for
|
||||
// common functions.
|
||||
class IntersectionHandler
|
||||
@ -114,6 +113,8 @@ class IntersectionHandler
|
||||
// For this scenario returns intersection at `b` and `b`.
|
||||
boost::optional<IntersectionHandler::IntersectionViewAndNode>
|
||||
getNextIntersection(const NodeID at, const EdgeID via) const;
|
||||
|
||||
bool isSameName(const EdgeID source_edge_id, const EdgeID target_edge_id) const;
|
||||
};
|
||||
|
||||
// Impl.
|
||||
@ -410,14 +411,11 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
const auto &best_option_data =
|
||||
node_based_graph.GetEdgeData(intersection[best_option].eid);
|
||||
const auto adjusted_distinction_ratio = [&]() {
|
||||
// not allowed competitors are easily distinct
|
||||
if (!intersection[index].entry_allowed)
|
||||
return 0.7 * DISTINCTION_RATIO;
|
||||
// a bit less obvious are road classes
|
||||
else if (in_way_data.road_classification == best_option_data.road_classification &&
|
||||
best_option_data.road_classification.GetPriority() <
|
||||
node_based_graph.GetEdgeData(intersection[index].eid)
|
||||
.road_classification.GetPriority())
|
||||
// obviousness by road classes
|
||||
if (in_way_data.road_classification == best_option_data.road_classification &&
|
||||
best_option_data.road_classification.GetPriority() <
|
||||
node_based_graph.GetEdgeData(intersection[index].eid)
|
||||
.road_classification.GetPriority())
|
||||
return 0.8 * DISTINCTION_RATIO;
|
||||
// if road classes are the same, we use the full ratio
|
||||
else
|
||||
|
@ -20,7 +20,6 @@ namespace guidance
|
||||
{
|
||||
|
||||
// Intersection handlers deal with all issues related to intersections.
|
||||
// They assign appropriate turn operations to the TurnOperations.
|
||||
class MotorwayHandler : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
|
@ -21,7 +21,6 @@ namespace guidance
|
||||
{
|
||||
|
||||
// Intersection handlers deal with all issues related to intersections.
|
||||
// They assign appropriate turn operations to the TurnOperations.
|
||||
class SliproadHandler final : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define OSRM_EXTRACTOR_TURN_ANALYSIS
|
||||
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
#include "extractor/guidance/driveway_handler.hpp"
|
||||
#include "extractor/guidance/intersection.hpp"
|
||||
#include "extractor/guidance/intersection_generator.hpp"
|
||||
#include "extractor/guidance/intersection_normalization_operation.hpp"
|
||||
@ -87,6 +88,7 @@ class TurnAnalysis
|
||||
const TurnHandler turn_handler;
|
||||
const SliproadHandler sliproad_handler;
|
||||
const SuppressModeHandler suppress_mode_handler;
|
||||
const DrivewayHandler driveway_handler;
|
||||
|
||||
// Utility function, setting basic turn types. Prepares for normal turn handling.
|
||||
Intersection
|
||||
|
@ -24,7 +24,6 @@ namespace guidance
|
||||
{
|
||||
|
||||
// Intersection handlers deal with all issues related to intersections.
|
||||
// They assign appropriate turn operations to the TurnOperations.
|
||||
class TurnHandler : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/iterator/reverse_iterator.hpp>
|
||||
#include <tbb/atomic.h>
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
@ -348,7 +349,7 @@ template <typename T, std::size_t Bits, storage::Ownership Ownership> class Pack
|
||||
fill(initial_value);
|
||||
}
|
||||
|
||||
PackedVector(util::ViewOrVector<std::uint64_t, Ownership> vec_, std::size_t num_elements)
|
||||
PackedVector(util::ViewOrVector<WordT, Ownership> vec_, std::size_t num_elements)
|
||||
: vec(std::move(vec_)), num_elements(num_elements)
|
||||
{
|
||||
initialize();
|
||||
@ -497,20 +498,39 @@ template <typename T, std::size_t Bits, storage::Ownership Ownership> class Pack
|
||||
|
||||
inline void set_value(const InternalIndex internal_index, const T value)
|
||||
{
|
||||
// ⚠ The method uses CAS spinlocks to prevent data races in parallel calls
|
||||
// TBB internal atomic's are used for CAS on non-atomic data
|
||||
// Parallel read and write access is not allowed
|
||||
|
||||
auto &lower_word = vec[internal_index.lower_word];
|
||||
auto &upper_word = vec[internal_index.lower_word + 1];
|
||||
|
||||
lower_word = set_lower_value<WordT, T>(lower_word,
|
||||
lower_mask[internal_index.element],
|
||||
lower_offset[internal_index.element],
|
||||
value);
|
||||
upper_word = set_upper_value<WordT, T>(upper_word,
|
||||
upper_mask[internal_index.element],
|
||||
upper_offset[internal_index.element],
|
||||
value);
|
||||
// Lock-free update of the lower word
|
||||
WordT local_lower_word, new_lower_word;
|
||||
do
|
||||
{
|
||||
local_lower_word = lower_word;
|
||||
new_lower_word = set_lower_value<WordT, T>(local_lower_word,
|
||||
lower_mask[internal_index.element],
|
||||
lower_offset[internal_index.element],
|
||||
value);
|
||||
} while (tbb::internal::as_atomic(lower_word)
|
||||
.compare_and_swap(new_lower_word, local_lower_word) != local_lower_word);
|
||||
|
||||
// Lock-free update of the upper word
|
||||
WordT local_upper_word, new_upper_word;
|
||||
do
|
||||
{
|
||||
local_upper_word = upper_word;
|
||||
new_upper_word = set_upper_value<WordT, T>(local_upper_word,
|
||||
upper_mask[internal_index.element],
|
||||
upper_offset[internal_index.element],
|
||||
value);
|
||||
} while (tbb::internal::as_atomic(upper_word)
|
||||
.compare_and_swap(new_upper_word, local_upper_word) != local_upper_word);
|
||||
}
|
||||
|
||||
util::ViewOrVector<std::uint64_t, Ownership> vec;
|
||||
util::ViewOrVector<WordT, Ownership> vec;
|
||||
std::uint64_t num_elements = 0;
|
||||
};
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "osrm",
|
||||
"version": "5.8.0-latest.1",
|
||||
"version": "5.8.1",
|
||||
"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": {
|
||||
|
@ -61,6 +61,22 @@ bool isShortAndUndisturbed(const RouteStep &step)
|
||||
return is_short && noIntermediaryIntersections(step);
|
||||
}
|
||||
|
||||
// On dual carriageways, we might want to use u-turns in combination with new-name instructions.
|
||||
// Otherwise a u-turn should never be part of a collapsing instructions.
|
||||
bool noBadUTurnCombination(const RouteStepIterator first, const RouteStepIterator second)
|
||||
{
|
||||
auto has_uturn = hasModifier(*first, DirectionModifier::UTurn) ||
|
||||
hasModifier(*second, DirectionModifier::UTurn);
|
||||
|
||||
auto const from_name_change_into_uturn =
|
||||
hasTurnType(*first, TurnType::NewName) && hasModifier(*second, DirectionModifier::UTurn);
|
||||
|
||||
auto const uturn_into_name_change =
|
||||
hasTurnType(*second, TurnType::NewName) && hasModifier(*first, DirectionModifier::UTurn);
|
||||
|
||||
return !has_uturn || from_name_change_into_uturn || uturn_into_name_change;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool basicCollapsePreconditions(const RouteStepIterator first, const RouteStepIterator second)
|
||||
@ -70,7 +86,10 @@ bool basicCollapsePreconditions(const RouteStepIterator first, const RouteStepIt
|
||||
|
||||
const auto waypoint_type = hasWaypointType(*first) || hasWaypointType(*second);
|
||||
|
||||
return !has_roundabout_type && !waypoint_type && haveSameMode(*first, *second);
|
||||
const auto contains_bad_uturn = !noBadUTurnCombination(first, second);
|
||||
|
||||
return !has_roundabout_type && !waypoint_type && haveSameMode(*first, *second) &&
|
||||
!contains_bad_uturn;
|
||||
}
|
||||
|
||||
bool basicCollapsePreconditions(const RouteStepIterator first,
|
||||
@ -81,8 +100,11 @@ bool basicCollapsePreconditions(const RouteStepIterator first,
|
||||
hasRoundaboutType(second->maneuver.instruction) ||
|
||||
hasRoundaboutType(third->maneuver.instruction);
|
||||
|
||||
const auto contains_bad_uturn =
|
||||
!noBadUTurnCombination(first, second) && !noBadUTurnCombination(second, third);
|
||||
|
||||
// require modes to match up
|
||||
return !has_roundabout_type && haveSameMode(*first, *second, *third);
|
||||
return !has_roundabout_type && haveSameMode(*first, *second, *third) && !contains_bad_uturn;
|
||||
}
|
||||
|
||||
bool isStaggeredIntersection(const RouteStepIterator step_prior_to_intersection,
|
||||
|
@ -831,6 +831,51 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
|
||||
values_writer.add_float(util::vector_tile::VARIANT_TYPE_FLOAT, value);
|
||||
}
|
||||
}
|
||||
|
||||
// OSM Node tile layer
|
||||
{
|
||||
protozero::pbf_writer point_layer_writer(tile_writer, util::vector_tile::LAYER_TAG);
|
||||
point_layer_writer.add_uint32(util::vector_tile::VERSION_TAG, 2); // version
|
||||
point_layer_writer.add_string(util::vector_tile::NAME_TAG, "osmnodes"); // name
|
||||
point_layer_writer.add_uint32(util::vector_tile::EXTENT_TAG,
|
||||
util::vector_tile::EXTENT); // extent
|
||||
|
||||
std::vector<NodeID> internal_nodes;
|
||||
internal_nodes.reserve(edges.size() * 2);
|
||||
for (const auto &edge : edges)
|
||||
{
|
||||
internal_nodes.push_back(edge.u);
|
||||
internal_nodes.push_back(edge.v);
|
||||
}
|
||||
std::sort(internal_nodes.begin(), internal_nodes.end());
|
||||
auto new_end = std::unique(internal_nodes.begin(), internal_nodes.end());
|
||||
internal_nodes.resize(new_end - internal_nodes.begin());
|
||||
|
||||
for (const auto &internal_node : internal_nodes)
|
||||
{
|
||||
const auto coord = facade.GetCoordinateOfNode(internal_node);
|
||||
const auto tile_point = coordinatesToTilePoint(coord, tile_bbox);
|
||||
if (!boost::geometry::within(point_t(tile_point.x, tile_point.y), clip_box))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
protozero::pbf_writer feature_writer(point_layer_writer,
|
||||
util::vector_tile::FEATURE_TAG);
|
||||
// Field 3 is the "geometry type" field. Value 1 is "point"
|
||||
feature_writer.add_enum(util::vector_tile::GEOMETRY_TAG,
|
||||
util::vector_tile::GEOMETRY_TYPE_POINT); // geometry type
|
||||
const auto osmid =
|
||||
static_cast<OSMNodeID::value_type>(facade.GetOSMNodeIDOfNode(internal_node));
|
||||
feature_writer.add_uint64(util::vector_tile::ID_TAG, osmid); // id
|
||||
// There are no additional properties, just the ID and the geometry
|
||||
{
|
||||
// Add the geometry as the last field in this feature
|
||||
protozero::packed_field_uint32 geometry(
|
||||
feature_writer, util::vector_tile::FEATURE_GEOMETRIES_TAG);
|
||||
encodePoint(tile_point, geometry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// protozero serializes data during object destructors, so once the scope closes,
|
||||
// our result buffer will have all the tile data encoded into it.
|
||||
|
@ -111,43 +111,6 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
||||
BOOST_ASSERT(graph.GetEdgeData(forward_e2).name_id ==
|
||||
graph.GetEdgeData(reverse_e2).name_id);
|
||||
|
||||
// Do not compress edge if it crosses a traffic signal.
|
||||
// This can't be done in CanCombineWith, becase we only store the
|
||||
// traffic signals in the `traffic_lights` list, which EdgeData
|
||||
// doesn't have access to.
|
||||
const bool has_node_penalty = traffic_lights.find(node_v) != traffic_lights.end();
|
||||
if (has_node_penalty)
|
||||
continue;
|
||||
|
||||
// Get weights before graph is modified
|
||||
const auto forward_weight1 = fwd_edge_data1.weight;
|
||||
const auto forward_weight2 = fwd_edge_data2.weight;
|
||||
const auto forward_duration1 = fwd_edge_data1.duration;
|
||||
const auto forward_duration2 = fwd_edge_data2.duration;
|
||||
|
||||
BOOST_ASSERT(0 != forward_weight1);
|
||||
BOOST_ASSERT(0 != forward_weight2);
|
||||
|
||||
const auto reverse_weight1 = rev_edge_data1.weight;
|
||||
const auto reverse_weight2 = rev_edge_data2.weight;
|
||||
const auto reverse_duration1 = rev_edge_data1.duration;
|
||||
const auto reverse_duration2 = rev_edge_data2.duration;
|
||||
|
||||
BOOST_ASSERT(0 != reverse_weight1);
|
||||
BOOST_ASSERT(0 != reverse_weight2);
|
||||
|
||||
// add weight of e2's to e1
|
||||
graph.GetEdgeData(forward_e1).weight += forward_weight2;
|
||||
graph.GetEdgeData(reverse_e1).weight += reverse_weight2;
|
||||
|
||||
// add duration of e2's to e1
|
||||
graph.GetEdgeData(forward_e1).duration += forward_duration2;
|
||||
graph.GetEdgeData(reverse_e1).duration += reverse_duration2;
|
||||
|
||||
// extend e1's to targets of e2's
|
||||
graph.SetTarget(forward_e1, node_w);
|
||||
graph.SetTarget(reverse_e1, node_u);
|
||||
|
||||
/*
|
||||
* Remember Lane Data for compressed parts. This handles scenarios where lane-data
|
||||
* is
|
||||
@ -185,12 +148,51 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
||||
return front;
|
||||
return back;
|
||||
};
|
||||
graph.GetEdgeData(forward_e1).lane_description_id =
|
||||
selectLaneID(graph.GetEdgeData(forward_e1).lane_description_id,
|
||||
fwd_edge_data2.lane_description_id);
|
||||
graph.GetEdgeData(reverse_e1).lane_description_id =
|
||||
selectLaneID(graph.GetEdgeData(reverse_e1).lane_description_id,
|
||||
rev_edge_data2.lane_description_id);
|
||||
graph.GetEdgeData(forward_e1).lane_description_id = selectLaneID(
|
||||
fwd_edge_data1.lane_description_id, fwd_edge_data2.lane_description_id);
|
||||
graph.GetEdgeData(reverse_e1).lane_description_id = selectLaneID(
|
||||
rev_edge_data1.lane_description_id, rev_edge_data2.lane_description_id);
|
||||
graph.GetEdgeData(forward_e2).lane_description_id = selectLaneID(
|
||||
fwd_edge_data2.lane_description_id, fwd_edge_data1.lane_description_id);
|
||||
graph.GetEdgeData(reverse_e2).lane_description_id = selectLaneID(
|
||||
rev_edge_data2.lane_description_id, rev_edge_data1.lane_description_id);
|
||||
|
||||
// Do not compress edge if it crosses a traffic signal.
|
||||
// This can't be done in CanCombineWith, becase we only store the
|
||||
// traffic signals in the `traffic_lights` list, which EdgeData
|
||||
// doesn't have access to.
|
||||
const bool has_node_penalty = traffic_lights.find(node_v) != traffic_lights.end();
|
||||
if (has_node_penalty)
|
||||
continue;
|
||||
|
||||
// Get weights before graph is modified
|
||||
const auto forward_weight1 = fwd_edge_data1.weight;
|
||||
const auto forward_weight2 = fwd_edge_data2.weight;
|
||||
const auto forward_duration1 = fwd_edge_data1.duration;
|
||||
const auto forward_duration2 = fwd_edge_data2.duration;
|
||||
|
||||
BOOST_ASSERT(0 != forward_weight1);
|
||||
BOOST_ASSERT(0 != forward_weight2);
|
||||
|
||||
const auto reverse_weight1 = rev_edge_data1.weight;
|
||||
const auto reverse_weight2 = rev_edge_data2.weight;
|
||||
const auto reverse_duration1 = rev_edge_data1.duration;
|
||||
const auto reverse_duration2 = rev_edge_data2.duration;
|
||||
|
||||
BOOST_ASSERT(0 != reverse_weight1);
|
||||
BOOST_ASSERT(0 != reverse_weight2);
|
||||
|
||||
// add weight of e2's to e1
|
||||
graph.GetEdgeData(forward_e1).weight += forward_weight2;
|
||||
graph.GetEdgeData(reverse_e1).weight += reverse_weight2;
|
||||
|
||||
// add duration of e2's to e1
|
||||
graph.GetEdgeData(forward_e1).duration += forward_duration2;
|
||||
graph.GetEdgeData(reverse_e1).duration += reverse_duration2;
|
||||
|
||||
// extend e1's to targets of e2's
|
||||
graph.SetTarget(forward_e1, node_w);
|
||||
graph.SetTarget(reverse_e1, node_u);
|
||||
|
||||
// remove e2's (if bidir, otherwise only one)
|
||||
graph.DeleteEdge(node_v, forward_e2);
|
||||
|
80
src/extractor/guidance/driveway_handler.cpp
Normal file
80
src/extractor/guidance/driveway_handler.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
#include "extractor/guidance/driveway_handler.hpp"
|
||||
|
||||
#include "util/assert.hpp"
|
||||
|
||||
using osrm::extractor::guidance::getTurnDirection;
|
||||
using osrm::util::angularDeviation;
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
DrivewayHandler::DrivewayHandler(const IntersectionGenerator &intersection_generator,
|
||||
const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table)
|
||||
: IntersectionHandler(node_based_graph,
|
||||
coordinates,
|
||||
name_table,
|
||||
street_name_suffix_table,
|
||||
intersection_generator)
|
||||
{
|
||||
}
|
||||
|
||||
// The intersection without major roads needs to pass by service roads (bd, be)
|
||||
// d
|
||||
// .
|
||||
// a--->b--->c
|
||||
// .
|
||||
// e
|
||||
bool DrivewayHandler::canProcess(const NodeID /*nid*/,
|
||||
const EdgeID /*via_eid*/,
|
||||
const Intersection &intersection) const
|
||||
{
|
||||
const auto from_eid = intersection.getUTurnRoad().eid;
|
||||
|
||||
if (intersection.size() <= 2 ||
|
||||
node_based_graph.GetEdgeData(from_eid).road_classification.IsLowPriorityRoadClass())
|
||||
return false;
|
||||
|
||||
auto low_priority_count =
|
||||
std::count_if(intersection.begin(), intersection.end(), [this](const auto &road) {
|
||||
return node_based_graph.GetEdgeData(road.eid)
|
||||
.road_classification.IsLowPriorityRoadClass();
|
||||
});
|
||||
|
||||
// Process intersection if it has two edges with normal priority and one is the entry edge,
|
||||
// and also has at least one edge with lower priority
|
||||
return static_cast<std::size_t>(low_priority_count) + 2 == intersection.size();
|
||||
}
|
||||
|
||||
Intersection DrivewayHandler::
|
||||
operator()(const NodeID nid, const EdgeID source_edge_id, Intersection intersection) const
|
||||
{
|
||||
auto road =
|
||||
std::find_if(intersection.begin() + 1, intersection.end(), [this](const auto &road) {
|
||||
return !node_based_graph.GetEdgeData(road.eid)
|
||||
.road_classification.IsLowPriorityRoadClass();
|
||||
});
|
||||
|
||||
(void)nid;
|
||||
OSRM_ASSERT(road != intersection.end(), coordinates[nid]);
|
||||
|
||||
if (road->instruction == TurnInstruction::INVALID())
|
||||
return intersection;
|
||||
|
||||
OSRM_ASSERT(road->instruction.type == TurnType::Turn, coordinates[nid]);
|
||||
|
||||
road->instruction.type =
|
||||
isSameName(source_edge_id, road->eid) ? TurnType::NoTurn : TurnType::NewName;
|
||||
|
||||
return intersection;
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
@ -436,6 +436,19 @@ IntersectionHandler::getNextIntersection(const NodeID at, const EdgeID via) cons
|
||||
IntersectionViewAndNode{std::move(intersection), intersection_node});
|
||||
}
|
||||
|
||||
bool IntersectionHandler::isSameName(const EdgeID source_edge_id, const EdgeID target_edge_id) const
|
||||
{
|
||||
const auto &source_edge_data = node_based_graph.GetEdgeData(source_edge_id);
|
||||
const auto &target_edge_data = node_based_graph.GetEdgeData(target_edge_id);
|
||||
|
||||
return source_edge_data.name_id != EMPTY_NAMEID && //
|
||||
target_edge_data.name_id != EMPTY_NAMEID && //
|
||||
!util::guidance::requiresNameAnnounced(source_edge_data.name_id,
|
||||
target_edge_data.name_id,
|
||||
name_table,
|
||||
street_name_suffix_table); //
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
@ -473,17 +473,7 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
|
||||
// In those cases the obvious non-Sliproad is now obvious and we discard the Fork turn type.
|
||||
if (sliproad_found && main_road.instruction.type == TurnType::Fork)
|
||||
{
|
||||
const auto &source_edge_data = node_based_graph.GetEdgeData(source_edge_id);
|
||||
const auto &main_road_data = node_based_graph.GetEdgeData(main_road.eid);
|
||||
|
||||
const auto same_name = source_edge_data.name_id != EMPTY_NAMEID && //
|
||||
main_road_data.name_id != EMPTY_NAMEID && //
|
||||
!util::guidance::requiresNameAnnounced(source_edge_data.name_id,
|
||||
main_road_data.name_id,
|
||||
name_table,
|
||||
street_name_suffix_table); //
|
||||
|
||||
if (same_name)
|
||||
if (isSameName(source_edge_id, main_road.eid))
|
||||
{
|
||||
if (angularDeviation(main_road.angle, STRAIGHT_ANGLE) < 5)
|
||||
intersection[*obvious].instruction.type = TurnType::Suppressed;
|
||||
@ -492,7 +482,7 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
|
||||
intersection[*obvious].instruction.direction_modifier =
|
||||
getTurnDirection(intersection[*obvious].angle);
|
||||
}
|
||||
else if (main_road_data.name_id != EMPTY_NAMEID)
|
||||
else if (node_based_graph.GetEdgeData(main_road.eid).name_id != EMPTY_NAMEID)
|
||||
{
|
||||
intersection[*obvious].instruction.type = TurnType::NewName;
|
||||
intersection[*obvious].instruction.direction_modifier =
|
||||
|
@ -68,7 +68,12 @@ TurnAnalysis::TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
node_based_graph,
|
||||
coordinates,
|
||||
name_table,
|
||||
street_name_suffix_table)
|
||||
street_name_suffix_table),
|
||||
driveway_handler(intersection_generator,
|
||||
node_based_graph,
|
||||
coordinates,
|
||||
name_table,
|
||||
street_name_suffix_table)
|
||||
{
|
||||
}
|
||||
|
||||
@ -132,8 +137,14 @@ Intersection TurnAnalysis::AssignTurnTypes(const NodeID node_prior_to_intersecti
|
||||
// set initial defaults for normal turns and modifier based on angle
|
||||
intersection =
|
||||
setTurnTypes(node_prior_to_intersection, entering_via_edge, std::move(intersection));
|
||||
if (motorway_handler.canProcess(
|
||||
if (driveway_handler.canProcess(
|
||||
node_prior_to_intersection, entering_via_edge, intersection))
|
||||
{
|
||||
intersection = driveway_handler(
|
||||
node_prior_to_intersection, entering_via_edge, std::move(intersection));
|
||||
}
|
||||
else if (motorway_handler.canProcess(
|
||||
node_prior_to_intersection, entering_via_edge, intersection))
|
||||
{
|
||||
intersection = motorway_handler(
|
||||
node_prior_to_intersection, entering_via_edge, std::move(intersection));
|
||||
|
@ -180,7 +180,7 @@ TurnLaneScenario TurnLaneHandler::deduceScenario(const NodeID at,
|
||||
(intersection.size() == 2 &&
|
||||
((lane_description_id != INVALID_LANE_DESCRIPTIONID &&
|
||||
lane_description_id ==
|
||||
node_based_graph.GetEdgeData(intersection[1].eid).lane_description_id) ||
|
||||
node_based_graph.GetEdgeData(intersection[1].eid).lane_description_id) &&
|
||||
angularDeviation(intersection[1].angle, STRAIGHT_ANGLE) < FUZZY_ANGLE_DIFFERENCE));
|
||||
|
||||
if (is_going_straight_and_turns_continue)
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "osrm/osrm.hpp"
|
||||
#include "osrm/status.hpp"
|
||||
|
||||
#include "util/typedefs.hpp"
|
||||
#include "util/vector_tile.hpp"
|
||||
|
||||
#include <protozero/pbf_reader.hpp>
|
||||
@ -20,23 +21,38 @@
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(tile)
|
||||
|
||||
template <typename algorithm> void test_tile(algorithm &osrm)
|
||||
void validate_value(protozero::pbf_reader value)
|
||||
{
|
||||
using namespace osrm;
|
||||
while (value.next())
|
||||
{
|
||||
switch (value.tag())
|
||||
{
|
||||
case util::vector_tile::VARIANT_TYPE_BOOL:
|
||||
value.get_bool();
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TYPE_DOUBLE:
|
||||
value.get_double();
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TYPE_FLOAT:
|
||||
value.get_float();
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TYPE_STRING:
|
||||
value.get_string();
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TYPE_UINT64:
|
||||
value.get_uint64();
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TYPE_SINT64:
|
||||
value.get_sint64();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This tile should contain most of monaco
|
||||
TileParameters params{17059, 11948, 15};
|
||||
|
||||
std::string result;
|
||||
const auto rc = osrm.Tile(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
BOOST_CHECK(result.size() > 114000);
|
||||
|
||||
protozero::pbf_reader tile_message(result);
|
||||
tile_message.next();
|
||||
BOOST_CHECK_EQUAL(tile_message.tag(), util::vector_tile::LAYER_TAG); // must be a layer
|
||||
protozero::pbf_reader layer_message = tile_message.get_message();
|
||||
void validate_feature_layer(protozero::pbf_reader &layer_message)
|
||||
{
|
||||
using namespace osrm;
|
||||
|
||||
const auto check_feature = [](protozero::pbf_reader feature_message) {
|
||||
feature_message.next(); // advance parser to first entry
|
||||
@ -81,33 +97,6 @@ template <typename algorithm> void test_tile(algorithm &osrm)
|
||||
BOOST_CHECK_GT(std::distance(geometry_iter_pair.begin(), geometry_iter_pair.end()), 1);
|
||||
};
|
||||
|
||||
const auto check_value = [](protozero::pbf_reader value) {
|
||||
while (value.next())
|
||||
{
|
||||
switch (value.tag())
|
||||
{
|
||||
case util::vector_tile::VARIANT_TYPE_BOOL:
|
||||
value.get_bool();
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TYPE_DOUBLE:
|
||||
value.get_double();
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TYPE_FLOAT:
|
||||
value.get_float();
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TYPE_STRING:
|
||||
value.get_string();
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TYPE_UINT64:
|
||||
value.get_uint64();
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TYPE_SINT64:
|
||||
value.get_sint64();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
auto number_of_speed_keys = 0u;
|
||||
auto number_of_speed_values = 0u;
|
||||
|
||||
@ -132,7 +121,7 @@ template <typename algorithm> void test_tile(algorithm &osrm)
|
||||
number_of_speed_keys++;
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TAG:
|
||||
check_value(layer_message.get_message());
|
||||
validate_value(layer_message.get_message());
|
||||
number_of_speed_values++;
|
||||
break;
|
||||
default:
|
||||
@ -143,9 +132,11 @@ template <typename algorithm> void test_tile(algorithm &osrm)
|
||||
|
||||
BOOST_CHECK_EQUAL(number_of_speed_keys, 7);
|
||||
BOOST_CHECK_GT(number_of_speed_values, 128); // speed value resolution
|
||||
}
|
||||
|
||||
tile_message.next();
|
||||
layer_message = tile_message.get_message();
|
||||
void validate_turn_layer(protozero::pbf_reader &layer_message)
|
||||
{
|
||||
using namespace osrm;
|
||||
|
||||
const auto check_turn_feature = [](protozero::pbf_reader feature_message) {
|
||||
feature_message.next(); // advance parser to first entry
|
||||
@ -202,7 +193,7 @@ template <typename algorithm> void test_tile(algorithm &osrm)
|
||||
number_of_turn_keys++;
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TAG:
|
||||
check_value(layer_message.get_message());
|
||||
validate_value(layer_message.get_message());
|
||||
break;
|
||||
default:
|
||||
BOOST_CHECK(false); // invalid tag
|
||||
@ -214,11 +205,95 @@ template <typename algorithm> void test_tile(algorithm &osrm)
|
||||
BOOST_CHECK(number_of_turns_found > 700);
|
||||
}
|
||||
|
||||
void validate_node_layer(protozero::pbf_reader &layer_message)
|
||||
{
|
||||
using namespace osrm;
|
||||
auto number_of_nodes_found = 0u;
|
||||
|
||||
const auto check_osmnode_feature = [](protozero::pbf_reader feature_message) {
|
||||
feature_message.next(); // advance parser to first entry
|
||||
BOOST_CHECK_EQUAL(feature_message.tag(), util::vector_tile::GEOMETRY_TAG);
|
||||
BOOST_CHECK_EQUAL(feature_message.get_enum(), util::vector_tile::GEOMETRY_TYPE_POINT);
|
||||
|
||||
feature_message.next(); // advance to next entry
|
||||
BOOST_CHECK_EQUAL(feature_message.tag(), util::vector_tile::ID_TAG);
|
||||
feature_message.get_uint64(); // id
|
||||
|
||||
feature_message.next(); // advance to next entry
|
||||
// Note - on this layer, there should be no feature attributes, the next thing
|
||||
// we get should be the geometry
|
||||
BOOST_CHECK_EQUAL(feature_message.tag(), util::vector_tile::FEATURE_GEOMETRIES_TAG);
|
||||
auto geometry_iter_pair = feature_message.get_packed_uint32();
|
||||
BOOST_CHECK_GT(std::distance(geometry_iter_pair.begin(), geometry_iter_pair.end()), 1);
|
||||
};
|
||||
|
||||
while (layer_message.next())
|
||||
{
|
||||
switch (layer_message.tag())
|
||||
{
|
||||
case util::vector_tile::VERSION_TAG:
|
||||
BOOST_CHECK_EQUAL(layer_message.get_uint32(), 2);
|
||||
break;
|
||||
case util::vector_tile::NAME_TAG:
|
||||
BOOST_CHECK_EQUAL(layer_message.get_string(), "osmnodes");
|
||||
break;
|
||||
case util::vector_tile::EXTENT_TAG:
|
||||
BOOST_CHECK_EQUAL(layer_message.get_uint32(), util::vector_tile::EXTENT);
|
||||
break;
|
||||
case util::vector_tile::FEATURE_TAG:
|
||||
check_osmnode_feature(layer_message.get_message());
|
||||
number_of_nodes_found++;
|
||||
break;
|
||||
case util::vector_tile::KEY_TAG:
|
||||
BOOST_CHECK(false); // There should be no properties on node features
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TAG:
|
||||
BOOST_CHECK(false); // There should be no properties on node features
|
||||
break;
|
||||
default:
|
||||
BOOST_CHECK(false); // invalid tag
|
||||
break;
|
||||
}
|
||||
}
|
||||
BOOST_CHECK_EQUAL(number_of_nodes_found, 1791);
|
||||
}
|
||||
|
||||
void validate_tile(const osrm::OSRM &osrm)
|
||||
{
|
||||
using namespace osrm;
|
||||
|
||||
// This tile should contain most of monaco
|
||||
TileParameters params{17059, 11948, 15};
|
||||
|
||||
std::string result;
|
||||
const auto rc = osrm.Tile(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
BOOST_CHECK(result.size() > 114000);
|
||||
|
||||
protozero::pbf_reader tile_message(result);
|
||||
|
||||
tile_message.next();
|
||||
BOOST_CHECK_EQUAL(tile_message.tag(), util::vector_tile::LAYER_TAG); // must be a layer
|
||||
protozero::pbf_reader layer_message = tile_message.get_message();
|
||||
validate_feature_layer(layer_message);
|
||||
|
||||
tile_message.next();
|
||||
BOOST_CHECK_EQUAL(tile_message.tag(), util::vector_tile::LAYER_TAG); // must be a layer
|
||||
layer_message = tile_message.get_message();
|
||||
validate_turn_layer(layer_message);
|
||||
|
||||
tile_message.next();
|
||||
BOOST_CHECK_EQUAL(tile_message.tag(), util::vector_tile::LAYER_TAG); // must be a layer
|
||||
layer_message = tile_message.get_message();
|
||||
validate_node_layer(layer_message);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_tile_ch)
|
||||
{
|
||||
using namespace osrm;
|
||||
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm", osrm::EngineConfig::Algorithm::CH);
|
||||
test_tile(osrm);
|
||||
validate_tile(osrm);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_tile_corech)
|
||||
@ -226,17 +301,17 @@ BOOST_AUTO_TEST_CASE(test_tile_corech)
|
||||
using namespace osrm;
|
||||
auto osrm =
|
||||
getOSRM(OSRM_TEST_DATA_DIR "/corech/monaco.osrm", osrm::EngineConfig::Algorithm::CoreCH);
|
||||
test_tile(osrm);
|
||||
validate_tile(osrm);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_tile_mld)
|
||||
{
|
||||
using namespace osrm;
|
||||
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/mld/monaco.osrm", osrm::EngineConfig::Algorithm::MLD);
|
||||
test_tile(osrm);
|
||||
validate_tile(osrm);
|
||||
}
|
||||
|
||||
template <typename algorithm> void test_tile_turns(algorithm &osrm)
|
||||
void test_tile_turns(const osrm::OSRM &osrm)
|
||||
{
|
||||
using namespace osrm;
|
||||
|
||||
@ -423,7 +498,7 @@ BOOST_AUTO_TEST_CASE(test_tile_turns_mld)
|
||||
test_tile_turns(osrm);
|
||||
}
|
||||
|
||||
template <typename algorithm> void test_tile_speeds(algorithm &osrm)
|
||||
void test_tile_speeds(const osrm::OSRM &osrm)
|
||||
{
|
||||
using namespace osrm;
|
||||
|
||||
@ -613,4 +688,109 @@ BOOST_AUTO_TEST_CASE(test_tile_speeds_mld)
|
||||
test_tile_speeds(osrm);
|
||||
}
|
||||
|
||||
void test_tile_nodes(const osrm::OSRM &osrm)
|
||||
{
|
||||
using namespace osrm;
|
||||
|
||||
// Small tile so we can test all the values
|
||||
// TileParameters params{272953, 191177, 19};
|
||||
// TileParameters params{136477, 95580, 18};
|
||||
// Small tile where we can test all the values
|
||||
TileParameters params{272953, 191177, 19};
|
||||
|
||||
std::string result;
|
||||
const auto rc = osrm.Tile(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
BOOST_CHECK_GT(result.size(), 128);
|
||||
|
||||
protozero::pbf_reader tile_message(result);
|
||||
tile_message.next();
|
||||
BOOST_CHECK_EQUAL(tile_message.tag(), util::vector_tile::LAYER_TAG); // must be a layer
|
||||
|
||||
// Skip the segments and turns layers
|
||||
tile_message.skip();
|
||||
tile_message.next();
|
||||
tile_message.skip();
|
||||
|
||||
// Get the osmnodes layer
|
||||
tile_message.next();
|
||||
protozero::pbf_reader layer_message = tile_message.get_message();
|
||||
|
||||
std::vector<OSMNodeID::value_type> found_node_ids;
|
||||
|
||||
const auto check_feature = [&](protozero::pbf_reader feature_message) {
|
||||
feature_message.next(); // advance parser to first entry
|
||||
BOOST_CHECK_EQUAL(feature_message.tag(), util::vector_tile::GEOMETRY_TAG);
|
||||
BOOST_CHECK_EQUAL(feature_message.get_enum(), util::vector_tile::GEOMETRY_TYPE_POINT);
|
||||
|
||||
feature_message.next(); // advance to next entry
|
||||
BOOST_CHECK_EQUAL(feature_message.tag(), util::vector_tile::ID_TAG);
|
||||
found_node_ids.push_back(feature_message.get_uint64()); // id
|
||||
|
||||
feature_message.next(); // advance to next entry
|
||||
BOOST_CHECK_EQUAL(feature_message.tag(), util::vector_tile::FEATURE_GEOMETRIES_TAG);
|
||||
auto geometry_iter_pair = feature_message.get_packed_uint32();
|
||||
BOOST_CHECK_GT(std::distance(geometry_iter_pair.begin(), geometry_iter_pair.end()), 1);
|
||||
};
|
||||
|
||||
while (layer_message.next())
|
||||
{
|
||||
switch (layer_message.tag())
|
||||
{
|
||||
case util::vector_tile::VERSION_TAG:
|
||||
BOOST_CHECK_EQUAL(layer_message.get_uint32(), 2);
|
||||
break;
|
||||
case util::vector_tile::NAME_TAG:
|
||||
BOOST_CHECK_EQUAL(layer_message.get_string(), "osmnodes");
|
||||
break;
|
||||
case util::vector_tile::EXTENT_TAG:
|
||||
BOOST_CHECK_EQUAL(layer_message.get_uint32(), util::vector_tile::EXTENT);
|
||||
break;
|
||||
case util::vector_tile::FEATURE_TAG:
|
||||
check_feature(layer_message.get_message());
|
||||
break;
|
||||
case util::vector_tile::KEY_TAG:
|
||||
BOOST_CHECK(false); // There should be no keys
|
||||
break;
|
||||
case util::vector_tile::VARIANT_TAG:
|
||||
BOOST_CHECK(false); // There should be no values
|
||||
break;
|
||||
default:
|
||||
BOOST_CHECK(false); // invalid tag
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(found_node_ids.begin(), found_node_ids.end());
|
||||
const std::vector<OSMNodeID::value_type> expected_node_ids = {
|
||||
25191722, 25191725, 357300400, 1737389138, 1737389140, 2241375220};
|
||||
BOOST_CHECK(found_node_ids == expected_node_ids);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_tile_nodes_ch)
|
||||
{
|
||||
using namespace osrm;
|
||||
|
||||
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm", osrm::EngineConfig::Algorithm::CH);
|
||||
test_tile_nodes(osrm);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_tile_nodes_corech)
|
||||
{
|
||||
using namespace osrm;
|
||||
|
||||
auto osrm =
|
||||
getOSRM(OSRM_TEST_DATA_DIR "/corech/monaco.osrm", osrm::EngineConfig::Algorithm::CoreCH);
|
||||
test_tile_nodes(osrm);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_tile_nodes_mld)
|
||||
{
|
||||
using namespace osrm;
|
||||
|
||||
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/mld/monaco.osrm", osrm::EngineConfig::Algorithm::MLD);
|
||||
test_tile_nodes(osrm);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
Loading…
Reference in New Issue
Block a user