refactor(junction): keep edit metrics pure
This commit is contained in:
1 parent
88d8b841e5
commit
f56c0978b0
5 files changed
+25
-16
No files matched your search
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
- [x] 统一重复归组;保存车行道和内部通路,不将不同通道按接近角度无条件合并。
|
- [x] 统一重复归组;保存车行道和内部通路,不将不同通道按接近角度无条件合并。
|
||||||
- [x] 引入 EntrySection 契约、来源/推断信息和稳定键;BoundaryGraph 留待连续边界阶段实现。
|
- [x] 引入 EntrySection 契约、来源/推断信息和稳定键;BoundaryGraph 留待连续边界阶段实现。
|
||||||
- [ ] 分离参考文件加载和纯 resolver;补输入重排、角度绕回、歧义、两路口隔离测试。
|
- [x] 分离参考文件加载和纯 resolver;补输入重排、角度绕回、歧义、两路口隔离测试。
|
||||||
- [ ] 出口 A1/A2 基础:3~6 臂和分隔组合均能产生可解释结构或明确不支持原因。
|
- [ ] 出口 A1/A2 基础:3~6 臂和分隔组合均能产生可解释结构或明确不支持原因。
|
||||||
|
|
||||||
## 2. 连续边界与区域求解(最高风险)
|
## 2. 连续边界与区域求解(最高风险)
|
||||||
|
|||||||
@@ -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 } = require('./junction-boundary-graph');
|
const { buildJunctionBoundaryGraph, buildCoreClosure } = require('./junction-boundary-graph');
|
||||||
|
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();
|
||||||
const CORNER_FILLET_SEGMENTS = 12;
|
const CORNER_FILLET_SEGMENTS = 12;
|
||||||
@@ -665,20 +666,7 @@ function readReferenceCalibration(cluster) {
|
|||||||
function complexJunctionMetrics(cluster) {
|
function complexJunctionMetrics(cluster) {
|
||||||
if (metricsCache.has(cluster)) return metricsCache.get(cluster);
|
if (metricsCache.has(cluster)) return metricsCache.get(cluster);
|
||||||
const calibration = readReferenceCalibration(cluster);
|
const calibration = readReferenceCalibration(cluster);
|
||||||
// Without a reference geometry `coreRadiusMeters` is the only size input the
|
const metrics = calculateComplexJunctionMetrics(cluster, calibration);
|
||||||
// template has, so honour it literally within the schema's own 12..80 range.
|
|
||||||
// It used to be scaled by .52 and clamped to 17, which silently capped every
|
|
||||||
// unreferenced junction at a core far smaller than its own approach envelope
|
|
||||||
// — a 24 m dual-carriageway arm was being fitted into a 16.6 m core no matter
|
|
||||||
// what the config asked for. The calibrated branch is unchanged.
|
|
||||||
const coreRadius = calibration
|
|
||||||
? Math.max(12, Math.min(24, calibration.shortSpanMeters * 0.14))
|
|
||||||
: Math.max(12, Math.min(80, Number(cluster.coreRadiusMeters) || 28));
|
|
||||||
const metrics = {
|
|
||||||
calibration,
|
|
||||||
coreRadius,
|
|
||||||
approachOuterRadius: coreRadius + (Number(cluster.outerRadiusExtraMeters) || 18),
|
|
||||||
};
|
|
||||||
metricsCache.set(cluster, metrics);
|
metricsCache.set(cluster, metrics);
|
||||||
return metrics;
|
return metrics;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const {
|
|||||||
junctionSurfaceId,
|
junctionSurfaceId,
|
||||||
connectionConnectorId,
|
connectionConnectorId,
|
||||||
} = require('./native-ids');
|
} = require('./native-ids');
|
||||||
const { complexJunctionMetrics } = require('./complex-junction');
|
const { complexJunctionMetrics } = require('./junction-metrics');
|
||||||
const { resolveJunctionBuildPlan } = require('./junction-build-plan');
|
const { resolveJunctionBuildPlan } = require('./junction-build-plan');
|
||||||
|
|
||||||
const RESOLUTION_SCHEMA = 'road-edit-resolution/v1';
|
const RESOLUTION_SCHEMA = 'road-edit-resolution/v1';
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Pure default geometry metrics. Reference-file calibration is resolved by the
|
||||||
|
// compiler boundary and can be supplied as plain data by its caller.
|
||||||
|
function complexJunctionMetrics(cluster, calibration = null) {
|
||||||
|
const coreRadius = calibration
|
||||||
|
? Math.max(12, Math.min(24, calibration.shortSpanMeters * 0.14))
|
||||||
|
: Math.max(12, Math.min(80, Number(cluster.coreRadiusMeters) || 28));
|
||||||
|
return {
|
||||||
|
calibration,
|
||||||
|
coreRadius,
|
||||||
|
approachOuterRadius: coreRadius + (Number(cluster.outerRadiusExtraMeters) || 18),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { complexJunctionMetrics };
|
||||||
@@ -759,5 +759,10 @@ assert.equal(stopOnly.cutbackMeters !== 4, true, 'a stop-line offset must not be
|
|||||||
const source = require('fs').readFileSync(require.resolve('../src/compile/direct-edit-solver'), 'utf8');
|
const source = require('fs').readFileSync(require.resolve('../src/compile/direct-edit-solver'), 'utf8');
|
||||||
for (const forbidden of ["require('fs')", "require('path')", "require('http')", "require('https')"])
|
for (const forbidden of ["require('fs')", "require('path')", "require('http')", "require('https')"])
|
||||||
assert.equal(source.includes(forbidden), false, `direct-edit-solver must not ${forbidden}`);
|
assert.equal(source.includes(forbidden), false, `direct-edit-solver must not ${forbidden}`);
|
||||||
|
assert.equal(
|
||||||
|
source.includes("require('./complex-junction')"),
|
||||||
|
false,
|
||||||
|
'direct-edit-solver must not depend on the compiler module that reads reference files',
|
||||||
|
);
|
||||||
|
|
||||||
console.log('direct edit solver tests passed');
|
console.log('direct edit solver tests passed');
|
||||||
Reference in new issue
Block a user