mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-21 07:46:58 +02:00
Refine Way#isArea
Closed ways that are multipolygon inners shouldn't be rendered as areas just because they have a source=* tag, for example.
This commit is contained in:
+12
-6
@@ -47,12 +47,14 @@ _.extend(iD.Way.prototype, {
|
||||
// - doesn't have area=no
|
||||
// - doesn't have highway tag
|
||||
isArea: function() {
|
||||
return this.tags.area === 'yes' ||
|
||||
(this.isClosed() &&
|
||||
!_.isEmpty(this.tags) &&
|
||||
this.tags.area !== 'no' &&
|
||||
!this.tags.highway &&
|
||||
!this.tags.barrier);
|
||||
if (this.tags.area === 'yes')
|
||||
return true;
|
||||
if (!this.isClosed() || this.tags.area === 'no')
|
||||
return false;
|
||||
for (var key in this.tags)
|
||||
if (key in iD.Way.areaKeys)
|
||||
return true;
|
||||
return false;
|
||||
},
|
||||
|
||||
isDegenerate: function() {
|
||||
@@ -138,3 +140,7 @@ _.extend(iD.Way.prototype, {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
iD.Way.areaKeys = iD.util.trueObj(['area', 'building', 'leisure', 'tourism', 'ruins',
|
||||
'historic', 'landuse', 'military', 'natural', 'amenity', 'shop', 'man_made',
|
||||
'public_transport']);
|
||||
|
||||
@@ -99,16 +99,16 @@ describe('iD.Way', function() {
|
||||
expect(iD.Way({nodes: ['n1', 'n1']}).isArea()).to.equal(false);
|
||||
});
|
||||
|
||||
it('returns true if the way is closed and has tags', function() {
|
||||
expect(iD.Way({nodes: ['n1', 'n1'], tags: {a: 'b'}}).isArea()).to.equal(true);
|
||||
it('returns true if the way is closed and has a key in iD.Way.areaKeys', function() {
|
||||
expect(iD.Way({nodes: ['n1', 'n1'], tags: {building: 'yes'}}).isArea()).to.equal(true);
|
||||
});
|
||||
|
||||
it('returns false if the way is closed and has no keys in iD.Way.areaKeys', function() {
|
||||
expect(iD.Way({nodes: ['n1', 'n1'], tags: {a: 'b'}}).isArea()).to.equal(false);
|
||||
});
|
||||
|
||||
it('returns false if the way is closed and has tag area=no', function() {
|
||||
expect(iD.Way({tags: { area: 'no' }, nodes: ['n1', 'n1']}).isArea()).to.equal(false);
|
||||
});
|
||||
|
||||
it('returns false if the way is closed and has highway tag', function() {
|
||||
expect(iD.Way({tags: { highway: 'residential' }, nodes: ['n1', 'n1']}).isArea()).to.equal(false);
|
||||
expect(iD.Way({nodes: ['n1', 'n1'], tags: {area: 'no', building: 'yes'}}).isArea()).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user