Add line geometry to traffic_calming=island preset (re: #5945)

Add more unit tests for tag_suggests_area
Replace "finds" with "flags" in validation unit test labels
This commit is contained in:
Quincy Morgan
2019-02-26 11:30:03 -05:00
parent 12d770a05e
commit 8a9399edb7
8 changed files with 71 additions and 30 deletions

View File

@@ -1014,7 +1014,7 @@
"traffic_calming/cushion": {"icon": "temaki-diamond", "fields": ["surface", "direction_vertex"], "geometry": ["vertex", "line"], "terms": ["bump", "hump", "speed", "slow"], "tags": {"traffic_calming": "cushion"}, "name": "Speed Cushion"},
"traffic_calming/dip": {"icon": "temaki-diamond", "fields": ["surface", "direction_vertex"], "geometry": ["vertex", "line"], "terms": ["speed", "slow"], "tags": {"traffic_calming": "dip"}, "name": "Dip"},
"traffic_calming/hump": {"icon": "temaki-diamond", "fields": ["surface", "direction_vertex"], "geometry": ["vertex", "line"], "terms": ["bump", "speed", "slow"], "tags": {"traffic_calming": "hump"}, "name": "Speed Hump"},
"traffic_calming/island": {"icon": "temaki-diamond", "fields": ["surface"], "geometry": ["vertex", "area"], "terms": ["circle", "roundabout", "slow"], "tags": {"traffic_calming": "island"}, "name": "Traffic Island"},
"traffic_calming/island": {"icon": "temaki-diamond", "fields": ["surface"], "geometry": ["vertex", "line", "area"], "terms": ["circle", "roundabout", "slow"], "tags": {"traffic_calming": "island"}, "name": "Traffic Island"},
"traffic_calming/rumble_strip": {"icon": "temaki-diamond", "fields": ["direction_vertex"], "geometry": ["vertex", "line"], "terms": ["audible lines", "sleeper lines", "growlers"], "tags": {"traffic_calming": "rumble_strip"}, "name": "Rumble Strip"},
"traffic_calming/table": {"icon": "temaki-diamond", "fields": ["surface", "direction_vertex"], "geometry": ["vertex"], "tags": {"traffic_calming": "table"}, "terms": ["flat top", "hump", "speed", "slow"], "name": "Speed Table"},
"traffic_sign_vertex": {"icon": "maki-square-stroked", "fields": ["traffic_sign", "traffic_sign/direction"], "geometry": ["vertex"], "tags": {"traffic_sign": "*"}, "terms": ["road", "highway"], "name": "Traffic Sign"},

View File

@@ -5,6 +5,7 @@
],
"geometry": [
"vertex",
"line",
"area"
],
"terms": [

View File

@@ -974,7 +974,7 @@
{"key": "traffic_calming", "value": "cushion", "description": "🄿 Speed Cushion", "object_types": ["node", "way"], "icon_url": "https://raw.githubusercontent.com/bhousel/temaki/master/icons/diamond.svg?sanitize=true"},
{"key": "traffic_calming", "value": "dip", "description": "🄿 Dip", "object_types": ["node", "way"], "icon_url": "https://raw.githubusercontent.com/bhousel/temaki/master/icons/diamond.svg?sanitize=true"},
{"key": "traffic_calming", "value": "hump", "description": "🄿 Speed Hump", "object_types": ["node", "way"], "icon_url": "https://raw.githubusercontent.com/bhousel/temaki/master/icons/diamond.svg?sanitize=true"},
{"key": "traffic_calming", "value": "island", "description": "🄿 Traffic Island", "object_types": ["node", "area"], "icon_url": "https://raw.githubusercontent.com/bhousel/temaki/master/icons/diamond.svg?sanitize=true"},
{"key": "traffic_calming", "value": "island", "description": "🄿 Traffic Island", "object_types": ["node", "way", "area"], "icon_url": "https://raw.githubusercontent.com/bhousel/temaki/master/icons/diamond.svg?sanitize=true"},
{"key": "traffic_calming", "value": "rumble_strip", "description": "🄿 Rumble Strip", "object_types": ["node", "way"], "icon_url": "https://raw.githubusercontent.com/bhousel/temaki/master/icons/diamond.svg?sanitize=true"},
{"key": "traffic_sign", "description": "🄿 Traffic Sign, 🄵 Traffic Sign", "object_types": ["node"], "icon_url": "https://raw.githubusercontent.com/mapbox/maki/master/icons/square-stroked-15.svg?sanitize=true"},
{"key": "traffic_sign", "value": "city_limit", "description": "🄿 City Limit Sign", "object_types": ["node"], "icon_url": "https://raw.githubusercontent.com/mapbox/maki/master/icons/square-stroked-15.svg?sanitize=true"},

View File

@@ -15,7 +15,8 @@ iD.data.presets = {
vertex: { name: 'Vertex', tags: {}, geometry: ['vertex'] },
relation: { name: 'Relation', tags: {}, geometry: ['relation'] },
// for tests related to areaKeys:
building: { name: 'Building', tags: { building: 'yes' }, geometry: ['area'] }
building: { name: 'Building', tags: { building: 'yes' }, geometry: ['point', 'area'] },
man_made: { name: 'Man Made', tags: { man_made: '*' }, geometry: ['vertex', 'point', 'line', 'area'] }
}
};

View File

