Don't flag buildings with lots of nodes or buildings connected to other buildings as unsquare (re: #6215)

This commit is contained in:
Quincy Morgan
2019-04-24 14:52:41 -07:00
parent d01bb78707
commit b30c91828f
+21 -2
View File
@@ -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);
});