From 7fa27217b6f9c5d9df1412f39e90dad0b6571db7 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 23 Feb 2018 11:59:44 -0500 Subject: [PATCH] Return an indirect u-turn restriction for an only restriction --- modules/osm/intersection.js | 2 +- test/spec/osm/intersection.js | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/osm/intersection.js b/modules/osm/intersection.js index 9e4784985..17c42beb2 100644 --- a/modules/osm/intersection.js +++ b/modules/osm/intersection.js @@ -490,7 +490,7 @@ export function osmIntersection(graph, startVertexId, maxDistance) { // an indirect restriction - only include the partial path (starting at FROM) if (matchedRestriction && matchedRestriction.direct === false) { for (i = 0; i < turnPath.length; i++) { - if (i > 0 && turnPath[i] === matchedRestriction.from) { + if (turnPath[i] === matchedRestriction.from) { turnPath = turnPath.slice(i); break; } diff --git a/test/spec/osm/intersection.js b/test/spec/osm/intersection.js index ec2651859..9f287e328 100644 --- a/test/spec/osm/intersection.js +++ b/test/spec/osm/intersection.js @@ -340,7 +340,6 @@ describe('iD.osmIntersection', function() { expect(turns[1].u).to.be.not.ok; expect(turns[1].restrictionID).to.eql('r'); expect(turns[1].direct).to.be.true; - expect(turns[1].indirect).to.be.not.ok; expect(turns[1].only).to.be.not.ok; }); @@ -369,21 +368,21 @@ describe('iD.osmIntersection', function() { expect(turns[0]).to.be.an.instanceOf(iD.osmTurn); expect(turns[0].key).to.eql('=_*_='); expect(turns[0].u).to.be.true; + expect(turns[1].direct).to.be.false; + expect(turns[1].only).to.be.not.ok; expect(turns[1]).to.be.an.instanceOf(iD.osmTurn); expect(turns[1].key).to.eql('=_*_~'); expect(turns[1].restrictionID).to.eql('r'); expect(turns[1].u).to.be.not.ok; - expect(turns[1].direct).to.be.not.ok; - expect(turns[1].indirect).to.be.true; + expect(turns[1].direct).to.be.false; expect(turns[1].only).to.be.not.ok; expect(turns[2]).to.be.an.instanceOf(iD.osmTurn); expect(turns[2].key).to.eql('=_*_-'); expect(turns[2].restrictionID).to.eql('r'); expect(turns[2].u).to.be.not.ok; - expect(turns[2].direct).to.be.not.ok; - expect(turns[2].indirect).to.be.not.ok; + expect(turns[2].direct).to.be.true; expect(turns[2].only).to.be.true; });