Add code to treat a few special tags as areas instead of lines

even in the absense of a proper `area=yes` or `areaKeys` tag.
(closes #4194)
This commit is contained in:
Bryan Housel
2017-08-06 23:39:58 -04:00
parent 6c880e5ba3
commit 10659505e2
2 changed files with 30 additions and 0 deletions

View File

@@ -152,6 +152,23 @@ _.extend(osmWay.prototype, {
isArea: function() {
// `highway` and `railway` are typically linear features, but there
// are a few exceptions that should be treated as areas, even in the
// absense of a proper `area=yes` or `areaKeys` tag.. see #4194
var lineKeys = {
highway: {
rest_area: true,
services: true
},
railway: {
roundhouse: true,
station: true,
traverser: true,
turntable: true,
wash: true
}
};
if (this.tags.area === 'yes')
return true;
if (!this.isClosed() || this.tags.area === 'no')
@@ -160,6 +177,9 @@ _.extend(osmWay.prototype, {
if (key in areaKeys && !(this.tags[key] in areaKeys[key])) {
return true;
}
if (key in lineKeys && this.tags[key] in lineKeys[key]) {
return true;
}
}
return false;
},

View File

@@ -345,6 +345,16 @@ describe('iD.osmWay', function() {
expect(iD.Way({nodes: ['n1', 'n1'], tags: {building: 'yes'}}).isArea()).to.equal(true);
});
it('returns true for some highway and railway exceptions', function() {
expect(iD.Way({nodes: ['n1', 'n1'], tags: { highway: 'services' }}).isArea(), 'highway=services').to.equal(true);
expect(iD.Way({nodes: ['n1', 'n1'], tags: { highway: 'rest_area' }}).isArea(), 'highway=rest_area').to.equal(true);
expect(iD.Way({nodes: ['n1', 'n1'], tags: { railway: 'roundhouse' }}).isArea(), 'railway=roundhouse').to.equal(true);
expect(iD.Way({nodes: ['n1', 'n1'], tags: { railway: 'station' }}).isArea(), 'railway=station').to.equal(true);
expect(iD.Way({nodes: ['n1', 'n1'], tags: { railway: 'traverser' }}).isArea(), 'railway=traverser').to.equal(true);
expect(iD.Way({nodes: ['n1', 'n1'], tags: { railway: 'turntable' }}).isArea(), 'railway=turntable').to.equal(true);
expect(iD.Way({nodes: ['n1', 'n1'], tags: { railway: 'wash' }}).isArea(), 'railway=wash').to.equal(true);
});
it('returns false if the way is closed and has no keys in iD.areaKeys', function() {
expect(iD.Way({nodes: ['n1', 'n1'], tags: {a: 'b'}}).isArea()).to.equal(false);
});