diff --git a/js/id/svg.js b/js/id/svg.js index 1e704bf7a..d1ab55b71 100644 --- a/js/id/svg.js +++ b/js/id/svg.js @@ -83,11 +83,12 @@ iD.svg = { }; }, - MultipolygonMemberTags: function(graph) { + RelationMemberTags: function(graph) { return function(entity) { var tags = entity.tags; graph.parentRelations(entity).forEach(function(relation) { - if (relation.isMultipolygon()) { + var type = relation.tags.type; + if (type === 'multipolygon' || type === 'boundary') { tags = _.extend({}, relation.tags, tags); } }); diff --git a/js/id/svg/lines.js b/js/id/svg/lines.js index 474057fd1..d62d0c74e 100644 --- a/js/id/svg/lines.js +++ b/js/id/svg/lines.js @@ -86,7 +86,7 @@ iD.svg.Lines = function(projection) { lines .sort(waystack) .attr('d', getPath) - .call(iD.svg.TagClasses().tags(iD.svg.MultipolygonMemberTags(graph))); + .call(iD.svg.TagClasses().tags(iD.svg.RelationMemberTags(graph))); lines.exit() .remove(); diff --git a/test/spec/svg.js b/test/spec/svg.js index e69de29bb..56fbb2321 100644 --- a/test/spec/svg.js +++ b/test/spec/svg.js @@ -0,0 +1,21 @@ +describe("iD.svg.RelationMemberTags", function() { + it("includes tags from parent multipolygon relations", function() { + var graph = iD.Graph([ + iD.Way({id: 'w'}), + iD.Relation({id: 'r', members: [{id: 'w'}], tags: {type: 'multipolygon'}}), + ]); + + expect(iD.svg.RelationMemberTags(graph)(graph.entity('w'))) + .to.eql({type: 'multipolygon'}); + }); + + it("includes tags from parent boundary relations", function() { + var graph = iD.Graph([ + iD.Way({id: 'w'}), + iD.Relation({id: 'r', members: [{id: 'w'}], tags: {type: 'boundary'}}), + ]); + + expect(iD.svg.RelationMemberTags(graph)(graph.entity('w'))) + .to.eql({type: 'boundary'}); + }); +});