From 8a9399edb7bbc1f2ddba7249bdbfc9824a1e04dc Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Tue, 26 Feb 2019 11:30:03 -0500 Subject: [PATCH] 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 --- data/presets/presets.json | 2 +- .../presets/traffic_calming/island.json | 1 + data/taginfo.json | 2 +- test/spec/spec_helpers.js | 3 +- test/spec/validations/deprecated_tag.js | 2 +- test/spec/validations/disconnected_way.js | 2 +- test/spec/validations/missing_tag.js | 8 +- test/spec/validations/tag_suggests_area.js | 81 ++++++++++++++----- 8 files changed, 71 insertions(+), 30 deletions(-) diff --git a/data/presets/presets.json b/data/presets/presets.json index 85246732a..937e5d330 100644 --- a/data/presets/presets.json +++ b/data/presets/presets.json @@ -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"}, diff --git a/data/presets/presets/traffic_calming/island.json b/data/presets/presets/traffic_calming/island.json index 0ae58511f..25da79301 100644 --- a/data/presets/presets/traffic_calming/island.json +++ b/data/presets/presets/traffic_calming/island.json @@ -5,6 +5,7 @@ ], "geometry": [ "vertex", + "line", "area" ], "terms": [ diff --git a/data/taginfo.json b/data/taginfo.json index 664efc5f1..fe6d87eb0 100644 --- a/data/taginfo.json +++ b/data/taginfo.json @@ -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"}, diff --git a/test/spec/spec_helpers.js b/test/spec/spec_helpers.js index 175112d4b..2a70210dd 100644 --- a/test/spec/spec_helpers.js +++ b/test/spec/spec_helpers.js @@ -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'] } } }; diff --git a/test/spec/validations/deprecated_tag.js b/test/spec/validations/deprecated_tag.js index 66cfdfd01..cd98818f5 100644 --- a/test/spec/validations/deprecated_tag.js +++ b/test/spec/validations/deprecated_tag.js @@ -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); diff --git a/test/spec/validations/disconnected_way.js b/test/spec/validations/disconnected_way.js index ddc9aa50d..592997d40 100644 --- a/test/spec/validations/disconnected_way.js +++ b/test/spec/validations/disconnected_way.js @@ -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); diff --git a/test/spec/validations/missing_tag.js b/test/spec/validations/missing_tag.js index ac02534dd..96a4b7443 100644 --- a/test/spec/validations/missing_tag.js +++ b/test/spec/validations/missing_tag.js @@ -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); diff --git a/test/spec/validations/tag_suggests_area.js b/test/spec/validations/tag_suggests_area.js index 8f6d2517f..479aa99b6 100644 --- a/test/spec/validations/tag_suggests_area.js +++ b/test/spec/validations/tag_suggests_area.js @@ -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];