From 2039a1d44ea62b043f8ecd3f2011ff9f0512c02a Mon Sep 17 00:00:00 2001 From: vcoppe Date: Tue, 23 Jul 2024 15:55:16 +0200 Subject: [PATCH] finer grained anchors points at high zoom levels, related to #16 --- website/src/lib/components/toolbar/tools/routing/Simplify.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/src/lib/components/toolbar/tools/routing/Simplify.ts b/website/src/lib/components/toolbar/tools/routing/Simplify.ts index a3d7b012..5e12c7bc 100644 --- a/website/src/lib/components/toolbar/tools/routing/Simplify.ts +++ b/website/src/lib/components/toolbar/tools/routing/Simplify.ts @@ -10,7 +10,7 @@ export function getZoomLevelForDistance(latitude: number, distance?: number): nu const rad = Math.PI / 180; const lat = latitude * rad; - return Math.min(20, Math.max(0, Math.floor(Math.log2((earthRadius * Math.cos(lat)) / distance)))); + return Math.min(22, Math.max(0, Math.log2((earthRadius * Math.cos(lat)) / distance))); } export function updateAnchorPoints(file: GPXFile) { @@ -34,7 +34,7 @@ export function updateAnchorPoints(file: GPXFile) { function computeAnchorPoints(segment: TrackSegment) { let points = segment.trkpt; - let anchors = ramerDouglasPeucker(points); + let anchors = ramerDouglasPeucker(points, 1); anchors.forEach((anchor) => { let point = anchor.point; point._data.anchor = true;