Smarter tag conflict merging (fixes #943)

This commit is contained in:
John Firebaugh
2013-03-08 11:00:14 -08:00
parent f0f2425d63
commit fa01cfbbf0
2 changed files with 17 additions and 1 deletions

View File

@@ -73,7 +73,7 @@ iD.Entity.prototype = {
var t1 = merged[k],
t2 = tags[k];
if (t1 && t1 !== t2) {
merged[k] = t1 + ';' + t2;
merged[k] = _.union(t1.split(/;\s*/), t2.split(/;\s*/)).join(';');
} else {
merged[k] = t2;
}

View File

@@ -88,6 +88,22 @@ describe('iD.Entity', function () {
b = a.mergeTags({a: 'b'});
expect(b.tags).to.eql({a: 'a;b'});
});
it("combines combined tags", function () {
var a = iD.Entity({tags: {a: 'a;b'}}),
b = iD.Entity({tags: {a: 'b'}});
expect(a.mergeTags(b.tags).tags).to.eql({a: 'a;b'});
expect(b.mergeTags(a.tags).tags).to.eql({a: 'b;a'});
});
it("combines combined tags with whitespace", function () {
var a = iD.Entity({tags: {a: 'a; b'}}),
b = iD.Entity({tags: {a: 'b'}});
expect(a.mergeTags(b.tags).tags).to.eql({a: 'a;b'});
expect(b.mergeTags(a.tags).tags).to.eql({a: 'b;a'});
});
});
describe("#osmId", function () {