Add test for route relation process in car.lua. Some fixes
This commit is contained in:
committed by
Patrick Niklaus
parent
a05e9c4932
commit
3634aa9a3c
+6
-2
@@ -401,10 +401,14 @@ function process_way(profile, way, result, relations)
|
||||
-- now process relations data
|
||||
local matched_refs = nil;
|
||||
if result.ref then
|
||||
matched_refs = Relations.MatchToRef(relations, result.ref)
|
||||
local match_res = Relations.match_to_ref(relations, result.ref)
|
||||
|
||||
order = match_res['order']
|
||||
matched_refs = match_res['match']
|
||||
|
||||
local ref = ''
|
||||
for k, v in pairs(matched_refs) do
|
||||
for _, k in pairs(order) do
|
||||
local v = matched_refs[k]
|
||||
if ref ~= '' then
|
||||
ref = ref .. '; '
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ function Relations.Merge(relations)
|
||||
end
|
||||
|
||||
-- match ref values to relations data
|
||||
function Relations.MatchToRef(relations, ref)
|
||||
function Relations.match_to_ref(relations, ref)
|
||||
|
||||
function calculate_scores(refs, tag_value)
|
||||
local tag_tokens = Set(Utils.tokenize_common(tag_value))
|
||||
@@ -47,12 +47,13 @@ function Relations.MatchToRef(relations, ref)
|
||||
|
||||
local references = Utils.string_list_tokens(ref)
|
||||
local result_match = {}
|
||||
|
||||
for _, r in ipairs(references) do
|
||||
local order = {}
|
||||
for i, r in ipairs(references) do
|
||||
result_match[r] = false
|
||||
order[i] = r
|
||||
end
|
||||
|
||||
for _, rel in ipairs(relations) do
|
||||
for i, rel in ipairs(relations) do
|
||||
local name_scores = nil
|
||||
local name_tokens = {}
|
||||
local route_name = rel["route_name"]
|
||||
@@ -94,7 +95,11 @@ function Relations.MatchToRef(relations, ref)
|
||||
|
||||
end
|
||||
|
||||
return result_match
|
||||
local result = {}
|
||||
result['order'] = order
|
||||
result['match'] = result_match
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
return Relations
|
||||
@@ -13,7 +13,7 @@ function Utils.string_list_tokens(str)
|
||||
for s in str.gmatch(str, "([^;]*)") do
|
||||
if s ~= nil and s ~= '' then
|
||||
idx = idx + 1
|
||||
table.insert(result, idx, (s:gsub("^%s*(.-)%s*$", "%1")))
|
||||
result[idx] = s:gsub("^%s*(.-)%s*$", "%1")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,7 +28,7 @@ function Utils.tokenize_common(str)
|
||||
for s in str.gmatch(str, "%S+") do
|
||||
if s ~= nil and s ~= '' then
|
||||
idx = idx + 1
|
||||
table.insert(result, idx, (s:gsub("^%s*(.-)%s*$", "%1")))
|
||||
result[idx] = s:gsub("^%s*(.-)%s*$", "%1")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user