Don't match a simple from-via-to restriction by taking a longer path

This commit is contained in:
Bryan Housel
2018-04-11 22:54:49 -04:00
parent 540f0f11dd
commit d20c537e46
2 changed files with 16 additions and 8 deletions

View File

@@ -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"

View File

@@ -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' },