Skip to content

Commit 832cdbf

Browse files
deniskoronchikPatrick Niklaus
authored andcommitted
Some fixes
1 parent 0dfec13 commit 832cdbf

File tree

3 files changed

+13
-32
lines changed

3 files changed

+13
-32
lines changed

features/options/profiles/version3.feature

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Feature: Profile API version 3
1414
find_access_tag = require("lib/access").find_access_tag
1515
limit = require("lib/maxspeed").limit
1616
17-
1817
function setup()
1918
return {
2019
properties = {
@@ -23,7 +22,8 @@ Feature: Profile API version 3
2322
continue_straight_at_waypoint = true,
2423
weight_name = 'test_version2',
2524
weight_precision = 2
26-
}
25+
},
26+
relation_types = Sequence { "route" }
2727
}
2828
end
2929
@@ -39,30 +39,15 @@ Feature: Profile API version 3
3939
result.forward_speed = 36
4040
result.backward_speed = 36
4141
42-
for _, r in ipairs(relations) do
43-
for k, v in pairs(r) do
44-
print('data_' .. k .. '_value_' .. v)
45-
end
42+
local rel_id_list = relations:get_relations(way)
43+
for i, rel_id in ipairs(rel_id_list) do
44+
local rel = relations:relation(rel_id)
45+
local role = rel:get_role(way)
46+
print('role_' .. role)
4647
end
4748
print ('process_way ' .. way:id() .. ' ' .. result.name)
4849
end
4950
50-
function process_relation(profile, relation, result)
51-
local t = relation:get_value_by_key("type")
52-
if t == "route" then
53-
for _, m in ipairs(relation:members()) do
54-
if m:role() == "north" then
55-
result[m]['direction'] = 'north'
56-
print('direction_north')
57-
end
58-
end
59-
60-
print('route_relation')
61-
end
62-
63-
print ('process_relation ' .. relation:id())
64-
end
65-
6651
function process_turn (profile, turn)
6752
print('process_turn', turn.angle, turn.turn_type, turn.direction_modifier, turn.has_traffic_light)
6853
turn.weight = turn.angle == 0 and 0 or 4.2
@@ -103,14 +88,11 @@ Feature: Profile API version 3
10388

10489
When I run "osrm-extract --profile {profile_file} {osm_file}"
10590
Then it should exit successfully
106-
And stdout should contain "process_relation"
107-
And stdout should contain "route_relation"
108-
And stdout should contain "direction_north"
109-
And stdout should contain "data_direction_value_north"
11091
And stdout should contain "process_node"
11192
And stdout should contain "process_way"
11293
And stdout should contain "process_turn"
11394
And stdout should contain "process_segment"
95+
And stdout should contain "role_north"
11496

11597
When I route I should get
11698
| from | to | route | time |

profiles/car.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,9 @@ function process_way(profile, way, result, relations)
404404

405405
local parsed_rel_list = {}
406406
local rel_id_list = relations:get_relations(way)
407-
for i, r in ipairs(rel_id_list) do
408-
local rel_id = relations:relation(r)
409-
parsed_rel_list[i] = Relations.parse_route_relation(rel_id, way)
407+
for i, rel_id in ipairs(rel_id_list) do
408+
local rel = relations:relation(rel_id)
409+
parsed_rel_list[i] = Relations.parse_route_relation(rel, way)
410410
end
411411

412412
-- now process relations data

src/extractor/extractor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
390390
auto relation_types = scripting_environment.GetRelations();
391391
std::sort(relation_types.begin(), relation_types.end());
392392

393-
ExtractionRelationContainer relations;
394393
std::vector<std::string> restrictions = scripting_environment.GetRestrictions();
395394
// setup restriction parser
396395
const RestrictionParser restriction_parser(
@@ -409,6 +408,8 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
409408
std::vector<InputConditionalTurnRestriction> resulting_restrictions;
410409
};
411410

411+
ExtractionRelationContainer relations;
412+
412413
const auto buffer_reader = [](osmium::io::Reader &reader) {
413414
return tbb::filter_t<void, SharedBuffer>(
414415
tbb::filter::serial_in_order, [&reader](tbb::flow_control &fc) {
@@ -479,8 +480,6 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
479480
}
480481
});
481482

482-
483-
484483
tbb::filter_t<SharedBuffer, std::shared_ptr<ExtractionRelationContainer>> buffer_relation_cache(
485484
tbb::filter::parallel, [&](const SharedBuffer buffer) {
486485
if (!buffer)

0 commit comments

Comments
 (0)