mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-22 16:19:48 +02:00
Handle multipolygon corner case when splitting (fixes #1799)
This commit is contained in:
@@ -29,7 +29,8 @@ iD.actions.Split = function(nodeId, newWayIds) {
|
||||
var wayB = iD.Way({id: newWayId, tags: wayA.tags}),
|
||||
nodesA,
|
||||
nodesB,
|
||||
isArea = wayA.isArea();
|
||||
isArea = wayA.isArea(),
|
||||
isOuter = iD.geo.isSimpleMultipolygonOuterMember(wayA, graph);
|
||||
|
||||
if (wayA.isClosed()) {
|
||||
var nodes = wayA.nodes.slice(0, -1),
|
||||
@@ -107,12 +108,18 @@ iD.actions.Split = function(nodeId, newWayIds) {
|
||||
}
|
||||
}
|
||||
|
||||
if (relation === isOuter) {
|
||||
relation = relation.mergeTags(wayA.tags);
|
||||
graph = graph.replace(wayA.update({tags: {}}));
|
||||
graph = graph.replace(wayB.update({tags: {}}));
|
||||
}
|
||||
|
||||
relation = relation.addMember({id: wayB.id, type: 'way', role: role}, i <= j ? i + 1 : i);
|
||||
graph = graph.replace(relation);
|
||||
}
|
||||
});
|
||||
|
||||
if (isArea) {
|
||||
if (!isOuter && isArea) {
|
||||
var multipolygon = iD.Relation({
|
||||
tags: _.extend({}, wayA.tags, {type: 'multipolygon'}),
|
||||
members: [
|
||||
|
||||
@@ -398,6 +398,22 @@ describe("iD.actions.Split", function () {
|
||||
expect(_.pluck(graph.entity('r').members, 'id')).to.eql(['~', '-', '=']);
|
||||
});
|
||||
|
||||
it("converts simple multipolygon to a proper multipolygon", function () {
|
||||
var graph = iD.Graph({
|
||||
'a': iD.Node({id: 'a'}),
|
||||
'b': iD.Node({id: 'b'}),
|
||||
'c': iD.Node({id: 'c'}),
|
||||
'-': iD.Way({'id': '-', nodes: ['a', 'b', 'c'], tags: {natural: 'water'}}),
|
||||
'r': iD.Relation({id: 'r', members: [{id: '-', type: 'way', role: 'outer'}], tags: {type: 'multipolygon'}})
|
||||
});
|
||||
|
||||
graph = iD.actions.Split('b', ['='])(graph);
|
||||
|
||||
expect(graph.entity('-').tags).to.eql({});
|
||||
expect(graph.entity('r').tags).to.eql({type: 'multipolygon', natural: 'water'});
|
||||
expect(_.pluck(graph.entity('r').members, 'id')).to.eql(['-', '=']);
|
||||
});
|
||||
|
||||
['restriction', 'restriction:bus'].forEach(function (type) {
|
||||
it("updates a restriction's 'from' role", function () {
|
||||
// Situation:
|
||||
|
||||
Reference in New Issue
Block a user