From da23bf79a87a81c41f1333d99f15f422f3844301 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Mon, 3 Sep 2018 12:24:54 +0100 Subject: [PATCH] Fix parsing of error type 294 --- modules/util/keepRight/errorSchema.json | 4 +-- modules/util/keepRight/keepRight_error.js | 33 +++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/modules/util/keepRight/errorSchema.json b/modules/util/keepRight/errorSchema.json index b1005cf3a..d7e951319 100644 --- a/modules/util/keepRight/errorSchema.json +++ b/modules/util/keepRight/errorSchema.json @@ -281,8 +281,8 @@ }, "_294": { "title": "from or to not a way", - "description": "From- and To-members of turn restrictions need to be ways\\. (.+)", - "TODO": "Group can be any combination of to/from: to node #ID | from node #ID | to relation #ID | from relation #ID", + "description": "From- and To-members of turn restrictions need to be ways\\. ((?:(?:from|to) (?:node|relation) #\\d+,?)+)", + "IDs": ["294"], "regex": true }, "_295": { diff --git a/modules/util/keepRight/keepRight_error.js b/modules/util/keepRight/keepRight_error.js index 3e785cf4d..e4fec3955 100644 --- a/modules/util/keepRight/keepRight_error.js +++ b/modules/util/keepRight/keepRight_error.js @@ -111,6 +111,36 @@ export function parseErrorDescriptions(entity) { return newList.join(', '); } + // arbitrary node/relation list of form: from node #ID,to relation #ID,to node #ID... + function parseError294(list) { + var newList = []; + var items = list.split(','); + + items.forEach(function(item) { + var role; + var idType; + var id; + + // item of form "from/to node/relation #ID" + item = item.split(' '); + + // to/from role is more clear in quotes + role = '"' + item[0] + '"'; + + // first letter of node/relation provides the type + idType = item[1].slice(0,1); + + // ID has # at the front + id = item[2].slice(1); + id = fillPlaceholder(idType + id); + + item = [role, item[1], id].join(' '); + newList.push(item); + }); + + return newList.join(', '); + } + if (!(entity instanceof krError)) return; // find the matching template from the error schema @@ -153,6 +183,9 @@ export function parseErrorDescriptions(entity) { break; case '231': group = parseError231(group); + break; + case '294': + group = parseError294(group); } } else if (html_re.test(group)) { // escape any html in non-IDs