Stricter test for whether a via way restriction matches the path

(closes #4928)
This commit is contained in:
Bryan Housel
2018-03-28 23:47:45 -04:00
parent 05526c1ba6
commit 0d262e5bb5

View File

@@ -1,5 +1,5 @@
import _clone from 'lodash-es/clone';
import _every from 'lodash-es/every';
import _difference from 'lodash-es/difference';
import _extend from 'lodash-es/extend';
import _uniq from 'lodash-es/uniq';
@@ -410,8 +410,18 @@ export function osmIntersection(graph, startVertexId, maxDistance) {
if (t.id === way.id) { // match VIA, TO
if (v.length === 1 && v[0].type === 'node' && v[0].id === entity.id) {
matchesViaTo = true; // match VIA node
} else if (_every(v, function(via) { return currPath.indexOf(via.id) !== -1; })) {
matchesViaTo = true; // match all VIA ways
} else { // match all VIA ways
var pathVias = [];
for (k = 1; k < currPath.length; k++) { // k = 1 skips FROM way
if (currPath[k][0] === 'w') pathVias.push(currPath[k]);
}
var restrictionVias = [];
for (k = 0; k < v.length; k++) {
if (v[k].type === 'way') restrictionVias.push(v[k].id);
}
var diff = _difference(pathVias, restrictionVias);
matchesViaTo = !diff.length;
}
} else if (isOnly) {