From b30c91828f1bc3739b5162ef85754709682702b3 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 24 Apr 2019 14:52:41 -0700 Subject: [PATCH] Don't flag buildings with lots of nodes or buildings connected to other buildings as unsquare (re: #6215) --- modules/validations/unsquare_way.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/modules/validations/unsquare_way.js b/modules/validations/unsquare_way.js index 7f29f6523..a8c9dff8b 100644 --- a/modules/validations/unsquare_way.js +++ b/modules/validations/unsquare_way.js @@ -8,16 +8,35 @@ import { validationIssue, validationIssueFix } from '../core/validation'; export function validationUnsquareWay() { var type = 'unsquare_way'; + function isBuilding(entity, graph) { + if (entity.type !== 'way' || entity.geometry(graph) !== 'area') return false; + + return entity.tags.building && entity.tags.building !== 'no'; + } + var validation = function checkMissingRole(entity, context) { - if (entity.type !== 'way' || entity.geometry(context.graph()) !== 'area') return []; + var graph = context.graph(); - if (!entity.tags.building || entity.tags.building === 'no') return []; + if (!isBuilding(entity, graph)) return []; var isClosed = entity.isClosed(); var nodes = context.childNodes(entity).slice(); // shallow copy if (isClosed) nodes.pop(); + // don't flag ways with lots of nodes since they are likely detail-mapped + if (nodes.length > 6) return []; + + var hasConnectedSquarableWays = nodes.some(function(node) { + return graph.parentWays(node).some(function(way) { + if (way.id === entity.id) return false; + return isBuilding(way, graph); + }); + }); + + // don't flag connected ways to avoid unresolvable unsquare loops + if (hasConnectedSquarableWays) return []; + var locs = nodes.map(function(node) { return context.projection(node.loc); });