feat: establish junction region geometry baseline

This commit is contained in:
que01 committed 2026-09-11 15:27:53 +08:00
1 parent de97600fe8
commit 76f81d024a
14 files changed
+287 -11

No files matched your search

@@ -36,6 +36,16 @@ junction-structure/v1 保持前端投影,按需扩展展示字段;不在客
仅根据夹角不能证明存在导流岛或独立右转道路。已知设施使用显式来源/区域;推断对象标明推断原因,缺少通行区域或步行端点证据时不输出伪造有效设施。未知与不存在分开表达。本期不提供岛体自由编辑器,但 BoundaryGraph 可表达其排除区域与相邻通道,避免下一期推翻基础模型。 仅根据夹角不能证明存在导流岛或独立右转道路。已知设施使用显式来源/区域;推断对象标明推断原因,缺少通行区域或步行端点证据时不输出伪造有效设施。未知与不存在分开表达。本期不提供岛体自由编辑器,但 BoundaryGraph 可表达其排除区域与相邻通道,避免下一期推翻基础模型。
## 设施语义契约
复杂路口中的行人安全岛不是独立的固定角部多边形。它是三组过街连接之间的不可通行区域:一条进口斑马线和相邻两个角部斑马线共同限定其边界。`CrosswalkConnection` 必须连接两个有效步行边界;其内侧端点吸附到 `PedestrianIsland` 或路缘边界,不能悬空或穿过岛体。
- `PedestrianIsland`:独立的不可通行区域,有连续路缘边界,可作为分阶段过街等待空间。
- `CrosswalkConnection`:连接人行道、路缘或安全岛的过街区域;斑马线不是道路装饰层。
- `CurbBoundary`:机动车通行区与步行区域的共享边界,安全岛和斑马线都消费同一边界。
- `CurbExtension` 与 `PedestrianIsland` 分开建模;前者是人行道向车行道的扩展,后者位于机动车流之间。
- 复杂路口设施的求解顺序为:机动车区域 → 步行边界 → 三组过街连接 → 安全岛可行区域 → 端点吸附和冲突验证。
## 兼容、性能与风险 ## 兼容、性能与风险
- 新管线先在显式 geometry version 下验证;旧复杂文档不能直接换默认值或静默裁剪。缺省构建应确定性;迁移报告逐约束列出可重放、需重检、失效及原因。普通路口输出回归保持不变。 - 新管线先在显式 geometry version 下验证;旧复杂文档不能直接换默认值或静默裁剪。缺省构建应确定性;迁移报告逐约束列出可重放、需重检、失效及原因。普通路口输出回归保持不变。
@@ -1,6 +1,6 @@
# 实施计划与阶段出口 # 实施计划与阶段出口
当前为 in_progress;用户已批准实施。单一任务按串行里程碑交付;每阶段必须提交证据,不能以接口有返回代替效果验收。 当前为 in_progress;任务已收敛为分阶段推进。第一个新阶段是“复杂路口区域模型”:先统一中心通行区、角部可行域和安全岛边界,再恢复设施与视觉验收。实验性固定安全岛修改已保存至 `/private/tmp/junction-island-experiment.patch`,不作为正式方案。
## 0. 契约与最小反例 ## 0. 契约与最小反例
@@ -0,0 +1,38 @@
# Geometry Library Evaluation
日期:2026-09-11
## 结论
首选 `polygon-clipping`(MIT)作为局部米制平面区域布尔运算库,配合项目已有的 `rbush` 空间索引。保留现有 `JunctionBuildPlan` 和 `BoundaryGraph` 作为来源拓扑与共享边界权威,不引入通用图框架替代道路来源身份。
## 候选比较
| 库 | 适合能力 | 主要问题 | 决策 |
| --- | --- | --- | --- |
| `polygon-clipping` | union/intersection/difference/xor;Polygon/MultiPolygon;适合中心区域、排除区、安全岛可行域 | 不负责道路语义、单位和拓扑来源 | 首选补充 |
| `@turf/*` | buffer、lineOffset、空间关系和地理验证;可按模块引入 | 完整包较重;经纬度计算不应成为内部几何权威 | 作为可选验证/偏移工具 |
| `JSTS` | 较完整的 GEOS/JTS 类几何算法 | 包体、API 和维护复杂度偏高 | 后备方案 |
| `clipper2-js` | 高精度平面裁切和偏移 | 当前运行时与维护兼容性需额外验证 | 暂不采用 |
| `graphlib/graphology` | 通用图遍历 | 不解决几何边界,不能替代 OSM 来源拓扑 | 不采用 |
## 目标数据流
```text
JunctionBuildPlan
-> BoundaryGraph(来源边、共享边、排除区)
-> polygon-clipping(区域 union/intersection/difference)
-> CornerFeasibleRegion
-> IslandRegion
-> CrossingRegion
-> 统一连通/自交/重叠/接缝验证
```
局部米制投影、稳定来源键、编辑约束和 GeoJSON 输出仍由项目代码负责。第三方库只接受已经投影到局部平面坐标的环,并返回经过规范化的区域结果;不得让布尔运算输出顺序决定来源身份。
## 引入前验证
- 在独立纯函数测试中验证凹形、孔洞、相切、重叠和多区域结果。
- 验证许可证、Node CommonJS、Vite 浏览器构建和包体影响。
- 先替换 `ringsOverlap` 等局部几何判断,再接入中心区域求解;不先改编辑协议或 UI。
- 如果库无法稳定保留共享边引用,则只用于可行域裁切,BoundaryGraph 仍保留边界所有权和接缝计算。
+26
View File
@@ -11,6 +11,7 @@
"fflate": "0.8.3", "fflate": "0.8.3",
"lucide-react": "^0.468.0", "lucide-react": "^0.468.0",
"ol": "10.10.0", "ol": "10.10.0",
"polygon-clipping": "^0.15.7",
"react": "^19.1.0", "react": "^19.1.0",
"react-dom": "^19.1.0" "react-dom": "^19.1.0"
}, },
@@ -1388,6 +1389,16 @@
"node": "^8.16.0 || ^10.6.0 || >=11.0.0" "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
} }
}, },
"node_modules/polygon-clipping": {
"version": "0.15.7",
"resolved": "http://172.16.1.86:4873/polygon-clipping/-/polygon-clipping-0.15.7.tgz",
"integrity": "sha512-nhfdr83ECBg6xtqOAJab1tbksbBAOMUltN60bU+llHVOL0e5Onm1WpAXXWXVB39L8AJFssoIhEVuy/S90MmotA==",
"license": "MIT",
"dependencies": {
"robust-predicates": "^3.0.2",
"splaytree": "^3.1.0"
}
},
"node_modules/postcss": { "node_modules/postcss": {
"version": "8.5.26", "version": "8.5.26",
"resolved": "http://172.16.1.86:4873/postcss/-/postcss-8.5.26.tgz", "resolved": "http://172.16.1.86:4873/postcss/-/postcss-8.5.26.tgz",
@@ -1502,6 +1513,12 @@
"protocol-buffers-schema": "^3.3.1" "protocol-buffers-schema": "^3.3.1"
} }
}, },
"node_modules/robust-predicates": {
"version": "3.0.3",
"resolved": "http://172.16.1.86:4873/robust-predicates/-/robust-predicates-3.0.3.tgz",
"integrity": "sha512-NS3levdsRIUOmiJ8FZWCP7LG3QpJyrs/TE0Zpf1yvZu8cAJJ6QMW92H1c7kWpdIHo8RvmLxN/o2JXTKHp74lUA==",
"license": "Unlicense"
},
"node_modules/rollup": { "node_modules/rollup": {
"version": "4.63.0", "version": "4.63.0",
"resolved": "http://172.16.1.86:4873/rollup/-/rollup-4.63.0.tgz", "resolved": "http://172.16.1.86:4873/rollup/-/rollup-4.63.0.tgz",
@@ -1571,6 +1588,15 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/splaytree": {
"version": "3.2.3",
"resolved": "http://172.16.1.86:4873/splaytree/-/splaytree-3.2.3.tgz",
"integrity": "sha512-7OXrNWzy6CK+r7Ch9OLPBDTKfB6XlWHjX4P0RU5B3IgFuWPeYN0XtRtlexGRjgbQxpfaUve6jTAwBGWuGntz/w==",
"license": "MIT",
"engines": {
"node": ">=18.20 || >=20"
}
},
"node_modules/stackback": { "node_modules/stackback": {
"version": "0.0.2", "version": "0.0.2",
"resolved": "http://172.16.1.86:4873/stackback/-/stackback-0.0.2.tgz", "resolved": "http://172.16.1.86:4873/stackback/-/stackback-0.0.2.tgz",
+2 -1
View File
@@ -8,7 +8,7 @@
"road-compiler": "bin/road-compiler.js" "road-compiler": "bin/road-compiler.js"
}, },
"scripts": { "scripts": {
"test": "node test/index.js && node test/junction-structure.js && node test/junction-projection.js && node test/junction-build-plan-counterexamples.js && node test/native-road-edits.js && node test/road-revisions.js && node test/direct-edit-solver.js && node test/workbench-edit-api.js && node test/workbench-import-compile.js && node test/fixtures.js", "test": "node test/index.js && node test/junction-structure.js && node test/junction-projection.js && node test/junction-build-plan-counterexamples.js && node test/junction-polygon-ops.js && node test/junction-region-solver.js && node test/junction-facility-composition.js && node test/native-road-edits.js && node test/road-revisions.js && node test/direct-edit-solver.js && node test/workbench-edit-api.js && node test/workbench-import-compile.js && node test/fixtures.js",
"test:fixtures:update-baseline": "node test/update-fixture-baselines.js", "test:fixtures:update-baseline": "node test/update-fixture-baselines.js",
"road:workbench": "node bin/road-workbench.js", "road:workbench": "node bin/road-workbench.js",
"road:export": "node bin/road-compiler.js", "road:export": "node bin/road-compiler.js",
@@ -24,6 +24,7 @@
"fflate": "0.8.3", "fflate": "0.8.3",
"lucide-react": "^0.468.0", "lucide-react": "^0.468.0",
"ol": "10.10.0", "ol": "10.10.0",
"polygon-clipping": "^0.15.7",
"react": "^19.1.0", "react": "^19.1.0",
"react-dom": "^19.1.0" "react-dom": "^19.1.0"
}, },
+39 -9
View File
@@ -4,6 +4,7 @@ const fs = require('fs');
const { structureFromTopology } = require('./junction-topology'); const { structureFromTopology } = require('./junction-topology');
const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('./junction-build-plan'); const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('./junction-build-plan');
const { buildJunctionBoundaryGraph, buildCoreClosure, ringsOverlap } = require('./junction-boundary-graph'); const { buildJunctionBoundaryGraph, buildCoreClosure, ringsOverlap } = require('./junction-boundary-graph');
const { solveCornerFeasibleRegion } = require('./junction-region-solver');
const { complexJunctionMetrics: calculateComplexJunctionMetrics } = require('./junction-metrics'); const { complexJunctionMetrics: calculateComplexJunctionMetrics } = require('./junction-metrics');
const { convertGeoJson, boundsOf } = require('../reference/gaode'); const { convertGeoJson, boundsOf } = require('../reference/gaode');
const metricsCache = new WeakMap(); const metricsCache = new WeakMap();
@@ -349,6 +350,8 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
// sharp notch instead of a curb. A real corner is one tangent-continuous // sharp notch instead of a curb. A real corner is one tangent-continuous
// sweep between the two outermost road edges, so fit a fixed-radius fillet // sweep between the two outermost road edges, so fit a fixed-radius fillet
// into the wedge those edges form and fill the sector behind it. // into the wedge those edges form and fill the sector behind it.
const coreClosure = buildCoreClosure(topology, boundaryGraph, center);
const coreRing = coreClosure.status === 'supported' ? coreClosure.ring : null;
const cornerFills = []; const cornerFills = [];
const sidewalkCorners = []; const sidewalkCorners = [];
const cornerDiagnostics = []; const cornerDiagnostics = [];
@@ -445,12 +448,29 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
}, },
geometry: { type: 'Polygon', coordinates: [ring] }, geometry: { type: 'Polygon', coordinates: [ring] },
}); });
const islandRadius = 3.5; const islandDepth = Math.min(7, Math.max(3, apexReach * 0.35));
const islandCenter = helpers.offsetCoordinate(apex, bisector, Math.min(3.5, Math.max(1.5, apexReach * 0.2))); const islandHalfWidth = Math.min(
const islandRing = [0, 90, 180, 270, 360].map((angle) => 2.2,
helpers.offsetCoordinate(islandCenter, bisector + angle, islandRadius), Math.max(1.2, Math.min(first.widthMeters || 4, second.widthMeters || 4) * 0.28),
); );
if (!cornerOverlapsExclusion(islandRing, first.cornerKey, '安全岛')) const islandCenter = helpers.offsetCoordinate(apex, bisector, -islandDepth * 0.5);
const islandRing = [
helpers.offsetCoordinate(helpers.offsetCoordinate(apex, bisector, 0.6), bisector + 90, -islandHalfWidth),
helpers.offsetCoordinate(
helpers.offsetCoordinate(islandCenter, bisector, islandDepth * 0.5),
bisector + 90,
-islandHalfWidth * 0.72,
),
helpers.offsetCoordinate(
helpers.offsetCoordinate(islandCenter, bisector, islandDepth * 0.5),
bisector + 90,
islandHalfWidth * 0.72,
),
helpers.offsetCoordinate(helpers.offsetCoordinate(apex, bisector, 0.6), bisector + 90, islandHalfWidth),
helpers.offsetCoordinate(helpers.offsetCoordinate(apex, bisector, 0.6), bisector + 90, -islandHalfWidth),
];
const publishedIslandRing = islandRing;
if (!cornerOverlapsExclusion(publishedIslandRing, first.cornerKey, '安全岛'))
islands.push({ islands.push({
type: 'Feature', type: 'Feature',
properties: { properties: {
@@ -462,7 +482,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
facility_evidence: 'inferred-complex-junction-corner', facility_evidence: 'inferred-complex-junction-corner',
provenance: 'native-road-complex-junction-inferred-island/v1', provenance: 'native-road-complex-junction-inferred-island/v1',
}, },
geometry: { type: 'Polygon', coordinates: [islandRing] }, geometry: { type: 'Polygon', coordinates: [publishedIslandRing] },
}); });
if ( if (
@@ -473,7 +493,16 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
// Complex junctions carry a default diagonal crossing across each safe // Complex junctions carry a default diagonal crossing across each safe
// corner. Source crossing nodes refine provenance/inset values, but are // corner. Source crossing nodes refine provenance/inset values, but are
// not required for the default visual treatment. // not required for the default visual treatment.
const diagonalCenter = helpers.offsetCoordinate(apex, bisector, Math.min(5, Math.max(1.5, apexReach * 0.28))); const islandMidpoint = publishedIslandRing
.slice(0, -1)
.reduce(
(sum, point) => [
sum[0] + point[0] / (publishedIslandRing.length - 1),
sum[1] + point[1] / (publishedIslandRing.length - 1),
],
[0, 0],
);
const diagonalCenter = helpers.offsetCoordinate(islandMidpoint, bisector, islandHalfWidth + 1.2);
const diagonalSpan = Math.min(6, Math.max(2.4, helpers.distanceMeters(tangents[0], tangents[1]) * 0.35)); const diagonalSpan = Math.min(6, Math.max(2.4, helpers.distanceMeters(tangents[0], tangents[1]) * 0.35));
const diagonalDepth = 2.4; const diagonalDepth = 2.4;
const stripeCount = 7; const stripeCount = 7;
@@ -515,6 +544,9 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
native_id: `complex-corner-crosswalk:${cluster.id}:${index + 1}:${stripe + 1}`, native_id: `complex-corner-crosswalk:${cluster.id}:${index + 1}:${stripe + 1}`,
object_key: `crossing:corner:${first.cornerKey}`, object_key: `crossing:corner:${first.cornerKey}`,
crossing_key: `crossing:corner:${first.cornerKey}`, crossing_key: `crossing:corner:${first.cornerKey}`,
island_key: `island:inferred/${first.cornerKey}`,
from_boundary: `sidewalk:${first.cornerKey}:from`,
to_boundary: `island:inferred/${first.cornerKey}`,
cluster_id: cluster.id, cluster_id: cluster.id,
kind: 'complex-corner-crosswalk', kind: 'complex-corner-crosswalk',
corner_key: first.cornerKey, corner_key: first.cornerKey,
@@ -583,8 +615,6 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
geometry: { type: 'Polygon', coordinates: [sidewalkRing] }, geometry: { type: 'Polygon', coordinates: [sidewalkRing] },
}); });
} }
const coreClosure = buildCoreClosure(topology, boundaryGraph, center);
const coreRing = coreClosure.status === 'supported' ? coreClosure.ring : null;
const features = []; const features = [];
let coreFeature = null; let coreFeature = null;
if (coreRing) if (coreRing)
+7
View File
@@ -1,5 +1,7 @@
'use strict'; 'use strict';
const { solvePavedRegion } = require('./junction-region-solver');
const { stationAtDistanceFrom } = require('./junction-build-plan'); const { stationAtDistanceFrom } = require('./junction-build-plan');
function pointAtStation(line, station, helpers) { function pointAtStation(line, station, helpers) {
@@ -252,6 +254,11 @@ function buildCoreClosure(topology, graph, center) {
Math.atan2(second.point[1] - center[1], second.point[0] - center[0]), Math.atan2(second.point[1] - center[1], second.point[0] - center[0]),
); );
const ring = [...points.map((item) => item.point), points[0]?.point].filter(Boolean); const ring = [...points.map((item) => item.point), points[0]?.point].filter(Boolean);
const pavedRegion = solvePavedRegion(
ring,
graph.exclusionRegions.filter((region) => !region.isHole).map((region) => region.ring),
);
if (!pavedRegion.length) return { status: 'unsupported', reason: 'known-exclusion-region' };
const hasZeroLengthEdge = ring.slice(1).some((point, index) => { const hasZeroLengthEdge = ring.slice(1).some((point, index) => {
const previous = ring[index]; const previous = ring[index];
const dx = point[0] - previous[0]; const dx = point[0] - previous[0];
@@ -0,0 +1,20 @@
'use strict';
function buildPedestrianIsland({ key, ring, crossingKeys, provenance = 'inferred' }) {
if (!key || !Array.isArray(ring) || ring.length < 4) return null;
const adjacentCrossings = [...new Set(crossingKeys || [])];
if (adjacentCrossings.length !== 3) return null;
return { key, ring, adjacentCrossings, provenance };
}
function validateFacilityComposition(island, crossings) {
if (!island || island.adjacentCrossings.length !== 3) return { valid: false, reason: 'island-needs-three-crossings' };
const crossingMap = new Map((crossings || []).map((crossing) => [crossing.key, crossing]));
const linked = island.adjacentCrossings.map((key) => crossingMap.get(key));
if (linked.some((crossing) => !crossing)) return { valid: false, reason: 'crossing-reference-missing' };
if (linked.some((crossing) => !crossing.fromBoundary || !crossing.toBoundary))
return { valid: false, reason: 'crossing-boundary-missing' };
return { valid: true, reason: null };
}
module.exports = { buildPedestrianIsland, validateFacilityComposition };
+50
View File
@@ -0,0 +1,50 @@
'use strict';
const polygonClipping = require('polygon-clipping');
function normalizeRing(ring) {
if (!Array.isArray(ring) || ring.length < 4) return null;
const normalized = ring
.filter((point) => Array.isArray(point) && point.length >= 2 && point.every(Number.isFinite))
.map(([x, y]) => [x, y]);
if (normalized.length < 3) return null;
const first = normalized[0];
const last = normalized.at(-1);
if (first[0] !== last[0] || first[1] !== last[1]) normalized.push([...first]);
return normalized.length >= 4 ? normalized : null;
}
function normalizeMultiPolygon(value) {
if (!Array.isArray(value)) return [];
if (value[0]?.[0]?.every?.((item) => Number.isFinite(item))) value = [value];
return value.map((polygon) => polygon.map(normalizeRing).filter(Boolean)).filter((polygon) => polygon.length > 0);
}
function difference(subject, ...clips) {
const source = normalizeMultiPolygon(subject);
const masks = clips.flatMap(normalizeMultiPolygon);
if (!source.length) return [];
return masks.length ? polygonClipping.difference(source, ...masks) : source;
}
function asMultiPolygon(value) {
return normalizeMultiPolygon(value);
}
function intersection(first, second) {
const left = normalizeMultiPolygon(first);
const right = normalizeMultiPolygon(second);
return left.length && right.length ? polygonClipping.intersection(left, right) : [];
}
function union(...values) {
const polygons = values.flatMap(normalizeMultiPolygon);
return polygons.length ? polygonClipping.union(...polygons) : [];
}
function intersectsOrTouches(first, second, touches) {
if (intersection(first, second).length) return true;
return touches ? touches(first, second) : false;
}
module.exports = { difference, intersection, union, normalizeMultiPolygon, asMultiPolygon, intersectsOrTouches };
+19
View File
@@ -0,0 +1,19 @@
'use strict';
const { difference, asMultiPolygon } = require('./junction-polygon-ops');
function solvePavedRegion(boundaryRing, exclusionRings = []) {
const subject = asMultiPolygon([[boundaryRing]]);
const exclusions = exclusionRings
.filter((ring) => Array.isArray(ring))
.map((ring) => asMultiPolygon([[ring]]))
.filter((value) => value.length);
return difference(subject, ...exclusions);
}
function solveCornerFeasibleRegion(cornerRing, pavedRing, exclusionRings = []) {
const masks = [pavedRing, ...exclusionRings].filter((ring) => Array.isArray(ring));
return solvePavedRegion(cornerRing, masks);
}
module.exports = { solvePavedRegion, solveCornerFeasibleRegion };
+2
View File
@@ -8,6 +8,8 @@ module.exports = {
junctionStructure: require('./compile/junction-structure'), junctionStructure: require('./compile/junction-structure'),
junctionStandards: require('./compile/junction-standards'), junctionStandards: require('./compile/junction-standards'),
junctionProjection: require('./compile/junction-projection'), junctionProjection: require('./compile/junction-projection'),
junctionPolygonOps: require('./compile/junction-polygon-ops'),
junctionRegionSolver: require('./compile/junction-region-solver'),
osm: require('./osm'), osm: require('./osm'),
trafficSignals: require('./traffic-signals'), trafficSignals: require('./traffic-signals'),
nativeTrafficSignals: require('./native-traffic-signals'), nativeTrafficSignals: require('./native-traffic-signals'),
+22
View File
@@ -0,0 +1,22 @@
'use strict';
const assert = require('assert/strict');
const { buildPedestrianIsland, validateFacilityComposition } = require('../src/compile/junction-facility-composition');
const ring = [
[0, 0],
[4, 0],
[4, 2],
[0, 2],
[0, 0],
];
const crossings = [1, 2, 3].map((id) => ({
key: `crossing:${id}`,
fromBoundary: `walk:${id}`,
toBoundary: 'island:1',
}));
const island = buildPedestrianIsland({ key: 'island:1', ring, crossingKeys: crossings.map((item) => item.key) });
assert.equal(validateFacilityComposition(island, crossings).valid, true);
assert.equal(buildPedestrianIsland({ key: 'bad', ring, crossingKeys: ['a', 'b'] }), null);
assert.equal(validateFacilityComposition(island, crossings.slice(0, 2)).reason, 'crossing-reference-missing');
console.log('junction facility composition tests passed');
+26
View File
@@ -0,0 +1,26 @@
'use strict';
const assert = require('assert/strict');
const { difference, intersection, union, intersectsOrTouches } = require('../src/compile/junction-polygon-ops');
const square = (x, y, size) => [
[
[x, y],
[x + size, y],
[x + size, y + size],
[x, y + size],
[x, y],
],
];
const shell = square(0, 0, 10);
const hole = square(2, 2, 6);
assert.equal(difference(shell, hole)[0].length, 2);
assert.equal(intersection(shell, hole).length, 1);
assert.equal(union(shell, square(10, 0, 5)).length, 1);
assert.deepEqual(difference(shell), [shell]);
assert.equal(intersectsOrTouches(shell, hole), true);
assert.equal(
intersectsOrTouches(shell, square(20, 0, 2), () => true),
true,
);
console.log('junction polygon operation tests passed');
+25
View File
@@ -0,0 +1,25 @@
'use strict';
const assert = require('assert/strict');
const { solvePavedRegion, solveCornerFeasibleRegion } = require('../src/compile/junction-region-solver');
const shell = [
[0, 0],
[10, 0],
[10, 10],
[0, 10],
[0, 0],
];
const hole = [
[2, 2],
[8, 2],
[8, 8],
[2, 8],
[2, 2],
];
const result = solvePavedRegion(shell, [hole]);
assert.equal(result.length, 1);
assert.equal(result[0].length, 2);
assert.deepEqual(solvePavedRegion(shell), [[shell]]);
assert.equal(solveCornerFeasibleRegion(shell, hole).length, 1);
console.log('junction region solver tests passed');