mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
iD.Way.isOneWay should return false if oneway=no #2220
i.e. overrides implied oneway tag like `highway=motorway` or `junction=roundabout`
This commit is contained in:
@@ -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';
|
||||
},
|
||||
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user