feat: migrate workbench to React

This commit is contained in:
que01 committed 2026-08-26 15:01:07 +08:00
1 parent f15e69c868
commit 3ddb33e321
48 files changed
+16748 -1509

No files matched your search

+10 -8
View File
@@ -1,18 +1,20 @@
"use strict";
'use strict';
const EARTH_RADIUS_METERS = 6371008.8;
function laneCenterline(lane) {
const ring = lane?.geometry?.type === "Polygon" ? lane.geometry.coordinates?.[0] : null;
const ring = lane?.geometry?.type === 'Polygon' ? lane.geometry.coordinates?.[0] : null;
if (!Array.isArray(ring) || ring.length < 5 || !sameCoordinate(ring[0], ring.at(-1))) return null;
const vertices = ring.slice(0, -1);
if (!vertices.every(validCoordinate)) return null;
const half = vertices.length / 2;
if (!Number.isInteger(half) || half < 2) return null;
const centerline = vertices.slice(0, half).map((point, index) => [
(point[0] + vertices[vertices.length - 1 - index][0]) / 2,
(point[1] + vertices[vertices.length - 1 - index][1]) / 2,
]);
const centerline = vertices
.slice(0, half)
.map((point, index) => [
(point[0] + vertices[vertices.length - 1 - index][0]) / 2,
(point[1] + vertices[vertices.length - 1 - index][1]) / 2,
]);
return polylineLength(centerline) > 0.01 ? centerline : null;
}
@@ -82,7 +84,7 @@ function lateralOffsetFrom(polyline, point) {
const offsetY = py - dy * ratio;
const distance = Math.hypot(offsetX, offsetY);
if (!best || distance < best.distance) {
best = { distance, lateral: offsetX * dy / length - offsetY * dx / length };
best = { distance, lateral: (offsetX * dy) / length - (offsetY * dx) / length };
}
}
return best;
@@ -145,7 +147,7 @@ function metersAt(latitude) {
}
function degreesToRadians(value) {
return value * Math.PI / 180;
return (value * Math.PI) / 180;
}
module.exports = {