From 0f289f1865d8a67edc11be52d0d23a0cadf34849 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 12 Mar 2015 13:59:48 -0400 Subject: [PATCH] Prevent no-match parent relations from breaking getMatches (e.g. a site relation with a fence in it) Also, updated the test graph to contain one of these. see https://github.com/openstreetmap/iD/pull/2554#issuecomment-78517442 --- js/id/renderer/features.js | 6 ++++-- test/spec/renderer/features.js | 14 +++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/js/id/renderer/features.js b/js/id/renderer/features.js index 9793025d48f..75c6eac72da 100644 --- a/js/id/renderer/features.js +++ b/js/id/renderer/features.js @@ -305,8 +305,10 @@ iD.Features = function(context) { var parents = features.getParents(entity, resolver, geometry); if (parents.length === 1) { var pkey = iD.Entity.key(parents[0]); - matches = _.clone(_cache[pkey].matches); - continue; + if (_cache[pkey] && _cache[pkey].matches) { + matches = _.clone(_cache[pkey].matches); + continue; + } } } } diff --git a/test/spec/renderer/features.js b/test/spec/renderer/features.js index 35a615f4eaf..01c2155afa2 100644 --- a/test/spec/renderer/features.js +++ b/test/spec/renderer/features.js @@ -135,6 +135,8 @@ describe('iD.Features', function() { iD.Way({id: 'scrub', tags: {area: 'yes', natural: 'scrub'}, version: 1}), iD.Way({id: 'industrial', tags: {area: 'yes', landuse: 'industrial'}, version: 1}), iD.Way({id: 'parkinglot', tags: {area: 'yes', amenity: 'parking', parking: 'surface'}, version: 1}), + + // Landuse with hole iD.Way({id: 'inner', version: 1}), iD.Way({id: 'outer', version: 1}), iD.Relation({id: 'retail', tags: {landuse: 'retail', type: 'multipolygon'}, @@ -175,7 +177,17 @@ describe('iD.Features', function() { // Others iD.Way({id: 'fence', tags: {barrier: 'fence'}, version: 1}), - iD.Way({id: 'pipeline', tags: {man_made: 'pipeline'}, version: 1}) + iD.Way({id: 'pipeline', tags: {man_made: 'pipeline'}, version: 1}), + + // Site relation + iD.Relation({id: 'site', tags: {type: 'site'}, + members: [ + {id: 'fence', role: 'perimeter'}, + {id: 'building_yes'} + ], + version: 1 + }), + ]), all = _.values(graph.base().entities);