Exclude from areaKeys blacklist presets that are point/vertex only

(closes #3009)
This commit is contained in:
Bryan Housel
2016-03-10 15:35:40 -05:00
parent 58e6ac075b
commit 83b324b0bb
2 changed files with 45 additions and 14 deletions
+1 -1
View File
@@ -74,7 +74,7 @@ iD.presets = function() {
if (ignore.indexOf(key) !== -1) return;
var value = d.tags[key];
if (d.geometry.indexOf('area') === -1 && key in areaKeys && value !== '*') {
if (d.geometry.indexOf('line') !== -1 && key in areaKeys && value !== '*') {
areaKeys[key][value] = true;
}
});
+44 -13
View File
@@ -43,28 +43,59 @@ describe("iD.presets", function() {
describe("#areaKeys", function() {
var presets = iD.presets().load({
presets: {
a: {
tags: {
a: '*'
},
geometry: ['point', 'line', 'area']
'amenity/fuel/shell': {
tags: { 'amenity': 'fuel' },
geometry: ['point','area'],
suggestion: true
},
ab: {
tags: {
a: 'b'
},
'highway/foo': {
tags: { 'highway': 'foo' },
geometry: ['area']
},
'natural': {
tags: { 'natural': '*' },
geometry: ['point', 'vertex', 'area']
},
'natural/peak': {
tags: { 'natural': 'peak' },
geometry: ['point', 'vertex']
},
'natural/tree_row': {
tags: { 'natural': 'tree_row' },
geometry: ['line']
}
'natural/wood': {
tags: { 'natural': 'wood' },
geometry: ['point', 'area']
}
}
});
it("whitelists keys from presets with area geometry", function() {
expect(presets.areaKeys()).to.have.key('a');
it("whitelists keys for presets with area geometry", function() {
expect(presets.areaKeys()).to.have.key('natural');
});
it("blacklists key-values from presets without an area geometry", function() {
expect(presets.areaKeys().a.b).to.eq(true);
it("blacklists key-values for presets with a line geometry", function() {
expect(presets.areaKeys().natural).to.have.key('tree_row');
expect(presets.areaKeys().natural.tree_row).to.eq(true);
});
it("does not blacklist key-values for presets without a line geometry (e.g. used only on nodes)", function() {
expect(presets.areaKeys().natural).not.to.have.key('peak');
});
it("does not blacklist generic '*' key-values", function() {
expect(presets.areaKeys().natural).not.to.have.key('natural');
});
it("ignores keys like 'highway'", function() {
expect(presets.areaKeys()).not.to.have.key('highway');
});
it("ignores suggestion presets", function() {
expect(presets.areaKeys()).not.to.have.key('amenity');
});
});
describe("expected matches", function() {