mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-12 16:52:50 +00:00
Don't match a simple from-via-to restriction by taking a longer path
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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' },
|
||||
|
||||
Reference in New Issue
Block a user