From a90826efedb1dc62ec885501be5b374d281c5414 Mon Sep 17 00:00:00 2001 From: que01 Date: Wed, 9 Sep 2026 14:04:17 +0800 Subject: [PATCH] test(junction): reject zero-area approach surfaces --- test/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/index.js b/test/index.js index 4c870bd..10e19d0 100644 --- a/test/index.js +++ b/test/index.js @@ -138,6 +138,12 @@ for (const feature of complexApproachFeatures) { const ring = feature.geometry?.coordinates?.[0] || []; assert.ok(ring.length >= 4 && ring[0][0] === ring.at(-1)[0] && ring[0][1] === ring.at(-1)[1]); assert.ok(ring.every((coordinate) => coordinate.every(Number.isFinite))); + const area = Math.abs( + ring + .slice(1) + .reduce((sum, coordinate, index) => sum + ring[index][0] * coordinate[1] - coordinate[0] * ring[index][1], 0) / 2, + ); + assert.ok(area > 0, 'compiled complex approach surface must have positive area'); } const complexFeatures = Object.values(complexGeometry).flatMap((layer) => layer?.features || []); assert.equal(