From 21824e6377a77646c6c8662b808e46f979a00035 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Thu, 31 Jan 2019 10:59:12 +0000 Subject: [PATCH] Fix coincident errors Potential for multiple missing turn restrictions on one node and I've also seen a case of missing one-way along the same stretch of road in opposite directions! Missing geometry is tile based so can't really be coincident, but doesn't hurt to check in case they happen to land on a one-way or turn restriction. --- modules/services/improveOSM.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/modules/services/improveOSM.js b/modules/services/improveOSM.js index 4888249df..8a30a1d8f 100644 --- a/modules/services/improveOSM.js +++ b/modules/services/improveOSM.js @@ -115,6 +115,20 @@ function cardinalDirection(bearing) { return t('QA.improveOSM.directions.' + compass[dir]); } +// Errors shouldn't obscure eachother +function preventCoincident(loc, bumpUp) { + var coincident = false; + do { + // first time, move marker up. after that, move marker right. + var delta = coincident ? [0.00001, 0] : (bumpUp ? [0, 0.00001] : [0, 0]); + loc = geoVecAdd(loc, delta); + var bbox = geoExtent(loc).bbox(); + coincident = _erCache.rtree.search(bbox).length; + } while (coincident); + + return loc; +} + export default { init: function() { if (!_erCache) { @@ -192,6 +206,9 @@ export default { loc = [mid.lon, mid.lat]; } + // One-ways can land on same segment in opposite direction + loc = preventCoincident(loc, false); + var d = new iOsmError({ loc: loc, comments: null, @@ -225,6 +242,13 @@ export default { // Tiles at high zoom == missing roads if (data.tiles) { data.tiles.forEach(function(feature) { + // Average of recorded points should land on the missing geometry + var loc = pointAverage(feature.points); + + // Missing geometry could happen to land on another error + loc = preventCoincident(loc, false); + + var geoType = feature.type.toLowerCase(); var geoIcons = { road: 'maki-car', @@ -234,7 +258,7 @@ export default { }; var d = new iOsmError({ - loc: pointAverage(feature.points), + loc: loc, comments: null, error_subtype: geoType, error_type: k, @@ -258,8 +282,9 @@ export default { data.entities.forEach(function(feature) { var loc = feature.point; - // Bump position slightly so junction node is accessible - loc = geoVecAdd([loc.lon, loc.lat], [0, 0.00001]); + // Turn restrictions could be missing at same junction + // We also want to bump the error up so node is accessible + loc = preventCoincident([loc.lon, loc.lat], true); // Elements are presented in a strange way var ids = feature.id.split(',');