diff --git a/modules/osm/intersection.js b/modules/osm/intersection.js index 384961f53..b145c5833 100644 --- a/modules/osm/intersection.js +++ b/modules/osm/intersection.js @@ -407,21 +407,29 @@ export function osmIntersection(graph, startVertexId, maxDistance) { var matchesViaTo = false; var isAlongOnlyPath = false; - if (t.id === way.id) { // match VIA, TO - if (v.length === 1 && v[0].type === 'node') { // match VIA node - matchesViaTo = v[0].id === entity.id; - } else { // match all VIA ways + if (t.id === way.id) { // match TO + + if (v.length === 1 && v[0].type === 'node') { // match VIA node + matchesViaTo = (v[0].id === entity.id && ( + (matchesFrom && currPath.length === 2) || + (!matchesFrom && currPath.length > 2) + )); + + } else { // match all VIA ways var pathVias = []; - for (k = 2; k < currPath.length; k+=2) { // k = 1 skips FROM way - pathVias.push(currPath[k]); + for (k = 2; k < currPath.length; k +=2 ) { // k = 2 skips FROM + pathVias.push(currPath[k]); // (path goes way-node-way...) } var restrictionVias = []; for (k = 0; k < v.length; k++) { - restrictionVias.push(v[k].id); + if (v[k].type === 'way') { + restrictionVias.push(v[k].id); + } } var diff = _difference(pathVias, restrictionVias); matchesViaTo = !diff.length; } + } else if (isOnly) { for (k = 0; k < v.length; k++) { // way doesn't match TO, but is one of the via ways along the path of an "only" diff --git a/test/spec/osm/intersection.js b/test/spec/osm/intersection.js index 3b18f397f..ecb23a265 100644 --- a/test/spec/osm/intersection.js +++ b/test/spec/osm/intersection.js @@ -1456,7 +1456,7 @@ describe('iD.osmIntersection', function() { expect(turns[9].u).to.be.not.ok; }); - it('matches from-via-to strictly when alternate paths exist between from and to', function() { + it('matches from-via-to strictly when alternate paths exist between from-via-to', function() { var r1 = iD.osmRelation({ id: 'r1', tags: { type: 'restriction', restriction: 'no_straight_on' },