mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
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:
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user