Skip to content

Commit 0dfec13

Browse files
deniskoronchikPatrick Niklaus
authored andcommitted
Fix some problems
1 parent a2b8698 commit 0dfec13

File tree

3 files changed

+44
-44
lines changed

3 files changed

+44
-44
lines changed

profiles/car.lua

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -316,48 +316,6 @@ function process_node(profile, node, result, relations)
316316
end
317317
end
318318

319-
function parse_relation(relation, obj)
320-
local t = relation:get_value_by_key("type")
321-
local role = relation:get_role(obj)
322-
local result = {}
323-
324-
function add_extra_data(m)
325-
local name = relation:get_value_by_key("name")
326-
if name then
327-
result['route_name'] = name
328-
end
329-
330-
local ref = relation:get_value_by_key("ref")
331-
if ref then
332-
result['route_ref'] = ref
333-
end
334-
end
335-
336-
if t == 'route' then
337-
local route = relation:get_value_by_key("route")
338-
if route == 'road' then
339-
-- process case, where directions set as role
340-
if role == 'north' or role == 'south' or role == 'west' or role == 'east' then
341-
result['route_direction'] = role
342-
add_extra_data(m)
343-
end
344-
end
345-
346-
local direction = relation:get_value_by_key('direction')
347-
if direction then
348-
direction = string.lower(direction)
349-
if direction == 'north' or direction == 'south' or direction == 'west' or direction == 'east' then
350-
if role == 'forward' then
351-
result['route_direction'] = direction
352-
add_extra_data(m)
353-
end
354-
end
355-
end
356-
end
357-
358-
return result
359-
end
360-
361319
function process_way(profile, way, result, relations)
362320
-- the intial filtering of ways based on presence of tags
363321
-- affects processing times significantly, because all ways
@@ -448,7 +406,7 @@ function process_way(profile, way, result, relations)
448406
local rel_id_list = relations:get_relations(way)
449407
for i, r in ipairs(rel_id_list) do
450408
local rel_id = relations:relation(r)
451-
parsed_rel_list[i] = parse_relation(rel_id, way)
409+
parsed_rel_list[i] = Relations.parse_route_relation(rel_id, way)
452410
end
453411

454412
-- now process relations data

profiles/lib/relations.lua

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,46 @@ function Relations.match_to_ref(relations, ref)
9191
return result
9292
end
9393

94+
function Relations.parse_route_relation(relation, obj)
95+
local t = relation:get_value_by_key("type")
96+
local role = relation:get_role(obj)
97+
local result = {}
98+
99+
function add_extra_data(m)
100+
local name = relation:get_value_by_key("name")
101+
if name then
102+
result['route_name'] = name
103+
end
104+
105+
local ref = relation:get_value_by_key("ref")
106+
if ref then
107+
result['route_ref'] = ref
108+
end
109+
end
110+
111+
if t == 'route' then
112+
local route = relation:get_value_by_key("route")
113+
if route == 'road' then
114+
-- process case, where directions set as role
115+
if role == 'north' or role == 'south' or role == 'west' or role == 'east' then
116+
result['route_direction'] = role
117+
add_extra_data(m)
118+
end
119+
end
120+
121+
local direction = relation:get_value_by_key('direction')
122+
if direction then
123+
direction = string.lower(direction)
124+
if direction == 'north' or direction == 'south' or direction == 'west' or direction == 'east' then
125+
if role == 'forward' then
126+
result['route_direction'] = direction
127+
add_extra_data(m)
128+
end
129+
end
130+
end
131+
end
132+
133+
return result
134+
end
135+
94136
return Relations

unit_tests/mocks/mock_scripting_environment.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class MockScriptingEnvironment : public extractor::ScriptingEnvironment
2929
std::vector<std::string> GetNameSuffixList() override final { return {}; }
3030
std::vector<std::vector<std::string>> GetExcludableClasses() override final { return {}; };
3131
std::vector<std::string> GetClassNames() override { return {}; };
32+
std::vector<std::string> GetRelations() override { return {}; };
3233

3334
std::vector<std::string> GetRestrictions() override final { return {}; }
3435
void ProcessTurn(extractor::ExtractionTurn &) override final {}
@@ -40,7 +41,6 @@ class MockScriptingEnvironment : public extractor::ScriptingEnvironment
4041
const extractor::ExtractionRelationContainer &,
4142
std::vector<std::pair<const osmium::Node &, extractor::ExtractionNode>> &,
4243
std::vector<std::pair<const osmium::Way &, extractor::ExtractionWay>> &,
43-
std::vector<std::pair<const osmium::Relation &, extractor::ExtractionRelation>> &,
4444
std::vector<extractor::InputConditionalTurnRestriction> &) override final
4545
{
4646
}

0 commit comments

Comments
 (0)