From 804620d91e737d81b27c1d32dcaca0e860c4c8bb Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sat, 20 Feb 2021 23:10:41 -0500 Subject: [PATCH] filter false gap positives. also faster --- src/geo/polygons.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/geo/polygons.js b/src/geo/polygons.js index 4e710b0b..e6b389cb 100644 --- a/src/geo/polygons.js +++ b/src/geo/polygons.js @@ -555,7 +555,13 @@ let mid = offset(off, dist / 2, {z}); let cmp = offset(off, dist, {z}); let gap = []; - subtract(ref, cmp, gap, null, z); + let aref = ref.map(p => p.areaDeep()).reduce((a,p) => a +p); + let cref = cmp.length ? cmp.map(p => p.areaDeep()).reduce((a,p) => a + p) : 0; + // threshold subtraction to area deltas > 0.1 % to filter out false + // positives where inset/outset are identical floating point error + if (Math.abs(aref - cref) > 1 - (Math.abs(aref / cref) / 1000)) { + subtract(ref, cmp, gap, null, z); + } layers.push({idx: total-count, off, mid, gap}); ref = off; }