@@ -39,7 +39,7 @@ describe('iD.validations.deprecated_tag', function () {
expect(issues).to.have.lengthOf(0);
});
it('finds deprecated tags', function() {
it('flags deprecated tags', function() {
createWay({'highway': 'ford'});
var issues = validate();
expect(issues).to.have.lengthOf(1);

View File

@@ -49,7 +49,7 @@ describe('iD.validations.disconnected_way', function () {
expect(issues).to.have.lengthOf(0);
});
it('finds disconnected highway', function() {
it('flags disconnected highway', function() {
createWay({'highway': 'unclassified'});
var issues = validate();
expect(issues).to.have.lengthOf(1);

View File

@@ -61,7 +61,7 @@ describe('iD.validations.missing_tag', function () {
expect(issues).to.have.lengthOf(0);
});
it('finds no tags', function() {
it('flags no tags', function() {
createWay({});
var issues = validate();
expect(issues).to.have.lengthOf(1);
@@ -71,7 +71,7 @@ describe('iD.validations.missing_tag', function () {
expect(issue.entities[0].id).to.eql('w-1');
});
it('finds no descriptive tags', function() {
it('flags no descriptive tags', function() {
createWay({ name: 'Main Street', source: 'Bing' });
var issues = validate();
expect(issues).to.have.lengthOf(1);
@@ -81,7 +81,7 @@ describe('iD.validations.missing_tag', function () {
expect(issue.entities[0].id).to.eql('w-1');
});
it('finds no descriptive tags on multipolygon', function() {
it('flags no descriptive tags on multipolygon', function() {
createRelation({ name: 'City Park', source: 'Bing', type: 'multipolygon' });
var issues = validate();
expect(issues).to.have.lengthOf(1);
@@ -91,7 +91,7 @@ describe('iD.validations.missing_tag', function () {
expect(issue.entities[0].id).to.eql('r-1');
});
it('finds no type tag on relation', function() {
it('flags no type tag on relation', function() {
createRelation({ name: 'City Park', source: 'Bing', leisure: 'park' });
var issues = validate();
expect(issues).to.have.lengthOf(1);

View File

@@ -5,18 +5,6 @@ describe('iD.validations.tag_suggests_area', function () {
context = iD.Context();
});
function createWay(tags) {
var n1 = iD.osmNode({id: 'n-1', loc: [4,4]});
var n2 = iD.osmNode({id: 'n-2', loc: [4,5]});
var w = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2'], tags: tags});
context.perform(
iD.actionAddEntity(n1),
iD.actionAddEntity(n2),
iD.actionAddEntity(w)
);
}
function createPoint(tags) {
var n1 = iD.osmNode({id: 'n-1', loc: [4,4], tags: tags});
context.perform(
@@ -24,6 +12,34 @@ describe('iD.validations.tag_suggests_area', function () {
);
}
function createOpenWay(tags) {
var n1 = iD.osmNode({id: 'n-1', loc: [4,4]});
var n2 = iD.osmNode({id: 'n-2', loc: [4,5]});
var n3 = iD.osmNode({id: 'n-3', loc: [5,5]});
var w = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2', 'n-3'], tags: tags});
context.perform(
iD.actionAddEntity(n1),
iD.actionAddEntity(n2),
iD.actionAddEntity(n3),
iD.actionAddEntity(w)
);
}
function createClosedWay(tags) {
var n1 = iD.osmNode({id: 'n-1', loc: [4,4]});
var n2 = iD.osmNode({id: 'n-2', loc: [4,5]});
var n3 = iD.osmNode({id: 'n-3', loc: [5,5]});
var w = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2', 'n-3', 'n-1'], tags: tags});
context.perform(
iD.actionAddEntity(n1),
iD.actionAddEntity(n2),
iD.actionAddEntity(n3),
iD.actionAddEntity(w)
);
}
function validate() {
var validator = iD.validationTagSuggestsArea();
var changes = context.history().changes();
@@ -41,20 +57,43 @@ describe('iD.validations.tag_suggests_area', function () {
expect(issues).to.have.lengthOf(0);
});
it('has no errors on good tags', function() {
createWay({'highway': 'unclassified'});
var issues = validate();
expect(issues).to.have.lengthOf(0);
});
it('ignores points', function() {
createPoint({'building': 'yes'});
createPoint({ building: 'yes' });
var issues = validate();
expect(issues).to.have.lengthOf(0);
});
it('finds tags that suggest area', function() {
createWay({'building': 'yes'});
it('ignores open way without area tag', function() {
createOpenWay({});
var issues = validate();
expect(issues).to.have.lengthOf(0);
});
it('ignores closed way with area tag', function() {
createClosedWay({ building: 'yes' });
var issues = validate();
expect(issues).to.have.lengthOf(0);
});
it('ignores open way with tag that allows both lines and areas', function() {
createOpenWay({ man_made: 'yes' });
var issues = validate();
expect(issues).to.have.lengthOf(0);
});
it('flags open way with area tag', function() {
createOpenWay({ building: 'yes' });
var issues = validate();
expect(issues).to.have.lengthOf(1);
var issue = issues[0];
expect(issue.type).to.eql('tag_suggests_area');
expect(issue.severity).to.eql('warning');
expect(issue.entities).to.have.lengthOf(1);
expect(issue.entities[0].id).to.eql('w-1');
});
it('flags open way with both area and line tags', function() {
createOpenWay({ area: 'yes', barrier: 'fence' });
var issues = validate();
expect(issues).to.have.lengthOf(1);
var issue = issues[0];