Skip to content

Commit

Permalink
Prevent no-match parent relations from breaking getMatches
Browse files Browse the repository at this point in the history
(e.g. a site relation with a fence in it)
Also, updated the test graph to contain one of these.
see openstreetmap#2554 (comment)
  • Loading branch information
bhousel authored and paulmach committed Jun 8, 2015
1 parent f3bd8b7 commit 0f289f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 4 additions & 2 deletions js/id/renderer/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion test/spec/renderer/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'},
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 0f289f1

Please sign in to comment.