Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions modules/actions/merge_polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
});

Expand Down
12 changes: 12 additions & 0 deletions test/spec/actions/merge_polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
});
});