diff --git a/js/id/graph/relation.js b/js/id/graph/relation.js index 989ade40c..dc298ecbd 100644 --- a/js/id/graph/relation.js +++ b/js/id/graph/relation.js @@ -38,6 +38,10 @@ iD.Relation = iD.Entity.extend({ } }, + isRestriction: function() { + return !!(this.tags.type && this.tags.type.match(/^restriction:?/)); + }, + // Returns an array [A0, ... An], each Ai being an array of node arrays [Nds0, ... Ndsm], // where Nds0 is an outer ring and subsequent Ndsi's (if any i > 0) being inner rings. // diff --git a/test/spec/graph/relation.js b/test/spec/graph/relation.js index b6961a092..f8b49a213 100644 --- a/test/spec/graph/relation.js +++ b/test/spec/graph/relation.js @@ -89,6 +89,21 @@ describe('iD.Relation', function () { }); }); + describe("#isRestriction", function () { + it("returns true for 'restriction' type", function () { + expect(iD.Relation({tags: {type: 'restriction'}}).isRestriction()).to.be.true; + }); + + it("returns true for 'restriction:type' types", function () { + expect(iD.Relation({tags: {type: 'restriction:bus'}}).isRestriction()).to.be.true; + }); + + it("returns false otherwise", function () { + expect(iD.Relation().isRestriction()).to.be.false; + expect(iD.Relation({tags: {type: 'multipolygon'}}).isRestriction()).to.be.false; + }); + }); + describe("#multipolygon", function () { specify("single polygon consisting of a single way", function () { var a = iD.Node(),