multiouters.add(r);
continue;
}
// Add it back!
Relation newRel = new Relation(r.rel);
newRel.addMember(new RelationMember(r.role, outer));
cmds.add(new ChangeCommand(r.rel, newRel));
}
Relation newRel;
switch (multiouters.size()) {
case 0:
return;
case 1:
// Found only one to be part of a multipolygon relation, so just add it back as well
newRel = new Relation(multiouters.get(0).rel);
newRel.addMember(new RelationMember(multiouters.get(0).role, outer));
cmds.add(new ChangeCommand(multiouters.get(0).rel, newRel));
return;
default:
// Create a new relation with all previous members and (Way)outer as outer.
newRel = new Relation();
for (RelationRole r : multiouters) {
// Add members
for (RelationMember rm : r.rel.getMembers())
if (!newRel.getMembers().contains(rm)) {
newRel.addMember(rm);
}
// Add tags
for (String key : r.rel.keySet()) {
newRel.put(key, r.rel.get(key));
}
// Delete old relation
relationsToDelete.add(r.rel);
}
newRel.addMember(new RelationMember("outer", outer));
cmds.add(new AddCommand(newRel));
}
}