diff --git a/common/changes/@visactor/vrender-core/fix-simplify_2024-10-25-02-50.json b/common/changes/@visactor/vrender-core/fix-simplify_2024-10-25-02-50.json new file mode 100644 index 000000000..c3736b739 --- /dev/null +++ b/common/changes/@visactor/vrender-core/fix-simplify_2024-10-25-02-50.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@visactor/vrender-core", + "comment": "fix: annotate the Ramer Douglas Peucker algorithm in point optimization", + "type": "none" + } + ], + "packageName": "@visactor/vrender-core" +} diff --git a/packages/vrender-core/src/common/simplify.ts b/packages/vrender-core/src/common/simplify.ts index 479b808eb..81fd35457 100644 --- a/packages/vrender-core/src/common/simplify.ts +++ b/packages/vrender-core/src/common/simplify.ts @@ -62,13 +62,14 @@ function simplifyDPStep( nextIdx = i; } } + if (maxSqDist > sqTolerance) { if (nextIdx - startIdx > 2) { simplifyDPStep(points, startIdx, nextIdx, sqTolerance, simplified); } simplified.push(points[nextIdx], points[nextIdx + 1]); if (endIdx - nextIdx > 2) { - simplifyDPStep(points, nextIdx, endIdx, sqTolerance, simplified); + simplifyDPStep(points, nextIdx + 1, endIdx, sqTolerance, simplified); } } } @@ -88,6 +89,7 @@ export function flatten_simplify(points: IPointLike[], tolerance: number, highes } const sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1; points = highestQuality ? points : simplifyRadialDist(points, sqTolerance); - points = simplifyDouglasPeucker(points, sqTolerance); + // 暂时屏蔽 Douglas-Peucker 算法, 因为在极端情况下不会有点被删除, 导致性能问题 + // points = simplifyDouglasPeucker(points, sqTolerance); return points; }