Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 851ae2ce4f | |||
| 577801ad38 | |||
| 7a86b7985f | |||
| 41551119f2 | |||
| 521636c854 | |||
| 6172dffd35 | |||
| 57099e4a85 | |||
| 6be468bdb4 |
+3
-2
@@ -1,10 +1,11 @@
|
|||||||
# 5.13.0 RC2
|
# 5.13.0
|
||||||
- Changes from 5.12:
|
- Changes from 5.12:
|
||||||
- Profile:
|
- Profile:
|
||||||
- Append cardinal directions from route relations to ref fields to improve instructions
|
- Append cardinal directions from route relations to ref fields to improve instructions; off by default see `profile.cardinal_directions`
|
||||||
- Support of `distance` weight in foot and bicycle profiles
|
- Support of `distance` weight in foot and bicycle profiles
|
||||||
- Support of relations processing
|
- Support of relations processing
|
||||||
- Added `way:get_location_tag(key)` method to get location-dependent tags https://github.com/Project-OSRM/osrm-backend/wiki/Using-location-dependent-data-in-profiles
|
- Added `way:get_location_tag(key)` method to get location-dependent tags https://github.com/Project-OSRM/osrm-backend/wiki/Using-location-dependent-data-in-profiles
|
||||||
|
- Added `forward_ref` and `backward_ref` support
|
||||||
- Left-side driving mode is specified by a local Boolean flag `is_left_hand_driving` in `ExtractionWay` and `ExtractionTurn`
|
- Left-side driving mode is specified by a local Boolean flag `is_left_hand_driving` in `ExtractionWay` and `ExtractionTurn`
|
||||||
- Support literal values for maxspeeds in NO, PL and ZA
|
- Support literal values for maxspeeds in NO, PL and ZA
|
||||||
- Infrastructure:
|
- Infrastructure:
|
||||||
|
|||||||
+3
-1
@@ -171,7 +171,9 @@ is_startpoint | Boolean | Can a journey start on this
|
|||||||
roundabout | Boolean | Is this part of a roundabout?
|
roundabout | Boolean | Is this part of a roundabout?
|
||||||
circular | Boolean | Is this part of a non-roundabout circular junction?
|
circular | Boolean | Is this part of a non-roundabout circular junction?
|
||||||
name | String | Name of the way
|
name | String | Name of the way
|
||||||
ref | String | Road number
|
ref | String | Road number (equal to set `forward_ref` and `backward_ref` with one value)
|
||||||
|
forward_ref | String | Road number in forward way direction
|
||||||
|
backward_ref | String | Road number in backward way direction
|
||||||
destinations | String | The road's destinations
|
destinations | String | The road's destinations
|
||||||
exits | String | The ramp's exit numbers or names
|
exits | String | The ramp's exit numbers or names
|
||||||
pronunciation | String | Name pronunciation
|
pronunciation | String | Name pronunciation
|
||||||
|
|||||||
@@ -157,15 +157,16 @@ Feature: Car - Restricted access
|
|||||||
|
|
||||||
Scenario: Car - Access combinations
|
Scenario: Car - Access combinations
|
||||||
Then routability should be
|
Then routability should be
|
||||||
| highway | access | vehicle | motor_vehicle | motorcar | forw | backw | # |
|
| highway | access | vehicle | motor_vehicle | motorcar | forw | backw | # |
|
||||||
| runway | private | | | permissive | x | x | |
|
| runway | private | | | permissive | x | x | |
|
||||||
| primary | forestry | | yes | | x | x | |
|
| primary | forestry | | yes | | x | x | |
|
||||||
| cycleway | | | designated | | x | x | |
|
| cycleway | | | designated | | x | x | |
|
||||||
| residential | | yes | no | | | | |
|
| unclassified | | | destination | destination | x | x | |
|
||||||
| motorway | yes | permissive | | private | x | | implied oneway |
|
| residential | | yes | no | | | | |
|
||||||
| trunk | agricultural | designated | permissive | no | | | |
|
| motorway | yes | permissive | | private | x | | implied oneway |
|
||||||
| pedestrian | | | | | | | |
|
| trunk | agricultural | designated | permissive | no | | | |
|
||||||
| pedestrian | | | | destination | | | temporary disabled #3773 |
|
| pedestrian | | | | | | | |
|
||||||
|
| pedestrian | | | | destination | | | temporary disabled #3773 |
|
||||||
|
|
||||||
Scenario: Car - Ignore access tags for other modes
|
Scenario: Car - Ignore access tags for other modes
|
||||||
Then routability should be
|
Then routability should be
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ Feature: Car - route relations
|
|||||||
Given the profile "car"
|
Given the profile "car"
|
||||||
|
|
||||||
Scenario: Assignment using relation membership roles
|
Scenario: Assignment using relation membership roles
|
||||||
|
Given the profile file "car" initialized with
|
||||||
|
"""
|
||||||
|
profile.cardinal_directions = true
|
||||||
|
"""
|
||||||
|
|
||||||
Given the node map
|
Given the node map
|
||||||
"""
|
"""
|
||||||
a----------------b
|
a----------------b
|
||||||
@@ -26,7 +31,63 @@ Feature: Car - route relations
|
|||||||
| b,a | westbound,westbound | I 80 $west,I 80 $west |
|
| b,a | westbound,westbound | I 80 $west,I 80 $west |
|
||||||
| c,d | eastbound,eastbound | I 80 $east; CO 93 $east,I 80 $east; CO 93 $east |
|
| c,d | eastbound,eastbound | I 80 $east; CO 93 $east,I 80 $east; CO 93 $east |
|
||||||
|
|
||||||
|
Scenario: No cardinal directions by default
|
||||||
|
Given the profile file "car" initialized with
|
||||||
|
"""
|
||||||
|
profile.cardinal_directions = false
|
||||||
|
"""
|
||||||
|
Given the node map
|
||||||
|
"""
|
||||||
|
a----------------b
|
||||||
|
c----------------d
|
||||||
|
"""
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | name | highway | ref |
|
||||||
|
| ba | westbound | motorway | I 80 |
|
||||||
|
| cd | eastbound | motorway | I 80;CO 93 |
|
||||||
|
|
||||||
|
And the relations
|
||||||
|
| type | way:east | way:west | route | ref | network |
|
||||||
|
| route | cd | ba | road | 80 | US:I |
|
||||||
|
| route | cd | ba | road | 93 | US:CO |
|
||||||
|
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | ref |
|
||||||
|
| b,a | westbound,westbound | I 80,I 80 |
|
||||||
|
| c,d | eastbound,eastbound | I 80; CO 93,I 80; CO 93 |
|
||||||
|
|
||||||
|
Scenario: No cardinal directions by default
|
||||||
|
Given the node map
|
||||||
|
"""
|
||||||
|
a----------------b
|
||||||
|
c----------------d
|
||||||
|
"""
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | name | highway | ref |
|
||||||
|
| ba | westbound | motorway | I 80 |
|
||||||
|
| cd | eastbound | motorway | I 80;CO 93 |
|
||||||
|
|
||||||
|
And the relations
|
||||||
|
| type | way:east | way:west | route | ref | network |
|
||||||
|
| route | cd | ba | road | 80 | US:I |
|
||||||
|
| route | cd | ba | road | 93 | US:CO |
|
||||||
|
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | ref |
|
||||||
|
| b,a | westbound,westbound | I 80,I 80 |
|
||||||
|
| c,d | eastbound,eastbound | I 80; CO 93,I 80; CO 93 |
|
||||||
|
|
||||||
|
|
||||||
Scenario: Assignment using relation direction property (no role on members)
|
Scenario: Assignment using relation direction property (no role on members)
|
||||||
|
Given the profile file "car" initialized with
|
||||||
|
"""
|
||||||
|
profile.cardinal_directions = true
|
||||||
|
"""
|
||||||
|
|
||||||
Given the node map
|
Given the node map
|
||||||
"""
|
"""
|
||||||
a----------------b
|
a----------------b
|
||||||
@@ -51,6 +112,11 @@ Feature: Car - route relations
|
|||||||
|
|
||||||
|
|
||||||
Scenario: Forward assignment on one-way roads using relation direction property
|
Scenario: Forward assignment on one-way roads using relation direction property
|
||||||
|
Given the profile file "car" initialized with
|
||||||
|
"""
|
||||||
|
profile.cardinal_directions = true
|
||||||
|
"""
|
||||||
|
|
||||||
Given the node map
|
Given the node map
|
||||||
"""
|
"""
|
||||||
a----------------b
|
a----------------b
|
||||||
@@ -74,31 +140,41 @@ Feature: Car - route relations
|
|||||||
| c,d | eastbound,eastbound | I 80 $east; CO 93 $east,I 80 $east; CO 93 $east |
|
| c,d | eastbound,eastbound | I 80 $east; CO 93 $east,I 80 $east; CO 93 $east |
|
||||||
|
|
||||||
|
|
||||||
# Scenario: Forward/backward assignment on non-divided roads with role direction tag
|
Scenario: Forward/backward assignment on non-divided roads with role direction tag
|
||||||
# Given the node map
|
Given the profile file "car" initialized with
|
||||||
# """
|
"""
|
||||||
# a----------------b
|
profile.cardinal_directions = true
|
||||||
# """
|
"""
|
||||||
#
|
|
||||||
# And the ways
|
Given the node map
|
||||||
# | nodes | name | highway | ref | oneway |
|
"""
|
||||||
# | ab | mainroad | motorway | I 80 | no |
|
a----------------b
|
||||||
#
|
"""
|
||||||
# And the relations
|
|
||||||
# | type | direction | way:forward | route | ref | network |
|
And the ways
|
||||||
# | route | west | ab | road | 80 | US:I |
|
| nodes | name | highway | ref | oneway |
|
||||||
#
|
| ab | mainroad | motorway | I 80 | no |
|
||||||
# And the relations
|
|
||||||
# | type | direction | way:backward | route | ref | network |
|
And the relations
|
||||||
# | route | east | ab | road | 80 | US:I |
|
| type | direction | way:forward | route | ref | network |
|
||||||
#
|
| route | west | ab | road | 80 | US:I |
|
||||||
# When I route I should get
|
|
||||||
# | waypoints | route | ref |
|
And the relations
|
||||||
# | b,a | mainroad,mainroad | I 80 $west,I 80 $west |
|
| type | direction | way:backward | route | ref | network |
|
||||||
# | a,b | mainroad,mainroad | I 80 $east,I 80 $east |
|
| route | east | ab | road | 80 | US:I |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | ref |
|
||||||
|
| a,b | mainroad,mainroad | I 80 $west,I 80 $west |
|
||||||
|
| b,a | mainroad,mainroad | I 80 $east,I 80 $east |
|
||||||
|
|
||||||
|
|
||||||
Scenario: Conflict between role and direction
|
Scenario: Conflict between role and direction
|
||||||
|
Given the profile file "car" initialized with
|
||||||
|
"""
|
||||||
|
profile.cardinal_directions = true
|
||||||
|
"""
|
||||||
|
|
||||||
Given the node map
|
Given the node map
|
||||||
"""
|
"""
|
||||||
a----------------b
|
a----------------b
|
||||||
@@ -118,6 +194,11 @@ Feature: Car - route relations
|
|||||||
|
|
||||||
|
|
||||||
Scenario: Conflict between role and superrelation direction
|
Scenario: Conflict between role and superrelation direction
|
||||||
|
Given the profile file "car" initialized with
|
||||||
|
"""
|
||||||
|
profile.cardinal_directions = true
|
||||||
|
"""
|
||||||
|
|
||||||
Given the node map
|
Given the node map
|
||||||
"""
|
"""
|
||||||
a----------------b
|
a----------------b
|
||||||
@@ -140,6 +221,11 @@ Feature: Car - route relations
|
|||||||
| a,b | eastbound,eastbound | I 80,I 80 |
|
| a,b | eastbound,eastbound | I 80,I 80 |
|
||||||
|
|
||||||
Scenario: Conflict between role and superrelation role
|
Scenario: Conflict between role and superrelation role
|
||||||
|
Given the profile file "car" initialized with
|
||||||
|
"""
|
||||||
|
profile.cardinal_directions = true
|
||||||
|
"""
|
||||||
|
|
||||||
Given the node map
|
Given the node map
|
||||||
"""
|
"""
|
||||||
a----------------b
|
a----------------b
|
||||||
@@ -162,6 +248,11 @@ Feature: Car - route relations
|
|||||||
| a,b | eastbound,eastbound | I 80,I 80 |
|
| a,b | eastbound,eastbound | I 80,I 80 |
|
||||||
|
|
||||||
Scenario: Direction only available via superrelation role
|
Scenario: Direction only available via superrelation role
|
||||||
|
Given the profile file "car" initialized with
|
||||||
|
"""
|
||||||
|
profile.cardinal_directions = true
|
||||||
|
"""
|
||||||
|
|
||||||
Given the node map
|
Given the node map
|
||||||
"""
|
"""
|
||||||
a----------------b
|
a----------------b
|
||||||
@@ -184,6 +275,11 @@ Feature: Car - route relations
|
|||||||
| a,b | eastbound,eastbound | I 80 $east,I 80 $east |
|
| a,b | eastbound,eastbound | I 80 $east,I 80 $east |
|
||||||
|
|
||||||
Scenario: Direction only available via superrelation direction
|
Scenario: Direction only available via superrelation direction
|
||||||
|
Given the profile file "car" initialized with
|
||||||
|
"""
|
||||||
|
profile.cardinal_directions = true
|
||||||
|
"""
|
||||||
|
|
||||||
Given the node map
|
Given the node map
|
||||||
"""
|
"""
|
||||||
a----------------b
|
a----------------b
|
||||||
@@ -205,6 +301,7 @@ Feature: Car - route relations
|
|||||||
| waypoints | route | ref |
|
| waypoints | route | ref |
|
||||||
| a,b | eastbound,eastbound | I 80 $east,I 80 $east |
|
| a,b | eastbound,eastbound | I 80 $east,I 80 $east |
|
||||||
|
|
||||||
|
|
||||||
# Scenario: Three levels of indirection
|
# Scenario: Three levels of indirection
|
||||||
# Given the node map
|
# Given the node map
|
||||||
# """
|
# """
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ inline auto contractExcludableGraph(ContractorGraph contractor_graph_,
|
|||||||
auto filtered_core_graph =
|
auto filtered_core_graph =
|
||||||
shared_core_graph.Filter([&filter](const NodeID node) { return filter[node]; });
|
shared_core_graph.Filter([&filter](const NodeID node) { return filter[node]; });
|
||||||
|
|
||||||
|
contractGraph(filtered_core_graph, is_shared_core, is_shared_core, node_weights);
|
||||||
|
|
||||||
edge_container.Merge(toEdges<QueryEdge>(std::move(filtered_core_graph)));
|
edge_container.Merge(toEdges<QueryEdge>(std::move(filtered_core_graph)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ struct ExtractionWay
|
|||||||
duration = -1;
|
duration = -1;
|
||||||
weight = -1;
|
weight = -1;
|
||||||
name.clear();
|
name.clear();
|
||||||
ref.clear();
|
forward_ref.clear();
|
||||||
|
backward_ref.clear();
|
||||||
pronunciation.clear();
|
pronunciation.clear();
|
||||||
destinations.clear();
|
destinations.clear();
|
||||||
exits.clear();
|
exits.clear();
|
||||||
@@ -67,8 +68,10 @@ struct ExtractionWay
|
|||||||
// wrappers to allow assigning nil (nullptr) to string values
|
// wrappers to allow assigning nil (nullptr) to string values
|
||||||
void SetName(const char *value) { detail::maybeSetString(name, value); }
|
void SetName(const char *value) { detail::maybeSetString(name, value); }
|
||||||
const char *GetName() const { return name.c_str(); }
|
const char *GetName() const { return name.c_str(); }
|
||||||
void SetRef(const char *value) { detail::maybeSetString(ref, value); }
|
void SetForwardRef(const char *value) { detail::maybeSetString(forward_ref, value); }
|
||||||
const char *GetRef() const { return ref.c_str(); }
|
const char *GetForwardRef() const { return forward_ref.c_str(); }
|
||||||
|
void SetBackwardRef(const char *value) { detail::maybeSetString(backward_ref, value); }
|
||||||
|
const char *GetBackwardRef() const { return backward_ref.c_str(); }
|
||||||
void SetDestinations(const char *value) { detail::maybeSetString(destinations, value); }
|
void SetDestinations(const char *value) { detail::maybeSetString(destinations, value); }
|
||||||
const char *GetDestinations() const { return destinations.c_str(); }
|
const char *GetDestinations() const { return destinations.c_str(); }
|
||||||
void SetExits(const char *value) { detail::maybeSetString(exits, value); }
|
void SetExits(const char *value) { detail::maybeSetString(exits, value); }
|
||||||
@@ -101,7 +104,8 @@ struct ExtractionWay
|
|||||||
// weight of the whole way in both directions
|
// weight of the whole way in both directions
|
||||||
double weight;
|
double weight;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string ref;
|
std::string forward_ref;
|
||||||
|
std::string backward_ref;
|
||||||
std::string pronunciation;
|
std::string pronunciation;
|
||||||
std::string destinations;
|
std::string destinations;
|
||||||
std::string exits;
|
std::string exits;
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ class ExtractorCallbacks
|
|||||||
// actually maps to name ids
|
// actually maps to name ids
|
||||||
using MapKey = std::tuple<std::string, std::string, std::string, std::string, std::string>;
|
using MapKey = std::tuple<std::string, std::string, std::string, std::string, std::string>;
|
||||||
using MapVal = unsigned;
|
using MapVal = unsigned;
|
||||||
std::unordered_map<MapKey, MapVal> string_map;
|
using StringMap = std::unordered_map<MapKey, MapVal>;
|
||||||
|
StringMap string_map;
|
||||||
ExtractionContainers &external_memory;
|
ExtractionContainers &external_memory;
|
||||||
std::unordered_map<std::string, ClassData> &classes_map;
|
std::unordered_map<std::string, ClassData> &classes_map;
|
||||||
guidance::LaneDescriptionMap &lane_description_map;
|
guidance::LaneDescriptionMap &lane_description_map;
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "osrm",
|
"name": "osrm",
|
||||||
"version": "5.13.0-rc.2",
|
"version": "5.13.0",
|
||||||
"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": {
|
||||||
|
|||||||
+4
-28
@@ -35,6 +35,7 @@ function setup()
|
|||||||
turn_penalty = 7.5,
|
turn_penalty = 7.5,
|
||||||
speed_reduction = 0.8,
|
speed_reduction = 0.8,
|
||||||
turn_bias = 1.075,
|
turn_bias = 1.075,
|
||||||
|
cardinal_directions = false,
|
||||||
|
|
||||||
-- a list of suffixes to suppress in name change instructions. The suffixes also include common substrings of each other
|
-- a list of suffixes to suppress in name change instructions. The suffixes also include common substrings of each other
|
||||||
suffix_list = {
|
suffix_list = {
|
||||||
@@ -161,6 +162,7 @@ function setup()
|
|||||||
'tertiary_link',
|
'tertiary_link',
|
||||||
'residential',
|
'residential',
|
||||||
'living_street',
|
'living_street',
|
||||||
|
'unclassified'
|
||||||
},
|
},
|
||||||
|
|
||||||
construction_whitelist = Set {
|
construction_whitelist = Set {
|
||||||
@@ -402,34 +404,8 @@ function process_way(profile, way, result, relations)
|
|||||||
|
|
||||||
WayHandlers.run(profile, way, result, data, handlers, relations)
|
WayHandlers.run(profile, way, result, data, handlers, relations)
|
||||||
|
|
||||||
local parsed_rel_list = {}
|
if profile.cardinal_directions then
|
||||||
local rel_id_list = relations:get_relations(way)
|
Relations.process_way_refs(way, relations, result)
|
||||||
for i, rel_id in ipairs(rel_id_list) do
|
|
||||||
local rel = relations:relation(rel_id)
|
|
||||||
parsed_rel_list[i] = Relations.parse_route_relation(rel, way, relations)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- now process relations data
|
|
||||||
local matched_refs = nil;
|
|
||||||
if result.ref then
|
|
||||||
local match_res = Relations.match_to_ref(parsed_rel_list, result.ref)
|
|
||||||
|
|
||||||
local ref = ''
|
|
||||||
for _, m in pairs(match_res) do
|
|
||||||
if ref ~= '' then
|
|
||||||
ref = ref .. '; '
|
|
||||||
end
|
|
||||||
|
|
||||||
if m.dir then
|
|
||||||
ref = ref .. m.ref .. ' $' .. m.dir
|
|
||||||
else
|
|
||||||
ref = ref .. m.ref
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- print(result.name, ref)
|
|
||||||
|
|
||||||
result.ref = ref
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ function Relations.match_to_ref(relations, ref)
|
|||||||
local result_match = {}
|
local result_match = {}
|
||||||
local order = {}
|
local order = {}
|
||||||
for i, r in ipairs(references) do
|
for i, r in ipairs(references) do
|
||||||
result_match[r] = false
|
result_match[r] = { forward = nil, backward = nil }
|
||||||
order[i] = r
|
order[i] = r
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -81,7 +81,19 @@ function Relations.match_to_ref(relations, ref)
|
|||||||
find_best(ref_scores)
|
find_best(ref_scores)
|
||||||
|
|
||||||
if best_ref then
|
if best_ref then
|
||||||
result_match[best_ref] = direction
|
local result_direction = result_match[best_ref]
|
||||||
|
|
||||||
|
local is_forward = rel["route_forward"]
|
||||||
|
if is_forward == nil then
|
||||||
|
result_direction.forward = direction
|
||||||
|
result_direction.backward = direction
|
||||||
|
elseif is_forward == true then
|
||||||
|
result_direction.forward = direction
|
||||||
|
else
|
||||||
|
result_direction.backward = direction
|
||||||
|
end
|
||||||
|
|
||||||
|
result_match[best_ref] = result_direction
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -182,7 +194,6 @@ function Relations.parse_route_relation(rel, way, relations)
|
|||||||
local super_dir = get_direction_from_superrel(rel, relations)
|
local super_dir = get_direction_from_superrel(rel, relations)
|
||||||
|
|
||||||
-- check if there are data error
|
-- check if there are data error
|
||||||
|
|
||||||
if (result_direction ~= nil) and (super_dir ~= nil) and (result_direction ~= super_dir) then
|
if (result_direction ~= nil) and (super_dir ~= nil) and (result_direction ~= super_dir) then
|
||||||
print('ERROR: conflicting relation directions found for way ' .. way:id() ..
|
print('ERROR: conflicting relation directions found for way ' .. way:id() ..
|
||||||
' relation direction is ' .. result_direction .. ' superrelation direction is ' .. super_dir)
|
' relation direction is ' .. result_direction .. ' superrelation direction is ' .. super_dir)
|
||||||
@@ -192,11 +203,59 @@ function Relations.parse_route_relation(rel, way, relations)
|
|||||||
end
|
end
|
||||||
|
|
||||||
result['route_direction'] = result_direction
|
result['route_direction'] = result_direction
|
||||||
|
|
||||||
|
if role == 'forward' then
|
||||||
|
result['route_forward'] = true
|
||||||
|
elseif role == 'backward' then
|
||||||
|
result['route_forward'] = false
|
||||||
|
else
|
||||||
|
result['route_forward'] = nil
|
||||||
|
end
|
||||||
|
|
||||||
add_extra_data(m)
|
add_extra_data(m)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Relations.process_way_refs(way, relations, result)
|
||||||
|
local parsed_rel_list = {}
|
||||||
|
local rel_id_list = relations:get_relations(way)
|
||||||
|
for i, rel_id in ipairs(rel_id_list) do
|
||||||
|
local rel = relations:relation(rel_id)
|
||||||
|
parsed_rel_list[i] = Relations.parse_route_relation(rel, way, relations)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- now process relations data
|
||||||
|
local matched_refs = nil;
|
||||||
|
if result.ref then
|
||||||
|
local match_res = Relations.match_to_ref(parsed_rel_list, result.ref)
|
||||||
|
|
||||||
|
function gen_ref(is_forward)
|
||||||
|
local ref = ''
|
||||||
|
for _, m in pairs(match_res) do
|
||||||
|
if ref ~= '' then
|
||||||
|
ref = ref .. '; '
|
||||||
|
end
|
||||||
|
|
||||||
|
local dir = m.dir.forward
|
||||||
|
if is_forward == false then
|
||||||
|
dir = m.dir.backward
|
||||||
|
end
|
||||||
|
|
||||||
|
if dir then
|
||||||
|
ref = ref .. m.ref .. ' $' .. dir
|
||||||
|
else
|
||||||
|
ref = ref .. m.ref
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return ref
|
||||||
|
end
|
||||||
|
|
||||||
|
result.forward_ref = gen_ref(true)
|
||||||
|
result.backward_ref = gen_ref(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return Relations
|
return Relations
|
||||||
@@ -318,57 +318,64 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
|||||||
road_classification.SetNumberOfLanes(std::max(road_deduced_num_lanes, // len(turn:lanes)
|
road_classification.SetNumberOfLanes(std::max(road_deduced_num_lanes, // len(turn:lanes)
|
||||||
road_classification.GetNumberOfLanes()));
|
road_classification.GetNumberOfLanes()));
|
||||||
|
|
||||||
// Get the unique identifier for the street name, destination, and ref
|
const auto GetNameID = [this, &parsed_way](bool is_forward) -> NameID {
|
||||||
const auto name_iterator = string_map.find(MapKey(parsed_way.name,
|
const std::string &ref = is_forward ? parsed_way.forward_ref : parsed_way.backward_ref;
|
||||||
parsed_way.destinations,
|
// Get the unique identifier for the street name, destination, and ref
|
||||||
parsed_way.ref,
|
const auto name_iterator = string_map.find(MapKey(parsed_way.name,
|
||||||
parsed_way.pronunciation,
|
parsed_way.destinations,
|
||||||
parsed_way.exits));
|
ref,
|
||||||
NameID name_id = EMPTY_NAMEID;
|
parsed_way.pronunciation,
|
||||||
if (string_map.end() == name_iterator)
|
parsed_way.exits));
|
||||||
{
|
|
||||||
// name_offsets has a sentinel element with the total name data size
|
|
||||||
// take the sentinels index as the name id of the new name data pack
|
|
||||||
// (name [name_id], destination [+1], pronunciation [+2], ref [+3], exits [+4])
|
|
||||||
name_id = external_memory.name_offsets.size() - 1;
|
|
||||||
|
|
||||||
std::copy(parsed_way.name.begin(),
|
NameID name_id = EMPTY_NAMEID;
|
||||||
parsed_way.name.end(),
|
if (string_map.end() == name_iterator)
|
||||||
std::back_inserter(external_memory.name_char_data));
|
{
|
||||||
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
|
// name_offsets has a sentinel element with the total name data size
|
||||||
|
// take the sentinels index as the name id of the new name data pack
|
||||||
|
// (name [name_id], destination [+1], pronunciation [+2], ref [+3], exits [+4])
|
||||||
|
name_id = external_memory.name_offsets.size() - 1;
|
||||||
|
|
||||||
std::copy(parsed_way.destinations.begin(),
|
std::copy(parsed_way.name.begin(),
|
||||||
parsed_way.destinations.end(),
|
parsed_way.name.end(),
|
||||||
std::back_inserter(external_memory.name_char_data));
|
std::back_inserter(external_memory.name_char_data));
|
||||||
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
|
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
|
||||||
|
|
||||||
std::copy(parsed_way.pronunciation.begin(),
|
std::copy(parsed_way.destinations.begin(),
|
||||||
parsed_way.pronunciation.end(),
|
parsed_way.destinations.end(),
|
||||||
std::back_inserter(external_memory.name_char_data));
|
std::back_inserter(external_memory.name_char_data));
|
||||||
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
|
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
|
||||||
|
|
||||||
std::copy(parsed_way.ref.begin(),
|
std::copy(parsed_way.pronunciation.begin(),
|
||||||
parsed_way.ref.end(),
|
parsed_way.pronunciation.end(),
|
||||||
std::back_inserter(external_memory.name_char_data));
|
std::back_inserter(external_memory.name_char_data));
|
||||||
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
|
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
|
||||||
|
|
||||||
std::copy(parsed_way.exits.begin(),
|
std::copy(ref.begin(), ref.end(), std::back_inserter(external_memory.name_char_data));
|
||||||
parsed_way.exits.end(),
|
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
|
||||||
std::back_inserter(external_memory.name_char_data));
|
|
||||||
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
|
|
||||||
|
|
||||||
auto k = MapKey{parsed_way.name,
|
std::copy(parsed_way.exits.begin(),
|
||||||
parsed_way.destinations,
|
parsed_way.exits.end(),
|
||||||
parsed_way.ref,
|
std::back_inserter(external_memory.name_char_data));
|
||||||
parsed_way.pronunciation,
|
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
|
||||||
parsed_way.exits};
|
|
||||||
auto v = MapVal{name_id};
|
auto k = MapKey{parsed_way.name,
|
||||||
string_map.emplace(std::move(k), std::move(v));
|
parsed_way.destinations,
|
||||||
}
|
ref,
|
||||||
else
|
parsed_way.pronunciation,
|
||||||
{
|
parsed_way.exits};
|
||||||
name_id = name_iterator->second;
|
auto v = MapVal{name_id};
|
||||||
}
|
string_map.emplace(std::move(k), std::move(v));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name_id = name_iterator->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
const NameID forward_name_id = GetNameID(true);
|
||||||
|
const NameID backward_name_id = GetNameID(false);
|
||||||
|
|
||||||
const bool in_forward_direction =
|
const bool in_forward_direction =
|
||||||
(parsed_way.forward_speed > 0 || parsed_way.forward_rate > 0 || parsed_way.duration > 0 ||
|
(parsed_way.forward_speed > 0 || parsed_way.forward_rate > 0 || parsed_way.duration > 0 ||
|
||||||
@@ -386,12 +393,13 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
|||||||
(force_split_edges || (parsed_way.forward_rate != parsed_way.backward_rate) ||
|
(force_split_edges || (parsed_way.forward_rate != parsed_way.backward_rate) ||
|
||||||
(parsed_way.forward_speed != parsed_way.backward_speed) ||
|
(parsed_way.forward_speed != parsed_way.backward_speed) ||
|
||||||
(parsed_way.forward_travel_mode != parsed_way.backward_travel_mode) ||
|
(parsed_way.forward_travel_mode != parsed_way.backward_travel_mode) ||
|
||||||
(turn_lane_id_forward != turn_lane_id_backward) || (forward_classes != backward_classes));
|
(turn_lane_id_forward != turn_lane_id_backward) || (forward_classes != backward_classes) ||
|
||||||
|
(parsed_way.forward_ref != parsed_way.backward_ref));
|
||||||
|
|
||||||
if (in_forward_direction)
|
if (in_forward_direction)
|
||||||
{ // add (forward) segments or (forward,backward) for non-split edges in backward direction
|
{ // add (forward) segments or (forward,backward) for non-split edges in backward direction
|
||||||
const auto annotation_data_id = external_memory.all_edges_annotation_data_list.size();
|
const auto annotation_data_id = external_memory.all_edges_annotation_data_list.size();
|
||||||
external_memory.all_edges_annotation_data_list.push_back({name_id,
|
external_memory.all_edges_annotation_data_list.push_back({forward_name_id,
|
||||||
turn_lane_id_forward,
|
turn_lane_id_forward,
|
||||||
forward_classes,
|
forward_classes,
|
||||||
parsed_way.forward_travel_mode,
|
parsed_way.forward_travel_mode,
|
||||||
@@ -424,7 +432,7 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
|||||||
if (in_backward_direction && (!in_forward_direction || split_edge))
|
if (in_backward_direction && (!in_forward_direction || split_edge))
|
||||||
{ // add (backward) segments for split edges or not in forward direction
|
{ // add (backward) segments for split edges or not in forward direction
|
||||||
const auto annotation_data_id = external_memory.all_edges_annotation_data_list.size();
|
const auto annotation_data_id = external_memory.all_edges_annotation_data_list.size();
|
||||||
external_memory.all_edges_annotation_data_list.push_back({name_id,
|
external_memory.all_edges_annotation_data_list.push_back({backward_name_id,
|
||||||
turn_lane_id_backward,
|
turn_lane_id_backward,
|
||||||
backward_classes,
|
backward_classes,
|
||||||
parsed_way.backward_travel_mode,
|
parsed_way.backward_travel_mode,
|
||||||
|
|||||||
@@ -369,8 +369,16 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
|||||||
&ExtractionWay::backward_rate,
|
&ExtractionWay::backward_rate,
|
||||||
"name",
|
"name",
|
||||||
sol::property(&ExtractionWay::GetName, &ExtractionWay::SetName),
|
sol::property(&ExtractionWay::GetName, &ExtractionWay::SetName),
|
||||||
"ref",
|
"ref", // backward compatibility
|
||||||
sol::property(&ExtractionWay::GetRef, &ExtractionWay::SetRef),
|
sol::property(&ExtractionWay::GetForwardRef,
|
||||||
|
[](ExtractionWay &way, const char *ref) {
|
||||||
|
way.SetForwardRef(ref);
|
||||||
|
way.SetBackwardRef(ref);
|
||||||
|
}),
|
||||||
|
"forward_ref",
|
||||||
|
sol::property(&ExtractionWay::GetForwardRef, &ExtractionWay::SetForwardRef),
|
||||||
|
"backward_ref",
|
||||||
|
sol::property(&ExtractionWay::GetBackwardRef, &ExtractionWay::SetBackwardRef),
|
||||||
"pronunciation",
|
"pronunciation",
|
||||||
sol::property(&ExtractionWay::GetPronunciation, &ExtractionWay::SetPronunciation),
|
sol::property(&ExtractionWay::GetPronunciation, &ExtractionWay::SetPronunciation),
|
||||||
"destinations",
|
"destinations",
|
||||||
|
|||||||
Reference in New Issue
Block a user