diff --git a/js/id/presets/preset.js b/js/id/presets/preset.js index f7cf8ba6c..64f61ab78 100644 --- a/js/id/presets/preset.js +++ b/js/id/presets/preset.js @@ -13,12 +13,18 @@ iD.presets.Preset = function(preset, forms) { }; preset.matchTags = function(entity) { - var tags = preset.match.tags; + var tags = preset.match.tags, + score = 0; for (var t in tags) { - if (entity.tags[t] !== tags[t] && - !(tags[t] === '*' && t in entity.tags)) return -1; + if (entity.tags[t] === tags[t]) { + score ++; + } else if (tags[t] === '*' && t in entity.tags) { + score += 0.5; + } else { + return -1; + } } - return Object.keys(preset.match.tags).length; + return score; }; preset.removeTags = function(tags, geometry) { diff --git a/test/spec/presets/preset.js b/test/spec/presets/preset.js index 0e6b15652..8b7a85761 100644 --- a/test/spec/presets/preset.js +++ b/test/spec/presets/preset.js @@ -103,7 +103,7 @@ describe('iD.presets.Preset', function() { }); it("counts * as a match for any value", function() { - expect(p.building.matchTags(w4)).to.equal(1); + expect(p.building.matchTags(w4)).to.equal(0.5); expect(p.building.matchTags(w5)).to.equal(-1); });