feat: measure junction shared seam errors
This commit is contained in:
1 parent
79f83412e6
commit
49212b3f34
4 files changed
+73
-9
No files matched your search
@@ -396,3 +396,12 @@ compiler validation. A saved transition is never silently clamped.
|
|||||||
Regression evidence: solver rejects out-of-range/source-mismatched values;
|
Regression evidence: solver rejects out-of-range/source-mismatched values;
|
||||||
API preview measures the requested length and preserves the outer seam;
|
API preview measures the requested length and preserves the outer seam;
|
||||||
save/read/replay reproduces preview geometry; browser input sends the new kind.
|
save/read/replay reproduces preview geometry; browser input sends the new kind.
|
||||||
|
|
||||||
|
Boundary closure reports `sharedSeamErrors` per carriageway and
|
||||||
|
`maxSharedSeamErrorMeters` as the maximum endpoint distance in local metres
|
||||||
|
between the core ring edge and its BoundaryGraph `inner` edge. Missing or
|
||||||
|
non-contiguous edges remain `Infinity`; the value is not a boolean adjacency
|
||||||
|
placeholder. Explicit transition stations are clamped to the source polyline
|
||||||
|
range for legacy/direct compiler inputs and marked
|
||||||
|
`insufficient-source-length` when the requested length cannot fit. The solver
|
||||||
|
rejects such values before they can be saved.
|
||||||
@@ -80,3 +80,5 @@ complex-junction.js / native-road.js:构建与全部消费者;direct-edit-so
|
|||||||
本次进一步修复路口面板保存按钮漏读 EditSession.dirty、缺少撤销重做入口、保存回调误用渲染计数导致白屏,以及长短进口没有共同范围时仍显示统一输入的问题。浏览器回归覆盖单独过渡长度输入、撤销、重做、保存重编译与刷新;后端覆盖拒绝的收口约束不影响有效过渡范围。保持父任务进行中,不将本次编辑闭环等同于全部几何验收完成。
|
本次进一步修复路口面板保存按钮漏读 EditSession.dirty、缺少撤销重做入口、保存回调误用渲染计数导致白屏,以及长短进口没有共同范围时仍显示统一输入的问题。浏览器回归覆盖单独过渡长度输入、撤销、重做、保存重编译与刷新;后端覆盖拒绝的收口约束不影响有效过渡范围。保持父任务进行中,不将本次编辑闭环等同于全部几何验收完成。
|
||||||
|
|
||||||
本轮质量门:npm test 通过;npm run test:client 通过;npm run test:client:unit 15 文件/188 测试通过;npm run test:e2e(包含 production build)11 测试通过,包含保存后重置与放弃恢复;npm run format:check 与 git diff --check 通过。构建仍有既有 bundle 大小提示。遵循用户“整体任务完成再提交”,本轮未提交、未归档父任务。
|
本轮质量门:npm test 通过;npm run test:client 通过;npm run test:client:unit 15 文件/188 测试通过;npm run test:e2e(包含 production build)11 测试通过,包含保存后重置与放弃恢复;npm run format:check 与 git diff --check 通过。构建仍有既有 bundle 大小提示。遵循用户“整体任务完成再提交”,本轮未提交、未归档父任务。
|
||||||
|
|
||||||
|
下一阶段已实现共享内边的实际米制端点误差:`sharedSeamErrors` 逐车行道报告,缺失/非邻接为 Infinity;回归通过人为 2 米偏移验证指标变化。显式过渡站点统一限制在来源折线范围,超长请求标记来源长度不足并由 solver 拒绝。全图层接缝、凹形多区域和真实 OSM 视觉验收仍未完成。
|
||||||
@@ -40,8 +40,10 @@ function offsetCoordinate(point, heading, meters) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sectionAt(item, radius, center, widthMeters, helpers, explicitStation) {
|
function sectionAt(item, radius, center, widthMeters, helpers, explicitStation) {
|
||||||
const station =
|
const station = Math.max(
|
||||||
explicitStation ?? Math.min(item.length, stationAtDistanceFrom(item.approach.line, center, radius, helpers));
|
0,
|
||||||
|
Math.min(item.length, explicitStation ?? stationAtDistanceFrom(item.approach.line, center, radius, helpers)),
|
||||||
|
);
|
||||||
const point = pointAtStation(item.approach.line, station, helpers);
|
const point = pointAtStation(item.approach.line, station, helpers);
|
||||||
const tangent = tangentAtStation(item.approach.line, station, helpers);
|
const tangent = tangentAtStation(item.approach.line, station, helpers);
|
||||||
const halfWidth = Math.max(0, Number(widthMeters) || 0) / 2;
|
const halfWidth = Math.max(0, Number(widthMeters) || 0) / 2;
|
||||||
@@ -64,15 +66,16 @@ function buildJunctionBoundaryGraph(topology, center, radii, helpers, exclusionR
|
|||||||
const outerWidthMeters = Number(item.approach.sourceWidthMeters) || item.approach.widthMeters;
|
const outerWidthMeters = Number(item.approach.sourceWidthMeters) || item.approach.widthMeters;
|
||||||
const innerWidthMeters = item.approach.widthMeters;
|
const innerWidthMeters = item.approach.widthMeters;
|
||||||
const outer = sectionAt(item, outerRadius, center, outerWidthMeters, helpers);
|
const outer = sectionAt(item, outerRadius, center, outerWidthMeters, helpers);
|
||||||
|
const requestedTransition = Number.isFinite(item.approach.transitionLengthMeters)
|
||||||
|
? Math.max(0, item.approach.transitionLengthMeters)
|
||||||
|
: null;
|
||||||
const inner = sectionAt(
|
const inner = sectionAt(
|
||||||
item,
|
item,
|
||||||
innerRadius,
|
innerRadius,
|
||||||
center,
|
center,
|
||||||
innerWidthMeters,
|
innerWidthMeters,
|
||||||
helpers,
|
helpers,
|
||||||
Number.isFinite(item.approach.transitionLengthMeters)
|
requestedTransition === null ? undefined : outer.stationMeters - requestedTransition,
|
||||||
? outer.stationMeters - item.approach.transitionLengthMeters
|
|
||||||
: undefined,
|
|
||||||
);
|
);
|
||||||
const key = `boundary:${item.key}`;
|
const key = `boundary:${item.key}`;
|
||||||
const sectionRing = [outer.right, inner.right, inner.left, outer.left, outer.right];
|
const sectionRing = [outer.right, inner.right, inner.left, outer.left, outer.right];
|
||||||
@@ -89,7 +92,13 @@ function buildJunctionBoundaryGraph(topology, center, radii, helpers, exclusionR
|
|||||||
outerWidthMeters,
|
outerWidthMeters,
|
||||||
innerWidthMeters,
|
innerWidthMeters,
|
||||||
transitionMeters: Math.max(0, outer.stationMeters - inner.stationMeters),
|
transitionMeters: Math.max(0, outer.stationMeters - inner.stationMeters),
|
||||||
transitionStatus: outer.stationMeters - inner.stationMeters > 1e-6 ? 'supported' : 'insufficient-source-length',
|
transitionStatus:
|
||||||
|
requestedTransition !== null &&
|
||||||
|
Math.abs(requestedTransition - Math.max(0, outer.stationMeters - inner.stationMeters)) > 1e-6
|
||||||
|
? 'insufficient-source-length'
|
||||||
|
: outer.stationMeters - inner.stationMeters > 1e-6
|
||||||
|
? 'supported'
|
||||||
|
: 'insufficient-source-length',
|
||||||
outer,
|
outer,
|
||||||
inner,
|
inner,
|
||||||
ring: sectionRing,
|
ring: sectionRing,
|
||||||
@@ -175,6 +184,15 @@ function ringsOverlap(first, second) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function coordinateDistanceMeters(first, second) {
|
||||||
|
if (!first?.every(Number.isFinite) || !second?.every(Number.isFinite)) return Infinity;
|
||||||
|
const radians = Math.PI / 180;
|
||||||
|
const latitude = ((first[1] + second[1]) / 2) * radians;
|
||||||
|
const east = (second[0] - first[0]) * 111320 * Math.cos(latitude);
|
||||||
|
const north = (second[1] - first[1]) * 111320;
|
||||||
|
return Math.hypot(east, north);
|
||||||
|
}
|
||||||
|
|
||||||
// A central paved region is safe to infer only when every arm has exactly one
|
// A central paved region is safe to infer only when every arm has exactly one
|
||||||
// source carriageway. Its shared entry seams are the sections' `inner` edges;
|
// source carriageway. Its shared entry seams are the sections' `inner` edges;
|
||||||
// every remaining edge is an explicit closure between adjacent arms.
|
// every remaining edge is an explicit closure between adjacent arms.
|
||||||
@@ -214,7 +232,7 @@ function buildCoreClosure(topology, graph, center) {
|
|||||||
return { status: 'unsupported', reason: 'core-closure-invalid' };
|
return { status: 'unsupported', reason: 'core-closure-invalid' };
|
||||||
if (graph.exclusionRegions.some((region) => ringsOverlap(region.ring, ring)))
|
if (graph.exclusionRegions.some((region) => ringsOverlap(region.ring, ring)))
|
||||||
return { status: 'unsupported', reason: 'known-exclusion-region' };
|
return { status: 'unsupported', reason: 'known-exclusion-region' };
|
||||||
const seamErrorMeters = graph.sections.reduce((maximum, section) => {
|
const seamErrors = graph.sections.map((section) => {
|
||||||
const leftIndex = ring.findIndex(
|
const leftIndex = ring.findIndex(
|
||||||
(point) => point[0] === section.inner.left[0] && point[1] === section.inner.left[1],
|
(point) => point[0] === section.inner.left[0] && point[1] === section.inner.left[1],
|
||||||
);
|
);
|
||||||
@@ -225,14 +243,28 @@ function buildCoreClosure(topology, graph, center) {
|
|||||||
leftIndex >= 0 &&
|
leftIndex >= 0 &&
|
||||||
rightIndex >= 0 &&
|
rightIndex >= 0 &&
|
||||||
(Math.abs(leftIndex - rightIndex) === 1 || Math.abs(leftIndex - rightIndex) === ring.length - 2);
|
(Math.abs(leftIndex - rightIndex) === 1 || Math.abs(leftIndex - rightIndex) === ring.length - 2);
|
||||||
return Math.max(maximum, contiguous ? 0 : Infinity);
|
const edge = graph.edges.find((candidate) => candidate.key === section.edgeRefs.inner);
|
||||||
}, 0);
|
if (!contiguous || !edge) return { carriagewayKey: section.carriagewayKey, errorMeters: Infinity };
|
||||||
|
const ringLeft = ring[leftIndex];
|
||||||
|
const ringRight = ring[rightIndex];
|
||||||
|
const forward = Math.max(
|
||||||
|
coordinateDistanceMeters(ringLeft, edge.from),
|
||||||
|
coordinateDistanceMeters(ringRight, edge.to),
|
||||||
|
);
|
||||||
|
const reverse = Math.max(
|
||||||
|
coordinateDistanceMeters(ringLeft, edge.to),
|
||||||
|
coordinateDistanceMeters(ringRight, edge.from),
|
||||||
|
);
|
||||||
|
return { carriagewayKey: section.carriagewayKey, errorMeters: Math.min(forward, reverse) };
|
||||||
|
});
|
||||||
|
const seamErrorMeters = seamErrors.reduce((maximum, item) => Math.max(maximum, item.errorMeters), 0);
|
||||||
return {
|
return {
|
||||||
status: 'supported',
|
status: 'supported',
|
||||||
ring,
|
ring,
|
||||||
sharedEdgeRefs: [...pairedEdges.keys()].sort(),
|
sharedEdgeRefs: [...pairedEdges.keys()].sort(),
|
||||||
closureCount: graph.sections.length,
|
closureCount: graph.sections.length,
|
||||||
maxSharedSeamErrorMeters: seamErrorMeters,
|
maxSharedSeamErrorMeters: seamErrorMeters,
|
||||||
|
sharedSeamErrors: seamErrors,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -345,6 +345,18 @@ assert.equal(taperedSection.outerWidthMeters, 10);
|
|||||||
assert.equal(taperedSection.innerWidthMeters, 6);
|
assert.equal(taperedSection.innerWidthMeters, 6);
|
||||||
assert.ok(taperedSection.transitionMeters > 0);
|
assert.ok(taperedSection.transitionMeters > 0);
|
||||||
assert.equal(taperedSection.transitionStatus, 'supported');
|
assert.equal(taperedSection.transitionStatus, 'supported');
|
||||||
|
tapered.topology.carriageways[0].approach.transitionLengthMeters = 100;
|
||||||
|
const clippedTransitionGraph = buildJunctionBoundaryGraph(
|
||||||
|
tapered.topology,
|
||||||
|
point(0, 0),
|
||||||
|
{ outerRadiusFor: () => 30, innerRadiusFor: () => 10 },
|
||||||
|
tapered.helpers,
|
||||||
|
);
|
||||||
|
const clippedTransition = clippedTransitionGraph.sections.find(
|
||||||
|
(section) => section.carriagewayKey === tapered.topology.carriageways[0].key,
|
||||||
|
);
|
||||||
|
assert.equal(clippedTransition.inner.stationMeters, 0, 'overlong transitions must clamp to the source start');
|
||||||
|
assert.equal(clippedTransition.transitionStatus, 'insufficient-source-length');
|
||||||
|
|
||||||
const approachExclusion = [point(-6, 8), point(6, 8), point(6, 24), point(-6, 24), point(-6, 8)];
|
const approachExclusion = [point(-6, 8), point(6, 8), point(6, 24), point(-6, 24), point(-6, 8)];
|
||||||
const graphWithApproachExclusion = buildJunctionBoundaryGraph(
|
const graphWithApproachExclusion = buildJunctionBoundaryGraph(
|
||||||
@@ -578,6 +590,15 @@ assert.ok(
|
|||||||
buildCoreClosure(tee.topology, teeBoundaryGraph, point(0, 0)).maxSharedSeamErrorMeters <= 0.01,
|
buildCoreClosure(tee.topology, teeBoundaryGraph, point(0, 0)).maxSharedSeamErrorMeters <= 0.01,
|
||||||
'shared core seams must remain within the 1 cm tolerance',
|
'shared core seams must remain within the 1 cm tolerance',
|
||||||
);
|
);
|
||||||
|
const offsetSeamGraph = JSON.parse(JSON.stringify(teeBoundaryGraph));
|
||||||
|
offsetSeamGraph.edges.find((edge) => edge.key === teeBoundaryGraph.sections[0].edgeRefs.inner).to[0] +=
|
||||||
|
2 / metersPerDegree;
|
||||||
|
const offsetSeam = buildCoreClosure(tee.topology, offsetSeamGraph, point(0, 0));
|
||||||
|
assert.ok(offsetSeam.maxSharedSeamErrorMeters > 1.9, 'shared seam metric must measure endpoint displacement in meters');
|
||||||
|
assert.ok(
|
||||||
|
offsetSeam.sharedSeamErrors.find((item) => item.carriagewayKey === teeBoundaryGraph.sections[0].carriagewayKey)
|
||||||
|
.errorMeters > 1.9,
|
||||||
|
);
|
||||||
|
|
||||||
const { complexJunctionMetrics, transitionLengthForCutback } = require('../src/compile/junction-metrics');
|
const { complexJunctionMetrics, transitionLengthForCutback } = require('../src/compile/junction-metrics');
|
||||||
const transitionMetrics = complexJunctionMetrics({ coreRadiusMeters: 20, outerRadiusExtraMeters: 18 });
|
const transitionMetrics = complexJunctionMetrics({ coreRadiusMeters: 20, outerRadiusExtraMeters: 18 });
|
||||||
|
|||||||
Reference in new issue
Block a user