From c3579074fd654fa218fd2dad73fba8e3721a32b5 Mon Sep 17 00:00:00 2001 From: que01 Date: Tue, 15 Sep 2026 13:53:31 +0800 Subject: [PATCH] fix: keep complex islands beyond outer lane edge --- src/compile/complex-junction.js | 2 +- src/compile/junction-facility-composition.js | 5 ++++- test/junction-facility-composition.js | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/compile/complex-junction.js b/src/compile/complex-junction.js index 1968729..ff5f04c 100644 --- a/src/compile/complex-junction.js +++ b/src/compile/complex-junction.js @@ -547,7 +547,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) { landing(first, pair.a), landing(second, pair.b), COMPLEX_CROSSWALK_DEPTH_METERS, - { maxLegLength: outerRadius }, + { maxLegLength: outerRadius, minLegLength: Math.max(outerRadius - coreRadius, COMPLEX_CROSSWALK_DEPTH_METERS) }, ); if (contactSolution.status !== 'solved') { cornerDiagnostics.push( diff --git a/src/compile/junction-facility-composition.js b/src/compile/junction-facility-composition.js index ca0719c..63789c5 100644 --- a/src/compile/junction-facility-composition.js +++ b/src/compile/junction-facility-composition.js @@ -145,7 +145,10 @@ function solveIslandContacts(firstSegment, secondSegment, thirdWidth, options = const tangent = unit(chord); // This scale leaves positive connectors on both sides even for unequal depths. const scale = 1 + thirdWidth / chordLength; - const legLengths = [a * scale, b * scale]; + const baseLegLengths = [a * scale, b * scale]; + const minimumLegLength = Number.isFinite(options.minLegLength) ? Math.max(0, options.minLegLength) : 0; + const legScale = Math.max(1, minimumLegLength / Math.max(...baseLegLengths)); + const legLengths = baseLegLengths.map((value) => value * legScale); if ( options.maxLegLength !== undefined && (!Number.isFinite(options.maxLegLength) || legLengths.some((value) => value > options.maxLegLength)) diff --git a/test/junction-facility-composition.js b/test/junction-facility-composition.js index c820ab0..bf34317 100644 --- a/test/junction-facility-composition.js +++ b/test/junction-facility-composition.js @@ -151,6 +151,20 @@ assert.equal(solvedContacts.contacts.length, 3); assert.equal(solvedContacts.greenRing.length, 7); assert.equal(solvedContacts.legLengths.length, 2); assert.ok(solvedContacts.legLengths.every((value) => value > 5.1)); +const extendedContacts = solveIslandContacts( + [ + [0, 1.7], + [0, 5.1], + ], + [ + [-1.7, 0], + [-5.1, 0], + ], + 3.4, + { maxLegLength: 20, minLegLength: 9 }, +); +assert.equal(extendedContacts.status, 'solved'); +assert.ok(extendedContacts.legLengths.every((value) => value >= 9)); assert.equal(new Set(solvedContacts.greenRing.slice(0, -1).map((p) => p.join(','))).size, 6);