From 097c6bd774c8d8489daf01968ce1b317165313d4 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Thu, 27 Oct 2022 18:34:48 +0200 Subject: [PATCH] skip unsupported/invalid restrictions instead of fallback to "no_*" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #9337 (at least kind of… for a proper solution see #6460) --- CHANGELOG.md | 2 ++ modules/osm/intersection.js | 5 +++++ test/spec/osm/intersection.js | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69feb857b..07d290808 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ _Breaking developer changes, which may affect downstream projects or sites that * Fix selection of best background source when starting on a zoomed-out view ([#9325]) * Fix leaking of localized strings in combo fields when taginfo service is unavailable ([#9342]) * Keep tags when changing presets if the new preset has a field for it ([#9341], [#9104]) +* Skip unsupported/invalid restriction relations instead of assuming they are a "no_*" restriction ([#9337]) #### :rocket: Presets * Support tagging schema v5 ([#9320]): * Add new field type `colour` ([schema-builder#38], [#8782]) @@ -61,6 +62,7 @@ _Breaking developer changes, which may affect downstream projects or sites that [#9294]: https://github.com/openstreetmap/iD/issues/9294 [#9320]: https://github.com/openstreetmap/iD/pull/9320 [#9325]: https://github.com/openstreetmap/iD/issues/9325 +[#9337]: https://github.com/openstreetmap/iD/issues/9337 [#9341]: https://github.com/openstreetmap/iD/issues/9341 [#9342]: https://github.com/openstreetmap/iD/issues/9342 [schema-builder#38]: https://github.com/ideditor/schema-builder/pull/38 diff --git a/modules/osm/intersection.js b/modules/osm/intersection.js index 5b69fbc0b..bdad883b6 100644 --- a/modules/osm/intersection.js +++ b/modules/osm/intersection.js @@ -386,8 +386,13 @@ export function osmIntersection(graph, startVertexId, maxDistance) { var f = restriction.memberByRole('from'); var v = restriction.membersByRole('via'); var t = restriction.memberByRole('to'); + var isNo = /^no_/.test(restriction.tags.restriction); var isOnly = /^only_/.test(restriction.tags.restriction); + if (!(isNo || isOnly)) { + continue; // skip unsupported restriction values + } + // Does the current path match this turn restriction? var matchesFrom = (f.id === fromWayId); var matchesViaTo = false; diff --git a/test/spec/osm/intersection.js b/test/spec/osm/intersection.js index f9eb7d075..2f5d46efe 100644 --- a/test/spec/osm/intersection.js +++ b/test/spec/osm/intersection.js @@ -305,7 +305,7 @@ describe('iD.osmIntersection', function() { expect(turns[0].u).to.be.true; }); - it('restricts turns with a restriction relation', function() { + it('restricts turns with a no_* restriction relation', function() { // u ==== * ---> w var graph = iD.coreGraph([ iD.osmNode({ id: 'u', loc: [0, 0] }), @@ -313,7 +313,7 @@ describe('iD.osmIntersection', function() { iD.osmNode({ id: 'w', loc: [2, 0] }), iD.osmWay({ id: '=', nodes: ['u', '*'], tags: { highway: 'residential' } }), iD.osmWay({ id: '-', nodes: ['*', 'w'], tags: { highway: 'residential' } }), - iD.osmRelation({id: 'r', tags: { type: 'restriction' }, members: [ + iD.osmRelation({id: 'r', tags: { type: 'restriction', restriction: 'no_straight_on' }, members: [ { id: '=', role: 'from', type: 'way' }, { id: '-', role: 'to', type: 'way' }, { id: '*', role: 'via', type: 'node' }