feat: refine complex junction geometry and workbench

This commit is contained in:
que01 committed 2026-09-23 17:55:55 +08:00
1 parent 7c04d086db
commit 05614d1a69
20 files changed
+315 -267

No files matched your search

+6 -4
View File
@@ -1,15 +1,17 @@
'use strict';
const { metersAt } = require('../geometry/metric');
// 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 { lon, lat } = metersAt(center[1]);
const east = (islandCenter[0] - center[0]) * lon;
const north = (islandCenter[1] - center[1]) * lat;
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];
return [(distanceMeters * east) / length / lon, (distanceMeters * north) / length / lat];
}
module.exports = { radialShift };