From 525d37c6479c08804166e133621bc6a0aa9616eb Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 13 May 2013 17:26:17 -0700 Subject: [PATCH] Preset#matchTags -> Preset#matchScore --- js/id/presets/category.js | 2 +- js/id/presets/collection.js | 2 +- js/id/presets/preset.js | 2 +- test/spec/presets/preset.js | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/js/id/presets/category.js b/js/id/presets/category.js index 5367f9407..5c36d3d80 100644 --- a/js/id/presets/category.js +++ b/js/id/presets/category.js @@ -11,7 +11,7 @@ iD.presets.Category = function(id, category, all) { return category.geometry.indexOf(geometry) >= 0; }; - category.matchTags = function() { return false; }; + category.matchScore = function() { return -1; }; category.name = function() { return t('presets.categories.' + id + '.name', {'default': id}); diff --git a/js/id/presets/collection.js b/js/id/presets/collection.js index d21916a21..8087fd861 100644 --- a/js/id/presets/collection.js +++ b/js/id/presets/collection.js @@ -26,7 +26,7 @@ iD.presets.Collection = function(collection) { match; for (var i = 0; i < collection.length; i++) { - var score = collection[i].matchTags(entity); + var score = collection[i].matchScore(entity); if (score > best) { best = score; match = collection[i]; diff --git a/js/id/presets/preset.js b/js/id/presets/preset.js index 76df447f3..ce825600b 100644 --- a/js/id/presets/preset.js +++ b/js/id/presets/preset.js @@ -12,7 +12,7 @@ iD.presets.Preset = function(id, preset, fields) { return preset.geometry.indexOf(geometry) >= 0; }; - preset.matchTags = function(entity) { + preset.matchScore = function(entity) { var tags = preset.tags, score = 0; for (var t in tags) { diff --git a/test/spec/presets/preset.js b/test/spec/presets/preset.js index 56483285e..9a3baee39 100644 --- a/test/spec/presets/preset.js +++ b/test/spec/presets/preset.js @@ -50,23 +50,23 @@ describe('iD.presets.Preset', function() { }); }); - describe('#matchTags', function() { + describe('#matchScore', function() { it("returns -1 if preset does not match tags", function() { - expect(p['highway/residential'].matchTags(w1)).to.equal(-1); + expect(p['highway/residential'].matchScore(w1)).to.equal(-1); }); it("returns 0 for other preset (no match tags)", function() { - expect(p.other.matchTags(w1)).to.equal(0); + expect(p.other.matchScore(w1)).to.equal(0); }); it("returns the number of matched tags", function() { - expect(p['highway/residential'].matchTags(w3)).to.equal(1); - expect(p['leisure/pitch/tennis'].matchTags(w2)).to.equal(2); + expect(p['highway/residential'].matchScore(w3)).to.equal(1); + expect(p['leisure/pitch/tennis'].matchScore(w2)).to.equal(2); }); it("counts * as a match for any value", function() { - expect(p.building.matchTags(w4)).to.equal(0.5); - expect(p.building.matchTags(w5)).to.equal(-1); + expect(p.building.matchScore(w4)).to.equal(0.5); + expect(p.building.matchScore(w5)).to.equal(-1); }); });