Allow user to adjust the threshold for the unsquare building warning

This commit is contained in:
Bryan Housel
2019-05-18 15:44:29 -04:00
parent 03dd95e00f
commit 511f8ecc82
5 changed files with 136 additions and 13 deletions
+11 -3
View File
@@ -8,16 +8,17 @@ import { validationIssue, validationIssueFix } from '../core/validation';
export function validationUnsquareWay() {
var type = 'unsquare_way';
var DEFAULTSQUARE = 6.5; // see also issues.js
// use looser epsilon for detection to reduce warnings of buildings that are essentially square already
var epsilon = 0.05;
var degreeThreshold = 13;
var autofixDegreeThreshold = 6.5;
var nodeThreshold = 10;
// var degreeThreshold = 13;
// var autofixDegreeThreshold = 6.5;
function isBuilding(entity, graph) {
if (entity.type !== 'way' || entity.geometry(graph) !== 'area') return false;
return entity.tags.building && entity.tags.building !== 'no';
}
@@ -55,6 +56,13 @@ export function validationUnsquareWay() {
if (hasConnectedSquarableWays) return [];
// testing: user-configurable square threshold
var degreeThreshold = context.storage('validate-square-degrees');
if (degreeThreshold === null) {
degreeThreshold = '' + DEFAULTSQUARE;
}
var autofixDegreeThreshold = degreeThreshold;
var points = nodes.map(function(node) { return context.projection(node.loc); });
if (!geoOrthoCanOrthogonalize(points, isClosed, epsilon, degreeThreshold, true)) return [];