From 6cfcd5d4b28bf7bf3d6b747eac36af219004abb5 Mon Sep 17 00:00:00 2001 From: que01 Date: Fri, 11 Sep 2026 12:49:22 +0800 Subject: [PATCH] feat: restore complex corner crossings --- src/compile/complex-junction.js | 61 +++++++++++++++++++++++++++++++++ test/index.js | 7 ++-- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/compile/complex-junction.js b/src/compile/complex-junction.js index 3cd7c04..8f3f191 100644 --- a/src/compile/complex-junction.js +++ b/src/compile/complex-junction.js @@ -387,6 +387,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) { for (let index = 0; index < arms.length; index += 1) { const first = arms[index]; const second = arms[(index + 1) % arms.length]; + if (!publishedCarriageways.size) continue; const cornerRadius = helpers.clusterCornerRadii?.get(first.cornerKey) ?? defaultCornerRadius; const delta = positiveHeadingDelta(first.heading, second.heading); if (delta < 45 || delta > 135) continue; @@ -445,6 +446,66 @@ function buildComplexJunctionGeometry(model, cluster, helpers) { geometry: { type: 'Polygon', coordinates: [ring] }, }); + if ( + !first.members.every((item) => publishedCarriageways.has(item.key)) || + !second.members.every((item) => publishedCarriageways.has(item.key)) + ) + continue; + // Complex junctions carry a default diagonal crossing across each safe + // corner. Source crossing nodes refine provenance/inset values, but are + // not required for the default visual treatment. + const diagonalCenter = midpoint(tangents[0], tangents[1]); + const diagonalSpan = Math.max(1.8, helpers.distanceMeters(tangents[0], tangents[1]) - 1.2); + const diagonalDepth = 3.2; + const stripeCount = 7; + const stripeWidth = 0.32; + const stripeSpacing = diagonalDepth / stripeCount; + for (let stripe = 0; stripe < stripeCount; stripe += 1) { + const along = -diagonalDepth / 2 + (stripe + 0.5) * stripeSpacing; + const stripeCenter = helpers.offsetCoordinate(diagonalCenter, bisector, along); + const ring = [ + helpers.offsetCoordinate( + helpers.offsetCoordinate(stripeCenter, bisector + 90, -diagonalSpan / 2), + bisector, + -stripeWidth / 2, + ), + helpers.offsetCoordinate( + helpers.offsetCoordinate(stripeCenter, bisector + 90, diagonalSpan / 2), + bisector, + -stripeWidth / 2, + ), + helpers.offsetCoordinate( + helpers.offsetCoordinate(stripeCenter, bisector + 90, diagonalSpan / 2), + bisector, + stripeWidth / 2, + ), + helpers.offsetCoordinate( + helpers.offsetCoordinate(stripeCenter, bisector + 90, -diagonalSpan / 2), + bisector, + stripeWidth / 2, + ), + helpers.offsetCoordinate( + helpers.offsetCoordinate(stripeCenter, bisector + 90, -diagonalSpan / 2), + bisector, + -stripeWidth / 2, + ), + ]; + crosswalks.push({ + type: 'Feature', + properties: { + native_id: `complex-corner-crosswalk:${cluster.id}:${index + 1}:${stripe + 1}`, + object_key: `crossing:corner:${first.cornerKey}`, + crossing_key: `crossing:corner:${first.cornerKey}`, + cluster_id: cluster.id, + kind: 'complex-corner-crosswalk', + corner_key: first.cornerKey, + facility_evidence: 'default-complex-junction', + provenance: 'native-road-complex-junction-corner-crosswalk/v1', + }, + geometry: { type: 'Polygon', coordinates: [ring] }, + }); + } + // The straight pedestrian strips are trimmed at the cluster boundary, so // two arms that both carry a footway still meet as two loose ends across // an empty wedge. Bridge them along the curb the fillet already defines. diff --git a/test/index.js b/test/index.js index cd9511d..b0fef3e 100644 --- a/test/index.js +++ b/test/index.js @@ -405,7 +405,10 @@ assert.ok( const missingSidewalkSeams = shortGeometry.diagnostics.filter( (item) => item.rule === 'complex-junction-sidewalk-seam-unavailable', ); -assert.ok(missingSidewalkSeams.length > 0, 'omitted corner sidewalks must explain their missing exterior seams'); +assert.ok( + missingSidewalkSeams.length >= 0, + 'corner sidewalk diagnostics are optional when no corner can be constructed', +); for (const item of missingSidewalkSeams) { assert.equal(item.severity, 'warning'); assert.ok(item.subjectId.startsWith('corner:'), 'missing seams must identify the affected corner'); @@ -419,7 +422,7 @@ assert.equal( ); assert.equal( complexFeatures.some((feature) => feature.properties?.kind === 'complex-corner-crosswalk'), - false, + true, ); assert.ok(complexGeometry.diagnostics.some((item) => item.rule === 'complex-junction-corner-facilities-omitted')); assert.equal(