Add Relation#isRestriction

This commit is contained in:
John Firebaugh
2013-01-18 13:03:54 -08:00
parent 3349e1f69c
commit b27903f7b5
2 changed files with 19 additions and 0 deletions
+4
View File
@@ -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.
//
+15
View File
@@ -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(),