diff --git a/modules/actions/merge_polygon.js b/modules/actions/merge_polygon.js index 0f29cd5b5e5..c11c1c3cc43 100644 --- a/modules/actions/merge_polygon.js +++ b/modules/actions/merge_polygon.js @@ -107,8 +107,15 @@ export function actionMergePolygon(ids, newRelationId) { return m.id === way.id && m.role !== 'inner'; } if (members.some(isThisOuter)) { - relation = relation.mergeTags(way.tags); - graph = graph.replace(way.update({ tags: {} })); + //separate area tags from line-only tags (like natural=coastline) + var areaTags = Object.assign({}, way.tags); + var lineTags = {}; + if (areaTags.natural === 'coastline') { + delete areaTags.natural; + lineTags.natural = 'coastline'; + } + relation = relation.mergeTags(areaTags); + graph = graph.replace(way.update({ tags: lineTags })); } }); diff --git a/test/spec/actions/merge_polygon.js b/test/spec/actions/merge_polygon.js index 89814da98fc..1c29763b2fa 100644 --- a/test/spec/actions/merge_polygon.js +++ b/test/spec/actions/merge_polygon.js @@ -162,4 +162,16 @@ describe('iD.actionMergePolygon', function () { expect(find(r, 'w3').role).to.equal('inner'); expect(find(r, 'w4').role).to.equal('inner'); }); + + it('preserves coastline tag on the outer ways when creating a multipolygon', function() { + graph = graph.replace(graph.entity('w0').update({ tags: { 'natural': 'coastline', 'place': 'island' }})); + graph = iD.actionMergePolygon(['w0', 'w1'], 'r')(graph); + + //coastline should stay on the way + expect(graph.entity('w0').tags).to.eql({ natural: 'coastline' }); + + //other tags should move to the relation + var r = graph.entity('r'); + expect(r.tags).to.eql({ type: 'multipolygon', place: 'island' }); + }); });