diff --git a/test/junction-build-plan-counterexamples.js b/test/junction-build-plan-counterexamples.js index 1834db8..593c0f7 100644 --- a/test/junction-build-plan-counterexamples.js +++ b/test/junction-build-plan-counterexamples.js @@ -384,3 +384,33 @@ assert.deepEqual( 'arm identity must remain stable across the -180/180 heading wrap', ); assert.equal(wrappedTopology.arms.length, sixArm.topology.arms.length); + +const translate = (coordinate, eastMeters, northMeters) => + point(coordinate[0] * metersPerDegree + eastMeters, coordinate[1] * metersPerDegree + northMeters); +const translatedEntries = sixArmEntries.map((entry) => ({ + ...entry, + line: entry.line.map((coordinate) => translate(coordinate, 120, -75)), +})); +const translatedBase = fixture('six-arm', translatedEntries); +translatedBase.helpers.junctionPlans.set('six-arm:node', { + node: translate(point(0, 0), 120, -75), + approaches: translatedBase.helpers.junctionPlans.get('six-arm:node').approaches, +}); +translatedBase.helpers.junctionPlans.set('six-arm:internal', { + node: translate(point(1, 1), 120, -75), + approaches: [], +}); +const translatedTopology = resolveJunctionBuildPlan( + translatedBase.model, + translatedBase.cluster, + translatedBase.helpers, +); +assert.deepEqual( + translatedTopology.arms.map((arm) => arm.key).sort(), + sixArm.topology.arms.map((arm) => arm.key).sort(), + 'translation must not change arm identity', +); +assert.deepEqual( + translatedTopology.carriageways.map((item) => item.entrySection.feasibility), + sixArm.topology.carriageways.map((item) => item.entrySection.feasibility), +);