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

+7 -16
View File
@@ -6,6 +6,8 @@ const { solvePavedRegion } = require('./junction-region-solver');
const { stationAtDistanceFrom } = require('./junction-build-plan');
const { offsetCoordinate, metersAt } = require('../geometry/metric');
function pointAtStation(line, station, helpers) {
let remaining = Math.max(0, station);
for (let index = 1; index < line.length; index += 1) {
@@ -33,16 +35,6 @@ function tangentAtStation(line, station, helpers) {
return null;
}
function offsetCoordinate(point, heading, meters) {
if (!point || !Number.isFinite(heading)) return null;
const radians = (heading * Math.PI) / 180;
const lonMeters = 111320 * Math.cos((point[1] * Math.PI) / 180);
return [
point[0] + (Math.sin(radians) * meters) / Math.max(lonMeters, 1e-9),
point[1] + (Math.cos(radians) * meters) / 111320,
];
}
function sectionAt(item, radius, center, widthMeters, helpers, explicitStation, edgeOffsets = null) {
const station = Math.max(
0,
@@ -211,10 +203,9 @@ function ringsOverlap(first, second) {
function coordinateDistanceMeters(first, second) {
if (!first?.every(Number.isFinite) || !second?.every(Number.isFinite)) return Infinity;
const radians = Math.PI / 180;
const latitude = ((first[1] + second[1]) / 2) * radians;
const east = (second[0] - first[0]) * 111320 * Math.cos(latitude);
const north = (second[1] - first[1]) * 111320;
const { lon, lat } = metersAt((first[1] + second[1]) / 2);
const east = (second[0] - first[0]) * lon;
const north = (second[1] - first[1]) * lat;
return Math.hypot(east, north);
}
@@ -223,8 +214,8 @@ function coordinateDistanceMeters(first, second) {
// every remaining edge is an explicit closure between adjacent arms.
// Split at boundary crossings to check complete seam intervals, not samples.
function segmentCoveredByRing(start, end, ring) {
const scale = Math.cos((start[1] * Math.PI) / 180);
const xy = (p) => [(p[0] - start[0]) * 111320 * scale, (p[1] - start[1]) * 111320];
const { lon, lat } = metersAt(start[1]);
const xy = (p) => [(p[0] - start[0]) * lon, (p[1] - start[1]) * lat];
const d = xy(end),
boundary = ring.map(xy);
const cross = (a, b) => a[0] * b[1] - a[1] * b[0];