From b841326e191d7efc439d6c5a8c82096ef8d0b4a0 Mon Sep 17 00:00:00 2001 From: vcoppe Date: Tue, 24 Dec 2024 16:40:48 +0100 Subject: [PATCH] finer tolerances for minify tool, closes #150 --- website/src/lib/components/toolbar/tools/Reduce.svelte | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/website/src/lib/components/toolbar/tools/Reduce.svelte b/website/src/lib/components/toolbar/tools/Reduce.svelte index ef4210a6..d78f376e 100644 --- a/website/src/lib/components/toolbar/tools/Reduce.svelte +++ b/website/src/lib/components/toolbar/tools/Reduce.svelte @@ -18,10 +18,13 @@ let sliderValue = [50]; let maxPoints = 0; let currentPoints = 0; + const minTolerance = 0.1; + const maxTolerance = 10000; $: validSelection = $selection.hasAnyChildren(new ListRootItem(), true, ['waypoints']); - $: tolerance = 2 ** (sliderValue[0] / (100 / Math.log2(10000))); + $: tolerance = + minTolerance * 2 ** (sliderValue[0] / (100 / Math.log2(maxTolerance / minTolerance))); let simplified = new Map(); let unsubscribes = new Map void>(); @@ -101,7 +104,7 @@ simplified.set(segmentItem.getFullId(), [ segmentItem, statistics.local.points.length, - ramerDouglasPeucker(statistics.local.points, 1) + ramerDouglasPeucker(statistics.local.points, minTolerance) ]); update(); } else if (simplified.has(segmentItem.getFullId())) { @@ -154,7 +157,7 @@