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
This commit is contained in:
Bryan Housel
2015-03-12 13:59:48 -04:00
parent 3308b5507b
commit 05ff86e5c2
2 changed files with 17 additions and 3 deletions
+4 -2
View File
@@ -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;
}
}
}
}
+13 -1
View File
@@ -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);