mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-06 11:21:33 +00:00
Add area=yes when necessary
Example: highway=pedestrian areas. Fixes #2069
This commit is contained in:
@@ -81,9 +81,11 @@ iD.presets.Preset = function(id, preset, fields) {
|
||||
|
||||
var applyTags = preset.addTags || preset.tags;
|
||||
preset.applyTags = function(tags, geometry) {
|
||||
var k;
|
||||
|
||||
tags = _.clone(tags);
|
||||
|
||||
for (var k in applyTags) {
|
||||
for (k in applyTags) {
|
||||
if (applyTags[k] === '*') {
|
||||
tags[k] = 'yes';
|
||||
} else {
|
||||
@@ -91,6 +93,13 @@ iD.presets.Preset = function(id, preset, fields) {
|
||||
}
|
||||
}
|
||||
|
||||
// Add area=yes if necessary
|
||||
for (k in applyTags) {
|
||||
if (geometry === 'area' && !(k in iD.areaKeys))
|
||||
tags['area'] = 'yes';
|
||||
break;
|
||||
}
|
||||
|
||||
for (var f in preset.fields) {
|
||||
var field = preset.fields[f];
|
||||
if (field.matchGeometry(geometry) && field.key && !tags[field.key] && field['default']) {
|
||||
|
||||
@@ -61,7 +61,7 @@ describe('iD.presets.Preset', function() {
|
||||
describe('#applyTags', function() {
|
||||
it("adds match tags", function() {
|
||||
var preset = iD.presets.Preset('test', {tags: {highway: 'residential'}});
|
||||
expect(preset.applyTags({}, 'area')).to.eql({highway: 'residential'});
|
||||
expect(preset.applyTags({}, 'line')).to.eql({highway: 'residential'});
|
||||
});
|
||||
|
||||
it("adds wildcard tags with value 'yes'", function() {
|
||||
@@ -85,6 +85,18 @@ describe('iD.presets.Preset', function() {
|
||||
preset = iD.presets.Preset('test', {fields: ['field']}, {field: field});
|
||||
expect(preset.applyTags({}, 'point')).to.eql({});
|
||||
});
|
||||
|
||||
context("with an area preset whose primary tag is not in areaKeys", function() {
|
||||
var preset = iD.presets.Preset('test', {geometry: ['line', 'area'], tags: {highway: 'pedestrian'}});
|
||||
|
||||
it("adds no area=yes to non-areas", function() {
|
||||
expect(preset.applyTags({}, 'line')).to.eql({highway: 'pedestrian'});
|
||||
});
|
||||
|
||||
it("adds area=yes to areas", function() {
|
||||
expect(preset.applyTags({}, 'area')).to.eql({highway: 'pedestrian', area: 'yes'});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#removeTags', function() {
|
||||
|
||||
Reference in New Issue
Block a user