fix complex junction island geometry

This commit is contained in:
que01 committed 2026-09-16 13:24:34 +08:00
1 parent c3579074fd
commit 0c42eb46cd
19 files changed
+424 -44

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
'use strict';
// Pure geometry helpers for the cluster-level island drag. This module does
// not mutate compiler features; callers can validate the returned rings before
// publishing a preview.
function radialShift(center, islandCenter, distanceMeters) {
const scale = 111320 * Math.cos((center[1] * Math.PI) / 180);
const east = (islandCenter[0] - center[0]) * scale;
const north = (islandCenter[1] - center[1]) * 111320;
const length = Math.hypot(east, north);
if (!Number.isFinite(length) || length < 1e-9 || !Number.isFinite(distanceMeters)) return [0, 0];
return [(distanceMeters * east) / length / scale, (distanceMeters * north) / length / 111320];
}
module.exports = { radialShift };