chore(deps): update dependency maplibre-gl-lanes to v1.4.0 #6

Merged
randy merged 1 commits from renovate/maplibre-gl-lanes-1.x into main 2026-11-03 18:09:53 +01:00
3 changed files with 83 additions and 62 deletions

No files matched your search

+4 -4
View File
@@ -9,7 +9,7 @@
"flag-icons": "7.6.0", "flag-icons": "7.6.0",
"maplibre-contour": "0.1.1", "maplibre-contour": "0.1.1",
"maplibre-gl": "6.16.0", "maplibre-gl": "6.16.0",
"maplibre-gl-lanes": "1.3.0", "maplibre-gl-lanes": "1.4.0",
"pmtiles": "4.5.0", "pmtiles": "4.5.0",
"suncalc": "2.1.1" "suncalc": "2.1.1"
} }
@@ -210,9 +210,9 @@
} }
}, },
"node_modules/maplibre-gl-lanes": { "node_modules/maplibre-gl-lanes": {
"version": "1.3.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/maplibre-gl-lanes/-/maplibre-gl-lanes-1.3.0.tgz", "resolved": "https://registry.npmjs.org/maplibre-gl-lanes/-/maplibre-gl-lanes-1.4.0.tgz",
"integrity": "sha512-Z6ZkBBvB8bIeChkZ7P7a6IEMqNhBIIvS/9d6hncacDSC8iUvhIaO9dSqeeFV1vMl7ykOozXmyjjoxTeRgBy4bQ==", "integrity": "sha512-N4zVCmit4uMyoJ4OF/38NBhXp8DMR9NxBcuZ0aew6QuvbRgI8gQh2dAHQWSM7OGG+QvoUN+ffbancggXpBtlww==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
+1 -1
View File
@@ -6,7 +6,7 @@
"flag-icons": "7.6.0", "flag-icons": "7.6.0",
"maplibre-contour": "0.1.1", "maplibre-contour": "0.1.1",
"maplibre-gl": "6.16.0", "maplibre-gl": "6.16.0",
"maplibre-gl-lanes": "1.3.0", "maplibre-gl-lanes": "1.4.0",
"pmtiles": "4.5.0", "pmtiles": "4.5.0",
"suncalc": "2.1.1" "suncalc": "2.1.1"
} }
+78 -57
View File
@@ -232,6 +232,26 @@ function endDirection(p) {
} }
return [0, 0]; return [0, 0];
} }
function startDirectionOver(p, window) {
let at = pointAlong(p, window), dx = at[0] - p[0], dy = at[1] - p[1], l = Math.hypot(dx, dy);
return l > 0 ? [dx / l, dy / l] : startDirection(p);
}
function endDirectionOver(p, window) {
let n = p.length, at = pointAlong(reversed(p), window), dx = p[n - 2] - at[0], dy = p[n - 1] - at[1], l = Math.hypot(dx, dy);
return l > 0 ? [dx / l, dy / l] : endDirection(p);
}
function pointAlong(p, dist) {
let acc = 0;
for (let i = 2; i < p.length; i += 2) {
let seg = Math.hypot(p[i] - p[i - 2], p[i + 1] - p[i - 1]);
if (acc + seg >= dist) {
let t = seg > 0 ? (dist - acc) / seg : 0;
return [p[i - 2] + (p[i] - p[i - 2]) * t, p[i - 1] + (p[i + 1] - p[i - 1]) * t];
}
acc += seg;
}
return [p[p.length - 2], p[p.length - 1]];
}
function trimPolyline(p, fromStart, fromEnd, keepFraction = 0.2) { function trimPolyline(p, fromStart, fromEnd, keepFraction = 0.2) {
let n = p.length / 2, seg = new Float64Array(Math.max(0, n - 1)), total = 0; let n = p.length / 2, seg = new Float64Array(Math.max(0, n - 1)), total = 0;
for (let i = 0; i < n - 1; i++) for (let i = 0; i < n - 1; i++)
@@ -515,64 +535,49 @@ function ccwAngle(a, b) {
for (; d >= 2 * Math.PI; ) d -= 2 * Math.PI; for (; d >= 2 * Math.PI; ) d -= 2 * Math.PI;
return d; return d;
} }
function smoothCatmullRom(p, segmentPx, maxPerSegment = 10, minBendDeg = 3, maxBendDeg = 180, cornerPx = 0) { function roundBends(p, deviationPx, minBendDeg = 3, cornerBendDeg = 180, cornerPx = 0) {
let n = p.length / 2; let n = p.length / 2;
if (n < 3) return p.slice(); if (n < 3) return p.slice();
if (maxBendDeg < 180) { if (cornerBendDeg < 180) {
let cosMax = Math.cos(maxBendDeg * Math.PI / 180), corners = null; let cosCorner = Math.cos(cornerBendDeg * Math.PI / 180), corners = null;
for (let i = 1; i < n - 1; i++) bendAt(p, i) < cosMax && (corners ?? (corners = [])).push(i); for (let i = 1; i < n - 1; i++) bendAt(p, i) < cosCorner && (corners ?? (corners = [])).push(i);
if (corners) { if (corners) {
let out2 = [], from = 0; let out2 = [], from = 0;
for (let c of [...corners, n - 1]) { for (let c of [...corners, n - 1]) {
let run = smoothCatmullRom(p.slice(from * 2, (c + 1) * 2), segmentPx, maxPerSegment, minBendDeg); let run = roundBends(p.slice(from * 2, (c + 1) * 2), deviationPx, minBendDeg);
for (let k = out2.length ? 2 : 0; k < run.length; k += 2) out2.push(run[k], run[k + 1]); for (let k = out2.length ? 2 : 0; k < run.length; k += 2) out2.push(run[k], run[k + 1]);
from = c; from = c;
} }
return cornerPx > 0 ? roundCorners(out2, p, corners, cornerPx) : out2; return cornerPx > 0 ? roundCorners(out2, p, corners, cornerPx) : out2;
} }
} }
let X = (i) => p[i * 2], Y = (i) => p[i * 2 + 1], bend = new Float64Array(n), cosMin = Math.cos(minBendDeg * Math.PI / 180); let cosMin = Math.cos(minBendDeg * Math.PI / 180), bends = [], reach = [];
for (let i = 1; i < n - 1; i++) { for (let i = 1; i < n - 1; i++) {
let ax = X(i) - X(i - 1), ay = Y(i) - Y(i - 1), bx = X(i + 1) - X(i), by = Y(i + 1) - Y(i), la = Math.hypot(ax, ay) || 1, lb = Math.hypot(bx, by) || 1; let c = bendAt(p, i);
bend[i] = (ax * bx + ay * by) / (la * lb); c >= cosMin || (bends.push(i), reach.push(4 * deviationPx / Math.sqrt(Math.max(0, 1 - c * c))));
} }
let out = [X(0), Y(0)]; if (!bends.length) return p.slice();
for (let i = 0; i < n - 1; i++) { let cum = new Float64Array(n);
let curved = i > 0 && bend[i] < cosMin || i + 1 < n - 1 && bend[i + 1] < cosMin, len = Math.hypot(X(i + 1) - X(i), Y(i + 1) - Y(i)), steps = curved ? Math.max(1, Math.min(maxPerSegment, Math.round(len / segmentPx))) : 1; for (let i = 1; i < n; i++)
if (steps === 1) { cum[i] = cum[i - 1] + Math.hypot(p[i * 2] - p[i * 2 - 2], p[i * 2 + 1] - p[i * 2 - 1]);
out.push(X(i + 1), Y(i + 1)); let out = [p[0], p[1]], done = 0;
for (let bi = 0; bi < bends.length; bi++) {
let c = bends[bi], prev = bi > 0 ? bends[bi - 1] : 0, next = bi + 1 < bends.length ? bends[bi + 1] : n - 1, cx = p[c * 2], cy = p[c * 2 + 1], ax = p[c * 2 - 2] - cx, ay = p[c * 2 - 1] - cy, la = Math.hypot(ax, ay), bx = p[c * 2 + 2] - cx, by = p[c * 2 + 3] - cy, lb = Math.hypot(bx, by), r = Math.min(reach[bi], 0.4 * (cum[c] - cum[prev]), 0.4 * (cum[next] - cum[c]), la, lb);
for (let i = done + 1; i < c; i++) out.push(p[i * 2], p[i * 2 + 1]);
if (done = c, r < 0.05) {
out.push(cx, cy);
continue; continue;
} }
let p0x = i > 0 ? X(i - 1) : 2 * X(0) - X(1), p0y = i > 0 ? Y(i - 1) : 2 * Y(0) - Y(1), p1x = X(i), p1y = Y(i), p2x = X(i + 1), p2y = Y(i + 1), p3x = i + 2 < n ? X(i + 2) : 2 * X(n - 1) - X(n - 2), p3y = i + 2 < n ? Y(i + 2) : 2 * Y(n - 1) - Y(n - 2), t0 = 0, t1 = t0 + (Math.sqrt(Math.hypot(p1x - p0x, p1y - p0y)) || 1e-6), t2 = t1 + (Math.sqrt(Math.hypot(p2x - p1x, p2y - p1y)) || 1e-6), t3 = t2 + (Math.sqrt(Math.hypot(p3x - p2x, p3y - p2y)) || 1e-6); let sx = cx + ax / la * r, sy = cy + ay / la * r, ex = cx + bx / lb * r, ey = cy + by / lb * r, steps = Math.max(4, Math.min(12, Math.round(r / 2))), first = Math.abs(out[out.length - 2] - sx) < 1e-9 && Math.abs(out[out.length - 1] - sy) < 1e-9 ? 1 : 0;
for (let s = 1; s < steps; s++) { for (let i = first; i <= steps; i++) {
let t = t1 + (t2 - t1) * s / steps, a1x = (t1 - t) / (t1 - t0) * p0x + (t - t0) / (t1 - t0) * p1x, a1y = (t1 - t) / (t1 - t0) * p0y + (t - t0) / (t1 - t0) * p1y, a2x = (t2 - t) / (t2 - t1) * p1x + (t - t1) / (t2 - t1) * p2x, a2y = (t2 - t) / (t2 - t1) * p1y + (t - t1) / (t2 - t1) * p2y, a3x = (t3 - t) / (t3 - t2) * p2x + (t - t2) / (t3 - t2) * p3x, a3y = (t3 - t) / (t3 - t2) * p2y + (t - t2) / (t3 - t2) * p3y, b1x = (t2 - t) / (t2 - t0) * a1x + (t - t0) / (t2 - t0) * a2x, b1y = (t2 - t) / (t2 - t0) * a1y + (t - t0) / (t2 - t0) * a2y, b2x = (t3 - t) / (t3 - t1) * a2x + (t - t1) / (t3 - t1) * a3x, b2y = (t3 - t) / (t3 - t1) * a2y + (t - t1) / (t3 - t1) * a3y; let t = i / steps, m = 1 - t;
out.push((t2 - t) / (t2 - t1) * b1x + (t - t1) / (t2 - t1) * b2x, (t2 - t) / (t2 - t1) * b1y + (t - t1) / (t2 - t1) * b2y); out.push(m * m * sx + 2 * m * t * cx + t * t * ex, m * m * sy + 2 * m * t * cy + t * t * ey);
} }
out.push(p2x, p2y); r >= lb && (done = c + 1);
} }
for (let i = done + 1; i < n; i++) out.push(p[i * 2], p[i * 2 + 1]);
return out; return out;
} }
function splineStartDirection(p, segmentPx, maxPerSegment = 10, minBendDeg = 3, maxBendDeg = 180) {
if (p.length / 2 < 3 || maxBendDeg < 180 && bendAt(p, 1) < Math.cos(maxBendDeg * Math.PI / 180)) return startDirection(p);
let steps = splineSteps(p, 0, segmentPx, maxPerSegment, minBendDeg);
if (steps < 2) return startDirection(p);
let [x, y] = centripetalPoint(2 * p[0] - p[2], 2 * p[1] - p[3], p[0], p[1], p[2], p[3], p[4], p[5], 1 / steps), dx = x - p[0], dy = y - p[1], l = Math.hypot(dx, dy);
return l > 0 ? [dx / l, dy / l] : startDirection(p);
}
function splineEndDirection(p, segmentPx, maxPerSegment = 10, minBendDeg = 3, maxBendDeg = 180) {
let n = p.length / 2;
if (n < 3 || maxBendDeg < 180 && bendAt(p, n - 2) < Math.cos(maxBendDeg * Math.PI / 180)) return endDirection(p);
let steps = splineSteps(p, n - 2, segmentPx, maxPerSegment, minBendDeg);
if (steps < 2) return endDirection(p);
let o = (n - 1) * 2, [x, y] = centripetalPoint(p[o - 4], p[o - 3], p[o - 2], p[o - 1], p[o], p[o + 1], 2 * p[o] - p[o - 2], 2 * p[o + 1] - p[o - 1], (steps - 1) / steps), dx = p[o] - x, dy = p[o + 1] - y, l = Math.hypot(dx, dy);
return l > 0 ? [dx / l, dy / l] : endDirection(p);
}
function splineSteps(p, i, segmentPx, maxPerSegment, minBendDeg) {
let n = p.length / 2, cosMin = Math.cos(minBendDeg * Math.PI / 180);
if (!(i > 0 && bendAt(p, i) < cosMin || i + 1 < n - 1 && bendAt(p, i + 1) < cosMin)) return 1;
let len = Math.hypot(p[i * 2 + 2] - p[i * 2], p[i * 2 + 3] - p[i * 2 + 1]);
return Math.max(1, Math.min(maxPerSegment, Math.round(len / segmentPx)));
}
function roundCorners(out, src, corners, radiusPx) { function roundCorners(out, src, corners, radiusPx) {
let n = src.length / 2, cum = new Float64Array(n); let n = src.length / 2, cum = new Float64Array(n);
for (let i = 1; i < n; i++) for (let i = 1; i < n; i++)
@@ -624,10 +629,6 @@ function bendAt(p, k) {
let ax = p[k * 2] - p[k * 2 - 2], ay = p[k * 2 + 1] - p[k * 2 - 1], bx = p[k * 2 + 2] - p[k * 2], by = p[k * 2 + 3] - p[k * 2 + 1]; let ax = p[k * 2] - p[k * 2 - 2], ay = p[k * 2 + 1] - p[k * 2 - 1], bx = p[k * 2 + 2] - p[k * 2], by = p[k * 2 + 3] - p[k * 2 + 1];
return (ax * bx + ay * by) / ((Math.hypot(ax, ay) || 1) * (Math.hypot(bx, by) || 1)); return (ax * bx + ay * by) / ((Math.hypot(ax, ay) || 1) * (Math.hypot(bx, by) || 1));
} }
function centripetalPoint(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y, u) {
let t1 = 0 + (Math.sqrt(Math.hypot(p1x - p0x, p1y - p0y)) || 1e-6), t2 = t1 + (Math.sqrt(Math.hypot(p2x - p1x, p2y - p1y)) || 1e-6), t3 = t2 + (Math.sqrt(Math.hypot(p3x - p2x, p3y - p2y)) || 1e-6), t = t1 + (t2 - t1) * u, a1x = (t1 - t) / (t1 - 0) * p0x + (t - 0) / (t1 - 0) * p1x, a1y = (t1 - t) / (t1 - 0) * p0y + (t - 0) / (t1 - 0) * p1y, a2x = (t2 - t) / (t2 - t1) * p1x + (t - t1) / (t2 - t1) * p2x, a2y = (t2 - t) / (t2 - t1) * p1y + (t - t1) / (t2 - t1) * p2y, a3x = (t3 - t) / (t3 - t2) * p2x + (t - t2) / (t3 - t2) * p3x, a3y = (t3 - t) / (t3 - t2) * p2y + (t - t2) / (t3 - t2) * p3y, b1x = (t2 - t) / (t2 - 0) * a1x + (t - 0) / (t2 - 0) * a2x, b1y = (t2 - t) / (t2 - 0) * a1y + (t - 0) / (t2 - 0) * a2y, b2x = (t3 - t) / (t3 - t1) * a2x + (t - t1) / (t3 - t1) * a3x, b2y = (t3 - t) / (t3 - t1) * a2y + (t - t1) / (t3 - t1) * a3y;
return [(t2 - t) / (t2 - t1) * b1x + (t - t1) / (t2 - t1) * b2x, (t2 - t) / (t2 - t1) * b1y + (t - t1) / (t2 - t1) * b2y];
}
function polylineBounds(p) { function polylineBounds(p) {
let minX = 1 / 0, minY = 1 / 0, maxX = -1 / 0, maxY = -1 / 0; let minX = 1 / 0, minY = 1 / 0, maxX = -1 / 0, maxY = -1 / 0;
for (let i = 0; i < p.length; i += 2) for (let i = 0; i < p.length; i += 2)
@@ -1372,7 +1373,7 @@ function getWorker(kind) {
if (failed[kind] || typeof Worker > "u") return null; if (failed[kind] || typeof Worker > "u") return null;
let worker; let worker;
try { try {
blobUrl || (blobUrl = URL.createObjectURL(new Blob(['"use strict";(()=>{var Fn=Object.defineProperty;var Rn=(e,n,t)=>n in e?Fn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var B=(e,n,t)=>Rn(e,typeof n!="symbol"?n+"":n,t);function Fe(e){let n=e.edges.map(o=>({...o,direction:new Map(o.direction??[]),order:o.order.slice()})),t=e.routes?new Map(e.routes.map(o=>[o.id,o])):new Map(e.routeIds.map(o=>[o,{id:o,color:"#000"}]));return{nodes:e.nodes,edges:n,routes:t,chains:new Map(e.chains)}}function Re(e){let n=e.length,t=new Uint32Array(n+1),o=0;for(let l=0;l<n;l++)o+=e[l].coords.length,t[l+1]=o;let s={coords:new Float64Array(o),anchors:new Float64Array(o),offsets:t,routeIds:[],route:new Uint32Array(n),looks:[],look:new Uint32Array(n),kind:new Uint8Array(n),travel:new Int8Array(n),startDistance:new Float64Array(n),edge:new Int32Array(n),node:new Int32Array(n),betweenU:new Int32Array(n),betweenV:new Int32Array(n)},i=new Map,d=new Map;for(let l=0;l<n;l++){let r=e[l],c=t[l];for(let f=0;f<r.coords.length;f++)s.coords[c+f]=r.coords[f],s.anchors[c+f]=r.anchors[f];let a=i.get(r.route);a===void 0&&(a=s.routeIds.push(r.route)-1,i.set(r.route,a));let u=d.get(r.look);u===void 0&&(u=s.looks.push(r.look)-1,d.set(r.look,u)),s.route[l]=a,s.look[l]=u,s.kind[l]=r.kind==="lane"?0:1,s.travel[l]=r.travel,s.startDistance[l]=r.startDistance,s.edge[l]=r.edge,s.node[l]=r.node??-1,s.betweenU[l]=r.between?r.between[0]:-1,s.betweenV[l]=r.between?r.between[1]:-1}return s}function je(e){return[e.coords.buffer,e.anchors.buffer,e.offsets.buffer,e.route.buffer,e.look.buffer,e.kind.buffer,e.travel.buffer,e.startDistance.buffer,e.edge.buffer,e.node.buffer,e.betweenU.buffer,e.betweenV.buffer]}function Q(e){let n=0;for(let t=2;t<e.length;t+=2)n+=Math.hypot(e[t]-e[t-2],e[t+1]-e[t-1]);return n}function W(e){let n=new Array(e.length);for(let t=0,o=e.length-2;t<e.length;t+=2,o-=2)n[t]=e[o],n[t+1]=e[o+1];return n}function J(e){for(let n=2;n<e.length;n+=2){let t=e[n]-e[0],o=e[n+1]-e[1],s=Math.hypot(t,o);if(s>0)return[t/s,o/s]}return[0,0]}function Y(e){let n=e.length;for(let t=n-4;t>=0;t-=2){let o=e[n-2]-e[t],s=e[n-1]-e[t+1],i=Math.hypot(o,s);if(i>0)return[o/i,s/i]}return[0,0]}function we(e,n,t,o=.2){let s=e.length/2,i=new Float64Array(Math.max(0,s-1)),d=0;for(let f=0;f<s-1;f++)i[f]=Math.hypot(e[f*2+2]-e[f*2],e[f*2+3]-e[f*2+1]),d+=i[f];if(d<=0)return e.slice();let l=d*(1-o);if(n+t>l){let f=l/(n+t);n*=f,t*=f}let r=$e(e,i,n),c=$e(e,i,d-t),a=[r.x,r.y],u=0;for(let f=0;f<s-1;f++)u+=i[f],u>n&&u<d-t&&a.push(e[f*2+2],e[f*2+3]);return a.push(c.x,c.y),a}function $e(e,n,t){if(t<=0)return{x:e[0],y:e[1]};let o=0;for(let s=0;s<n.length;s++){let i=n[s];if(o+i>=t){let d=i>0?(t-o)/i:0;return{x:e[s*2]+(e[s*2+2]-e[s*2])*d,y:e[s*2+1]+(e[s*2+3]-e[s*2+1])*d}}o+=i}return{x:e[e.length-2],y:e[e.length-1]}}function ie(e,n){let t=e.length/2;if(t<=2||n<=0)return e.slice();let o=new Uint8Array(t);o[0]=1,o[t-1]=1;let s=n*n,i=[0,t-1];for(;i.length;){let l=i.pop(),r=i.pop(),c=0,a=-1,u=e[r*2],f=e[r*2+1],m=e[l*2],h=e[l*2+1];for(let g=r+1;g<l;g++){let b=Ye(e[g*2],e[g*2+1],u,f,m,h);b>c&&(c=b,a=g)}c>s&&a>0&&(o[a]=1,i.push(r,a,a,l))}let d=[];for(let l=0;l<t;l++)o[l]&&d.push(e[l*2],e[l*2+1]);return d}function Ze(e){let n=e.length/2,t=new Float64Array(n);if(n===0||(t[0]=1/0,t[n-1]=1/0,n<=2))return t;let o=[0,n-1],s=[1/0];for(;o.length;){let i=o.pop(),d=o.pop(),l=s.pop(),r=0,c=-1,a=e[d*2],u=e[d*2+1],f=e[i*2],m=e[i*2+1];for(let h=d+1;h<i;h++){let g=Ye(e[h*2],e[h*2+1],a,u,f,m);g>r&&(r=g,c=h)}if(r>0&&c>0){let h=r<l?r:l;t[c]=h,o.push(d,c,c,i),s.push(h,h)}}return t}function Je(e,n,t){let o=e.length/2;if(o<=2||t<=0)return e.slice();let s=t*t,i=[];for(let d=0;d<o;d++)n[d]>s&&i.push(e[d*2],e[d*2+1]);return i}function Ye(e,n,t,o,s,i){let d=s-t,l=i-o,r=d*d+l*l;if(r>0){let c=Math.max(0,Math.min(1,((e-t)*d+(n-o)*l)/r));d=t+d*c,l=o+l*c}else d=t,l=o;return(e-d)*(e-d)+(n-l)*(n-l)}function He(e,n=1e-9){let t=[];for(let o=0;o<e.length;o+=2){let s=t.length;s>=2&&Math.abs(t[s-2]-e[o])<n&&Math.abs(t[s-1]-e[o+1])<n||t.push(e[o],e[o+1])}return t}var Ke=12,Tn=8;function qe(e,n,t=Math.PI/9){return q(e,n,t).points}function q(e,n,t=Math.PI/9){let o=He(e),s=o.length/2;if(s<2||n===0)return{points:o.slice(),anchors:o.slice()};let i=new Float64Array((s-1)*4);for(let c=0;c<s-1;c++){let a=o[c*2],u=o[c*2+1],f=o[c*2+2],m=o[c*2+3],h=f-a,g=m-u,b=Math.hypot(h,g),p=g/b,A=-h/b;i[c*4]=a+p*n,i[c*4+1]=u+A*n,i[c*4+2]=f+p*n,i[c*4+3]=m+A*n}let d=[i[0],i[1]],l=[o[0],o[1]];for(let c=1;c<s-1;c++){let a=(c-1)*4,u=c*4,f=i[a],m=i[a+1],h=i[a+2],g=i[a+3],b=i[u],p=i[u+1],A=i[u+2],w=i[u+3],y=o[c*2],k=o[c*2+1],v=(h-f)*(w-p)-(g-m)*(A-b),x=(h-f)*(A-b)+(g-m)*(w-p),M=n>0==v>0;if(Math.abs(v)<1e-9*Math.max(1,Math.abs(x))){d.push(b,p),l.push(y,k);continue}if(!M){let N=xe(f,m,h,g,b,p,A,w);N&&Math.hypot(N[0]-y,N[1]-k)<=Tn*Math.abs(n)?(d.push(N[0],N[1]),l.push(y,k)):(d.push(h,g,b,p),l.push(y,k,y,k));continue}let L=Math.atan2(g-k,h-y),C=Math.atan2(p-k,b-y)-L;for(;C>Math.PI;)C-=2*Math.PI;for(;C<-Math.PI;)C+=2*Math.PI;let O=Math.max(1,Math.ceLine truncated blobUrl || (blobUrl = URL.createObjectURL(new Blob(['"use strict";(()=>{var Rn=Object.defineProperty;var Tn=(e,n,t)=>n in e?Rn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var G=(e,n,t)=>Tn(e,typeof n!="symbol"?n+"":n,t);function Se(e){let n=e.edges.map(o=>({...o,direction:new Map(o.direction??[]),order:o.order.slice()})),t=e.routes?new Map(e.routes.map(o=>[o.id,o])):new Map(e.routeIds.map(o=>[o,{id:o,color:"#000"}]));return{nodes:e.nodes,edges:n,routes:t,chains:new Map(e.chains)}}function Ie(e){let n=e.length,t=new Uint32Array(n+1),o=0;for(let l=0;l<n;l++)o+=e[l].coords.length,t[l+1]=o;let r={coords:new Float64Array(o),anchors:new Float64Array(o),offsets:t,routeIds:[],route:new Uint32Array(n),looks:[],look:new Uint32Array(n),kind:new Uint8Array(n),travel:new Int8Array(n),startDistance:new Float64Array(n),edge:new Int32Array(n),node:new Int32Array(n),betweenU:new Int32Array(n),betweenV:new Int32Array(n)},s=new Map,u=new Map;for(let l=0;l<n;l++){let a=e[l],i=t[l];for(let m=0;m<a.coords.length;m++)r.coords[i+m]=a.coords[m],r.anchors[i+m]=a.anchors[m];let c=s.get(a.route);c===void 0&&(c=r.routeIds.push(a.route)-1,s.set(a.route,c));let d=u.get(a.look);d===void 0&&(d=r.looks.push(a.look)-1,u.set(a.look,d)),r.route[l]=c,r.look[l]=d,r.kind[l]=a.kind==="lane"?0:1,r.travel[l]=a.travel,r.startDistance[l]=a.startDistance,r.edge[l]=a.edge,r.node[l]=a.node??-1,r.betweenU[l]=a.between?a.between[0]:-1,r.betweenV[l]=a.between?a.between[1]:-1}return r}function Ve(e){return[e.coords.buffer,e.anchors.buffer,e.offsets.buffer,e.route.buffer,e.look.buffer,e.kind.buffer,e.travel.buffer,e.startDistance.buffer,e.edge.buffer,e.node.buffer,e.betweenU.buffer,e.betweenV.buffer]}function K(e){let n=0;for(let t=2;t<e.length;t+=2)n+=Math.hypot(e[t]-e[t-2],e[t+1]-e[t-1]);return n}function W(e){let n=new Array(e.length);for(let t=0,o=e.length-2;t<e.length;t+=2,o-=2)n[t]=e[o],n[t+1]=e[o+1];return n}function ne(e){for(let n=2;n<e.length;n+=2){let t=e[n]-e[0],o=e[n+1]-e[1],r=Math.hypot(t,o);if(r>0)return[t/r,o/r]}return[0,0]}function te(e){let n=e.length;for(let t=n-4;t>=0;t-=2){let o=e[n-2]-e[t],r=e[n-1]-e[t+1],s=Math.hypot(o,r);if(s>0)return[o/s,r/s]}return[0,0]}function Xe(e,n){let t=Ze(e,n),o=t[0]-e[0],r=t[1]-e[1],s=Math.hypot(o,r);return s>0?[o/s,r/s]:ne(e)}function Ce(e,n){let t=e.length,o=Ze(W(e),n),r=e[t-2]-o[0],s=e[t-1]-o[1],u=Math.hypot(r,s);return u>0?[r/u,s/u]:te(e)}function Ze(e,n){let t=0;for(let o=2;o<e.length;o+=2){let r=Math.hypot(e[o]-e[o-2],e[o+1]-e[o-1]);if(t+r>=n){let s=r>0?(n-t)/r:0;return[e[o-2]+(e[o]-e[o-2])*s,e[o-1]+(e[o+1]-e[o-1])*s]}t+=r}return[e[e.length-2],e[e.length-1]]}function ue(e,n,t,o=.2){let r=e.length/2,s=new Float64Array(Math.max(0,r-1)),u=0;for(let m=0;m<r-1;m++)s[m]=Math.hypot(e[m*2+2]-e[m*2],e[m*2+3]-e[m*2+1]),u+=s[m];if(u<=0)return e.slice();let l=u*(1-o);if(n+t>l){let m=l/(n+t);n*=m,t*=m}let a=ze(e,s,n),i=ze(e,s,u-t),c=[a.x,a.y],d=0;for(let m=0;m<r-1;m++)d+=s[m],d>n&&d<u-t&&c.push(e[m*2+2],e[m*2+3]);return c.push(i.x,i.y),c}function ze(e,n,t){if(t<=0)return{x:e[0],y:e[1]};let o=0;for(let r=0;r<n.length;r++){let s=n[r];if(o+s>=t){let u=s>0?(t-o)/s:0;return{x:e[r*2]+(e[r*2+2]-e[r*2])*u,y:e[r*2+1]+(e[r*2+3]-e[r*2+1])*u}}o+=s}return{x:e[e.length-2],y:e[e.length-1]}}function pe(e,n){let t=e.length/2;if(t<=2||n<=0)return e.slice();let o=new Uint8Array(t);o[0]=1,o[t-1]=1;let r=n*n,s=[0,t-1];for(;s.length;){let l=s.pop(),a=s.pop(),i=0,c=-1,d=e[a*2],m=e[a*2+1],p=e[l*2],f=e[l*2+1];for(let h=a+1;h<l;h++){let b=He(e[h*2],e[h*2+1],d,m,p,f);b>i&&(i=b,c=h)}i>r&&c>0&&(o[c]=1,s.push(a,c,c,l))}let u=[];for(let l=0;l<t;l++)o[l]&&u.push(e[l*2],e[l*2+1]);return u}function Je(e){let n=e.length/2,t=new Float64Array(n);if(n===0||(t[0]=1/0,t[n-1]=1/0,n<=2))return t;let o=[0,n-1],r=[1/0];for(;o.length;){let s=o.pop(),u=o.pop(),l=r.pop(),a=0,i=-1,c=e[u*2],d=e[u*2+1],m=e[s*2],p=e[s*2+1];for(let f=u+1;f<s;f++){let h=He(e[f*2],e[f*2+1],c,d,m,p);h>a&&(a=h,i=f)}if(a>0&&i>0){let f=a<l?a:l;t[i]=f,o.push(u,i,i,s),r.push(f,f)}}return t}function Ye(e,n,t){let o=e.length/2;if(o<=2||t<=0)return e.slice();let r=t*t,s=[];for(let u=0;u<o;u++)n[u]>r&&s.push(e[u*2],e[u*2+1]);return s}function He(e,n,t,o,r,s){let u=r-t,l=s-o,a=u*u+l*l;if(a>0){let i=Math.max(0,Math.min(1,((e-t)*u+(n-o)*l)/a));u=t+u*i,l=o+l*i}else u=t,l=o;return(e-u)*(e-u)+(n-l)*(n-l)}function Ke(e,n=1e-9){let t=[];for(let o=0;o<e.length;o+=2){let r=t.length;r>=2&&Math.abs(t[r-2]-e[o])<n&&Math.abs(t[r-1]-e[o+1])<n||t.push(e[o],e[o+1])}return t}var qe=12,Nn=8;function Qe(e,n,t=Math.PI/9){return H(e,n,t).points}function H(e,n,t=Math.PI/9){let o=Ke(e),r=o.length/2;if(r<2||n===0)return{points:o.slice(),anchors:o.slice()};let s=new Float64Array((r-1)*4);for(let i=0;i<r-1;i++){let c=o[i*2],d=o[i*2+1],m=o[i*2+2],p=o[i*2+3],f=m-c,h=p-d,b=Math.hypot(f,h),g=h/b,A=-f/b;s[i*4]=c+g*n,s[i*4+1]=d+A*n,s[i*4+2]=m+g*n,s[i*4+3]=p+A*n}let u=[s[0],s[1]],l=[o[0],o[1]];for(let i=1;i<r-1;i++){let c=(i-1)*4,d=i*4,m=s[c],p=s[c+1],f=s[c+2],h=s[c+3],b=s[d],g=s[d+1],A=s[d+2],M=s[d+3],yLine truncated
} catch { } catch {
return failed[kind] = !0, null; return failed[kind] = !0, null;
} }
@@ -1700,7 +1701,7 @@ function solve(g) {
} }
// src/core/layout.ts // src/core/layout.ts
var SIMPLIFY_TOLERANCE_PX2 = 0.25, GENERALIZE_PER_OFFSET = 0.25, SMOOTH_SEGMENT_PX = 5, MIN_FRONT_MARGIN_LANES = 0.6, MAX_FRONT_FRACTION = 0.42, CLIQUE_MIN_REF_LANES = 1.5, MAX_SLIDE_SLOPE = 0.4, SOLO_EASE_LANES = 12, SOLO_EASE_STEPS = 6, MERGE_BELOW_BUNDLE_WIDTHS = 1, MAX_MERGE_PASSES = 4, CORNER_BEND_DEG = 60, CORNER_RADIUS_LANES = 1.5, CORNER_MIN_TURN_DEG = 60, CORNER_MAX_REACH = 1.5, FOLLOW_ABOVE_LANES = 1, SNAP_HOOK_LANES = 3, LayoutCache = class { var SIMPLIFY_TOLERANCE_PX2 = 0.25, GENERALIZE_PER_OFFSET = 0.25, MIN_FRONT_MARGIN_LANES = 0.6, MAX_FRONT_FRACTION = 0.42, CLIQUE_MIN_REF_LANES = 1.5, MAX_SLIDE_SLOPE = 0.4, SOLO_EASE_LANES = 12, SOLO_EASE_STEPS = 6, MERGE_BELOW_BUNDLE_WIDTHS = 1, MAX_MERGE_PASSES = 4, BEND_DEVIATION_PX = 1.5, CORNER_BEND_DEG = 60, CORNER_RADIUS_LANES = 1.5, CORNER_MIN_TURN_DEG = 60, CORNER_MAX_REACH = 1.5, FOLLOW_ABOVE_LANES = 1, SNAP_HOOK_LANES = 3, LayoutCache = class {
constructor() { constructor() {
__publicField(this, "state", null); __publicField(this, "state", null);
} }
@@ -1815,7 +1816,7 @@ function zoomState(g, zoom, style, smooth, openFolds2, laneStyle) {
e.simplifyRank || (e.simplifyRank = simplifyRank(e.coords)); e.simplifyRank || (e.simplifyRank = simplifyRank(e.coords));
let p = simplifyRanked(e.coords, e.simplifyRank, Math.max(SIMPLIFY_TOLERANCE_PX2, GENERALIZE_PER_OFFSET * widest) / scale); let p = simplifyRanked(e.coords, e.simplifyRank, Math.max(SIMPLIFY_TOLERANCE_PX2, GENERALIZE_PER_OFFSET * widest) / scale);
for (let i = 0; i < p.length; i++) p[i] *= scale; for (let i = 0; i < p.length; i++) p[i] *= scale;
simplePx[e.id] = p, edgeLen[e.id] = polylineLength(p), dirA[e.id] = smooth ? splineStartDirection(p, SMOOTH_SEGMENT_PX, 10, 3, CORNER_BEND_DEG) : startDirection(p), dirB[e.id] = (smooth ? splineEndDirection(p, SMOOTH_SEGMENT_PX, 10, 3, CORNER_BEND_DEG) : endDirection(p)).map((v) => -v); simplePx[e.id] = p, edgeLen[e.id] = polylineLength(p), dirA[e.id] = startDirection(p), dirB[e.id] = endDirection(p).map((v) => -v);
} }
let halfWidth = (e) => (e.routes.length - 1) / 2 * spacing + width / 2 + casing, laneOffsetTravel = (e, r, forward) => { let halfWidth = (e) => (e.routes.length - 1) / 2 * spacing + width / 2 + casing, laneOffsetTravel = (e, r, forward) => {
let off = offsets[e.id * routeCount + routeIndex.get(r)]; let off = offsets[e.id * routeCount + routeIndex.get(r)];
@@ -1972,14 +1973,26 @@ function lookOf(st, e, r) {
let meta = st.graph.routes.get(r), over = st.laneStyle ? st.laneStyle(e, r) : null, color = over?.color || meta?.color || "#888", dash = over?.dash ?? meta?.dash, dashColor = over?.dashColor ?? meta?.dashColor, dashCap = over?.dashCap ?? meta?.dashCap, key = `${color}|${dash ? dash[0] + "," + dash[1] : ""}|${dashColor ?? ""}|${dashCap ?? ""}`, look = st.looks.get(key); let meta = st.graph.routes.get(r), over = st.laneStyle ? st.laneStyle(e, r) : null, color = over?.color || meta?.color || "#888", dash = over?.dash ?? meta?.dash, dashColor = over?.dashColor ?? meta?.dashColor, dashCap = over?.dashCap ?? meta?.dashCap, key = `${color}|${dash ? dash[0] + "," + dash[1] : ""}|${dashColor ?? ""}|${dashCap ?? ""}`, look = st.looks.get(key);
return look || st.looks.set(key, look = { color, dash, dashColor, dashCap }), look; return look || st.looks.set(key, look = { color, dash, dashColor, dashCap }), look;
} }
function widestOffset(st, edge) {
let e = st.graph.edges[edge];
return ((e.routes.length - 1) / 2 + Math.abs(e.baseline ?? 0)) * st.spacing;
}
function bendBudget(st, edges) {
let widest = 0;
for (let edge of edges) widest = Math.max(widest, widestOffset(st, edge));
return Math.max(BEND_DEVIATION_PX, GENERALIZE_PER_OFFSET * widest);
}
function roundedPx(st, p, edges) {
return simplify(roundBends(p, bendBudget(st, edges), 3, CORNER_BEND_DEG, CORNER_RADIUS_LANES * st.spacing), SIMPLIFY_TOLERANCE_PX2);
}
function preparedPx(st, edge) { function preparedPx(st, edge) {
let px = st.preparedPx[edge]; let px = st.preparedPx[edge];
if (!px) { if (!px) {
let simple = st.simplePx[edge]; let simple = st.simplePx[edge];
px = st.smooth ? simplify(smoothCatmullRom(simple, SMOOTH_SEGMENT_PX, 10, 3, CORNER_BEND_DEG, CORNER_RADIUS_LANES * st.spacing), SIMPLIFY_TOLERANCE_PX2) : simple; px = st.smooth ? roundedPx(st, simple, [edge]) : simple;
let e = st.graph.edges[edge]; let e = st.graph.edges[edge];
if (st.openFolds && e.routes.length > 1 && !st.short[edge]) { if (st.openFolds && e.routes.length > 1 && !st.short[edge]) {
let widest = ((e.routes.length - 1) / 2 + Math.abs(e.baseline ?? 0)) * st.spacing; let widest = widestOffset(st, edge);
px = openFolds(px, 2 * widest + st.width + 2 * st.casing, st.frontA[edge] + st.spacing, st.frontB[edge] + st.spacing); px = openFolds(px, 2 * widest + st.width + 2 * st.casing, st.frontA[edge] + st.spacing, st.frontB[edge] + st.spacing);
} }
st.preparedPx[edge] = px; st.preparedPx[edge] = px;
@@ -2043,17 +2056,17 @@ function lanePathOf(st, edge, route) {
}; };
return st.lanePaths[k] = path, path; return st.lanePaths[k] = path, path;
} }
function guideOf(st, parts) { function guideOf(st, parts, edges) {
let out = []; let out = [];
for (let p of parts) for (let p of parts)
for (let i = 0; i < p.length; i += 2) for (let i = 0; i < p.length; i += 2)
out.length && Math.abs(out[out.length - 2] - p[i]) < 1e-6 && Math.abs(out[out.length - 1] - p[i + 1]) < 1e-6 || out.push(p[i], p[i + 1]); out.length && Math.abs(out[out.length - 2] - p[i]) < 1e-6 && Math.abs(out[out.length - 1] - p[i + 1]) < 1e-6 || out.push(p[i], p[i + 1]);
return st.smooth ? simplify(smoothCatmullRom(out, SMOOTH_SEGMENT_PX, 10, 3, CORNER_BEND_DEG, CORNER_RADIUS_LANES * st.spacing), SIMPLIFY_TOLERANCE_PX2) : out; return st.smooth ? roundedPx(st, out, edges) : out;
} }
function resolveTail(st, plan) { function resolveTail(st, plan) {
if (plan.mode) return; if (plan.mode) return;
plan.mode = 2; plan.mode = 2;
let g = st.graph, t = plan.tail, p = plan.port, portLane = laneOf(st, p.edge, t.route), parts = t.edges.map((s) => orientedPx(st, s.edge, s.forward)), far = t.edges[t.side === "end" ? t.edges.length - 1 : 0], farOffset = offsetTravel(st, far.edge, t.route, far.forward), portOffset = offsetTravel(st, p.edge, t.route, t.side === "end" ? p.end === "b" : p.end === "a"), portPx = preparedPx(st, p.edge), portPart = t.side === "end" ? lastPortion(p.end === "b" ? portPx : reversed(portPx), p.end === "b" ? st.frontB[p.edge] : st.frontA[p.edge]) : firstPortion(p.end === "a" ? portPx : reversed(portPx), p.end === "a" ? st.frontA[p.edge] : st.frontB[p.edge]), guide = t.side === "end" ? guideOf(st, [portPart, ...parts]) : guideOf(st, [...parts, portPart]), slide = t.side === "end" ? offsetPolylineSlidingAnchored(guide, portOffset, farOffset) : offsetPolylineSlidingAnchored(guide, farOffset, portOffset); let g = st.graph, t = plan.tail, p = plan.port, portLane = laneOf(st, p.edge, t.route), parts = t.edges.map((s) => orientedPx(st, s.edge, s.forward)), far = t.edges[t.side === "end" ? t.edges.length - 1 : 0], farOffset = offsetTravel(st, far.edge, t.route, far.forward), portOffset = offsetTravel(st, p.edge, t.route, t.side === "end" ? p.end === "b" : p.end === "a"), portPx = preparedPx(st, p.edge), portPart = t.side === "end" ? lastPortion(p.end === "b" ? portPx : reversed(portPx), p.end === "b" ? st.frontB[p.edge] : st.frontA[p.edge]) : firstPortion(p.end === "a" ? portPx : reversed(portPx), p.end === "a" ? st.frontA[p.edge] : st.frontB[p.edge]), edges = [p.edge, ...t.edges.map((s) => s.edge)], guide = t.side === "end" ? guideOf(st, [portPart, ...parts], edges) : guideOf(st, [...parts, portPart], edges), slide = t.side === "end" ? offsetPolylineSlidingAnchored(guide, portOffset, farOffset) : offsetPolylineSlidingAnchored(guide, farOffset, portOffset);
if (slide.points.length < 4) return; if (slide.points.length < 4) return;
let lanePts = t.side === "end" ? p.end === "b" ? portLane.points : reversed(portLane.points) : p.end === "a" ? portLane.points : reversed(portLane.points); let lanePts = t.side === "end" ? p.end === "b" ? portLane.points : reversed(portLane.points) : p.end === "a" ? portLane.points : reversed(portLane.points);
t.side === "end" ? (slide.points[0] = lanePts[lanePts.length - 2], slide.points[1] = lanePts[lanePts.length - 1]) : (slide.points[slide.points.length - 2] = lanePts[0], slide.points[slide.points.length - 1] = lanePts[1]); t.side === "end" ? (slide.points[0] = lanePts[lanePts.length - 2], slide.points[1] = lanePts[lanePts.length - 1]) : (slide.points[slide.points.length - 2] = lanePts[0], slide.points[slide.points.length - 1] = lanePts[1]);
@@ -2075,7 +2088,7 @@ function resolveTail(st, plan) {
} }
function islandPaths(st, isl) { function islandPaths(st, isl) {
if (isl.paths) return isl.paths; if (isl.paths) return isl.paths;
let g = st.graph, first = isl.steps[0], last = isl.steps[isl.steps.length - 1], guide = guideOf(st, isl.steps.map((s) => orientedPx(st, s.edge, s.forward))), d0 = offsetTravel(st, first.edge, isl.route, first.forward), d1 = offsetTravel(st, last.edge, isl.route, last.forward), slide = offsetPolylineSlidingAnchored(guide, d0, d1); let g = st.graph, first = isl.steps[0], last = isl.steps[isl.steps.length - 1], guide = guideOf(st, isl.steps.map((s) => orientedPx(st, s.edge, s.forward)), isl.steps.map((s) => s.edge)), d0 = offsetTravel(st, first.edge, isl.route, first.forward), d1 = offsetTravel(st, last.edge, isl.route, last.forward), slide = offsetPolylineSlidingAnchored(guide, d0, d1);
if (slide.points.length >= 4) { if (slide.points.length >= 4) {
let e = g.edges[first.edge], travel = travelSign(e.direction.get(isl.route)) * (first.forward ? 1 : -1); let e = g.edges[first.edge], travel = travelSign(e.direction.get(isl.route)) * (first.forward ? 1 : -1);
return isl.paths = [{ return isl.paths = [{
@@ -2181,7 +2194,7 @@ function buildGroup(st, grp) {
let g = st.graph, clique = [], ends = /* @__PURE__ */ new Map(), follows = !1; let g = st.graph, clique = [], ends = /* @__PURE__ */ new Map(), follows = !1;
for (let m of grp.members) { for (let m of grp.members) {
if (st.connPaths.set(m.key, null), m.plan) continue; if (st.connPaths.set(m.key, null), m.plan) continue;
let laneU = laneOf(st, m.pu.edge, m.route), laneV = laneOf(st, m.pv.edge, m.route), from = m.pu.end === "b" ? laneU.points : reversed(laneU.points), to = m.pv.end === "a" ? laneV.points : reversed(laneV.points), made = m.via.length ? null : connector(from, to, st.spacing); let laneU = laneOf(st, m.pu.edge, m.route), laneV = laneOf(st, m.pv.edge, m.route), from = m.pu.end === "b" ? laneU.points : reversed(laneU.points), to = m.pv.end === "a" ? laneV.points : reversed(laneV.points), made = m.via.length ? null : connector(from, to, st.spacing, cutDirection(st, m.pu.edge, m.pu.end), cutDirection(st, m.pv.edge, m.pv.end, !0));
ends.set(m, { from, to, made }), made && made.coords.length >= 4 && leavesLine(st, m, made.coords) && (follows = !0); ends.set(m, { from, to, made }), made && made.coords.length >= 4 && leavesLine(st, m, made.coords) && (follows = !0);
} }
for (let m of grp.members) { for (let m of grp.members) {
@@ -2191,7 +2204,7 @@ function buildGroup(st, grp) {
} }
let { from, to, made } = ends.get(m); let { from, to, made } = ends.get(m);
if ((m.via.length || follows) && buildViaConnector(st, m, from, to)) continue; if ((m.via.length || follows) && buildViaConnector(st, m, from, to)) continue;
let curve = made ?? connector(from, to, st.spacing); let curve = made ?? connector(from, to, st.spacing, cutDirection(st, m.pu.edge, m.pu.end), cutDirection(st, m.pv.edge, m.pv.end, !0));
curve.coords.length < 4 || clique.push({ member: m, lateral: m.lateral, own: curve.coords, coords: curve.coords, corner: curve.corner }); curve.coords.length < 4 || clique.push({ member: m, lateral: m.lateral, own: curve.coords, coords: curve.coords, corner: curve.corner });
} }
let arcs = clique.filter((c) => !c.corner); let arcs = clique.filter((c) => !c.corner);
@@ -2214,6 +2227,14 @@ function buildGroup(st, grp) {
}); });
} }
} }
function cutDirection(st, edge, end, leaving = !1) {
let front = end === "b" ? st.frontB[edge] : st.frontA[edge];
if (front <= 0) return null;
let px = preparedPx(st, edge), before = trimPolyline(end === "b" ? px : reversed(px), 0, front);
if (before.length < 4) return null;
let d = endDirectionOver(before, st.spacing / 2);
return d[0] === 0 && d[1] === 0 ? null : leaving ? [-d[0], -d[1]] : d;
}
function leavesLine(st, m, coords) { function leavesLine(st, m, coords) {
let uPx = preparedPx(st, m.pu.edge), vPx = preparedPx(st, m.pv.edge), line = lastPortion(m.pu.end === "b" ? uPx : reversed(uPx), m.pu.end === "b" ? st.frontB[m.pu.edge] : st.frontA[m.pu.edge]).concat(firstPortion(m.pv.end === "a" ? vPx : reversed(vPx), m.pv.end === "a" ? st.frontA[m.pv.edge] : st.frontB[m.pv.edge])), limit = Math.max(Math.abs(m.lateral), Math.abs(m.lateralOut)) + FOLLOW_ABOVE_LANES * st.spacing; let uPx = preparedPx(st, m.pu.edge), vPx = preparedPx(st, m.pv.edge), line = lastPortion(m.pu.end === "b" ? uPx : reversed(uPx), m.pu.end === "b" ? st.frontB[m.pu.edge] : st.frontA[m.pu.edge]).concat(firstPortion(m.pv.end === "a" ? vPx : reversed(vPx), m.pv.end === "a" ? st.frontA[m.pv.edge] : st.frontB[m.pv.edge])), limit = Math.max(Math.abs(m.lateral), Math.abs(m.lateralOut)) + FOLLOW_ABOVE_LANES * st.spacing;
for (let i = 0; i < coords.length; i += 2) { for (let i = 0; i < coords.length; i += 2) {
@@ -2265,7 +2286,7 @@ function buildViaConnector(st, m, from, to) {
} }
for (let k = 0; k < knots.length; k += 2) knots[k + 1] = straight(knots[k]) + (knots[k + 1] - straight(knots[k])) * share; for (let k = 0; k < knots.length; k += 2) knots[k + 1] = straight(knots[k]) + (knots[k + 1] - straight(knots[k])) * share;
} }
let guide = st.smooth ? simplify(smoothCatmullRom(centerline, SMOOTH_SEGMENT_PX, 10, 3, CORNER_BEND_DEG, CORNER_RADIUS_LANES * st.spacing), SIMPLIFY_TOLERANCE_PX2) : centerline, slide = offsetPolylineSlidingAnchored(guide, m.lateral, m.lateralOut, 4, knots); let guide = st.smooth ? roundedPx(st, centerline, [m.pu.edge, m.pv.edge, ...m.via.map((s) => s.edge)]) : centerline, slide = offsetPolylineSlidingAnchored(guide, m.lateral, m.lateralOut, 4, knots);
if (slide.points.length < 4) return !1; if (slide.points.length < 4) return !1;
slide.points[0] = from[from.length - 2], slide.points[1] = from[from.length - 1], slide.points[slide.points.length - 2] = to[0], slide.points[slide.points.length - 1] = to[1]; slide.points[0] = from[from.length - 2], slide.points[1] = from[from.length - 1], slide.points[slide.points.length - 2] = to[0], slide.points[slide.points.length - 1] = to[1];
let { points: coords, anchors } = removeLoopsAnchored(slide.points, slide.anchors, SNAP_HOOK_LANES * st.spacing); let { points: coords, anchors } = removeLoopsAnchored(slide.points, slide.anchors, SNAP_HOOK_LANES * st.spacing);
@@ -2477,8 +2498,8 @@ function signedTurning(p) {
} }
return total; return total;
} }
function connector(from, to, spacing) { function connector(from, to, spacing, tpAt = null, tqAt = null) {
let P = [from[from.length - 2], from[from.length - 1]], Q = [to[0], to[1]], tp = endDirection(from), tqIn = startDirection(to), tq = [-tqIn[0], -tqIn[1]], chord = Math.hypot(Q[0] - P[0], Q[1] - P[1]); let P = [from[from.length - 2], from[from.length - 1]], Q = [to[0], to[1]], tp = tpAt ?? endDirectionOver(from, spacing / 2), tqIn = tqAt ?? startDirectionOver(to, spacing / 2), tq = [-tqIn[0], -tqIn[1]], chord = Math.hypot(Q[0] - P[0], Q[1] - P[1]);
if (chord < 1e-6) return { coords: [], corner: !1 }; if (chord < 1e-6) return { coords: [], corner: !1 };
if (Math.abs((Q[0] - P[0]) * tp[1] - (Q[1] - P[1]) * tp[0]) < 0.05 && tp[0] * tqIn[0] + tp[1] * tqIn[1] > 0.9999) return { coords: [P[0], P[1], Q[0], Q[1]], corner: !1 }; if (Math.abs((Q[0] - P[0]) * tp[1] - (Q[1] - P[1]) * tp[0]) < 0.05 && tp[0] * tqIn[0] + tp[1] * tqIn[1] > 0.9999) return { coords: [P[0], P[1], Q[0], Q[1]], corner: !1 };
let corner = cornerTurn(P, tp, Q, tq, chord, spacing); let corner = cornerTurn(P, tp, Q, tq, chord, spacing);