diff --git a/js/id/core/way.js b/js/id/core/way.js index ff7416dc4..530185fc9 100644 --- a/js/id/core/way.js +++ b/js/id/core/way.js @@ -43,11 +43,15 @@ _.extend(iD.Way.prototype, { }, isOneWay: function() { - return this.tags.oneway === 'yes' || - this.tags.oneway === '1' || - this.tags.oneway === '-1' || - this.tags.waterway === 'river' || + // explicit oneway tag.. + if (['yes', '1', '-1'].indexOf(this.tags.oneway) !== -1) { return true; } + if (['no', '0'].indexOf(this.tags.oneway) !== -1) { return false; } + + // implied oneway tag.. + return this.tags.waterway === 'river' || this.tags.waterway === 'stream' || + this.tags.highway === 'motorway' || + this.tags.highway === 'motorway_link' || this.tags.junction === 'roundabout'; }, diff --git a/test/spec/core/way.js b/test/spec/core/way.js index b253638c7..5ff68c431 100644 --- a/test/spec/core/way.js +++ b/test/spec/core/way.js @@ -150,24 +150,31 @@ describe('iD.Way', function() { describe('#isOneWay', function() { it('returns false when the way has no tags', function() { - expect(iD.Way().isOneWay()).to.eql(false); + expect(iD.Way().isOneWay()).to.be.false; }); it('returns false when the way has tag oneway=no', function() { - expect(iD.Way({tags: { oneway: 'no' }}).isOneWay()).to.equal(false); + expect(iD.Way({tags: { oneway: 'no' }}).isOneWay()).to.be.false; + expect(iD.Way({tags: { oneway: '0' }}).isOneWay()).to.be.false; }); it('returns true when the way has tag oneway=yes', function() { - expect(iD.Way({tags: { oneway: 'yes' }}).isOneWay()).to.equal(true); + expect(iD.Way({tags: { oneway: 'yes' }}).isOneWay()).to.be.true; + expect(iD.Way({tags: { oneway: '1' }}).isOneWay()).to.be.true; + expect(iD.Way({tags: { oneway: '-1' }}).isOneWay()).to.be.true; }); - it('returns true when the way has tag waterway=river or waterway=stream', function() { - expect(iD.Way({tags: { waterway: 'river' }}).isOneWay()).to.equal(true); - expect(iD.Way({tags: { waterway: 'stream' }}).isOneWay()).to.equal(true); + it('returns true when the way has implied oneway tag (waterway=river, waterway=stream, etc)', function() { + expect(iD.Way({tags: { waterway: 'river' }}).isOneWay()).to.be.true; + expect(iD.Way({tags: { waterway: 'stream' }}).isOneWay()).to.be.true; + expect(iD.Way({tags: { highway: 'motorway' }}).isOneWay()).to.be.true; + expect(iD.Way({tags: { highway: 'motorway_link' }}).isOneWay()).to.be.true; + expect(iD.Way({tags: { junction: 'roundabout' }}).isOneWay()).to.be.true; }); - it('returns true when the way has tag junction=roundabout', function() { - expect(iD.Way({tags: { junction: 'roundabout' }}).isOneWay()).to.equal(true); + it('returns false when oneway=no overrides implied oneway tag', function() { + expect(iD.Way({tags: { junction: 'roundabout', oneway: 'no' }}).isOneWay()).to.be.false; + expect(iD.Way({tags: { highway: 'motorway', oneway: 'no' }}).isOneWay()).to.be.false; }); });