fix: align carriageway edge handles with entry geometry
This commit is contained in:
1 parent
44fa82299b
commit
a5089220b5
5 files changed
+157
-3
No files matched your search
@@ -113,6 +113,21 @@ the pure resolver remains reusable by preview and formal compilation.
|
||||
The handle manifest reports `axisAzimuth = tangent + 90` for both sides, which is
|
||||
therefore *right*. Handle placement must offset the left handle by `tangent - 90`.
|
||||
|
||||
Complex carriageway edge handles use the same convention, but their position is
|
||||
the effective inner entry section rather than the legacy cutback point:
|
||||
|
||||
```text
|
||||
innerStation = outerStation - transitionLength + positionOffset
|
||||
edgeDistance = effectiveWidth / 2 + sideEdgeOffset
|
||||
```
|
||||
|
||||
Compute the tangent at `innerStation`, then apply `directionOffsetDegrees` before
|
||||
placing the left and right handles. This keeps the manifest aligned with
|
||||
`JunctionBoundaryGraph` after transition, position, direction, width, or edge
|
||||
edits. Tests must measure that the two handles are geographically opposite and
|
||||
their separation equals `effectiveWidth + leftOffset + rightOffset` within the
|
||||
geometry tolerance; checking only stored scalar values does not prove placement.
|
||||
|
||||
**Regression**: `makeRoadHandles()` once placed the left handle at `tangent + 90`,
|
||||
drawing it over the right kerb, so dragging the visually-left handle moved the
|
||||
right edge. Assert sides by geography (a north-heading road's left handle is west
|
||||
|
||||
@@ -79,6 +79,14 @@ complex-junction.js / native-road.js:构建与全部消费者;direct-edit-so
|
||||
|
||||
本次进一步修复路口面板保存按钮漏读 EditSession.dirty、缺少撤销重做入口、保存回调误用渲染计数导致白屏,以及长短进口没有共同范围时仍显示统一输入的问题。浏览器回归覆盖单独过渡长度输入、撤销、重做、保存重编译与刷新;后端覆盖拒绝的收口约束不影响有效过渡范围。保持父任务进行中,不将本次编辑闭环等同于全部几何验收完成。
|
||||
|
||||
## 接入边界手柄几何交付记录
|
||||
|
||||
复杂车行道左右边界手柄现统一发布向右法线,由客户端仅对左侧反转一次,修复左边界向外拖反而收窄。手柄位置使用与 BoundaryGraph 相同的有效内断面站点 `outer - transition + position`,并消费当前方向、有效宽度及各侧边界偏移;左右手柄不再重叠,曲线进口和过渡长度变化后仍落在实际编辑断面。
|
||||
|
||||
回归按米制测量左右手柄间距、地理侧别、过渡断面对齐以及位置/方向响应;客户端覆盖两侧向外展宽、向内收窄、约束值、ghost 位置和边界钳制。npm test、190 项客户端单测、类型检查、生产构建、11 项 E2E、format:check 与 git diff --check 通过,构建仅保留既有 bundle 大小提示。
|
||||
|
||||
方向控件仍以沿切线的线性拖动米数映射角度,且位置/方向自身手柄仍显示旧收口点。完整旋转交互需要单独明确手柄契约,本轮不据此关闭 A4/A5。
|
||||
|
||||
本轮质量门: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 视觉验收仍未完成。
|
||||
|
||||
@@ -1625,6 +1625,25 @@ function makeClusterCarriagewayHandles(model, junctionData, constraints, cluster
|
||||
editable: true,
|
||||
});
|
||||
}
|
||||
const positionEdit = constraintFor(constraints, 'cluster-carriageway-position', {
|
||||
clusterId,
|
||||
carriagewayKey: item.key,
|
||||
});
|
||||
const directionEdit = constraintFor(constraints, 'cluster-carriageway-direction', {
|
||||
clusterId,
|
||||
carriagewayKey: item.key,
|
||||
});
|
||||
// Match JunctionBoundaryGraph's effective inner section. The old handle
|
||||
// placement used the legacy cutback station, which diverges as soon as a
|
||||
// transition length is edited (and is especially visible on curves).
|
||||
const effectiveStationMeters = Math.max(
|
||||
0,
|
||||
Math.min(item.length, bounds.outer - transitionValue + numericValue(positionEdit, 'offsetMeters', 0)),
|
||||
);
|
||||
const effectiveStation = effectiveStationMeters / Math.max(item.length, 1);
|
||||
const effectiveCenter = coordinateAt(line, effectiveStation);
|
||||
const effectiveTangent = tangentAzimuth(line, effectiveStation) + numericValue(directionEdit, 'offsetDegrees', 0);
|
||||
const effectiveWidth = numericValue(constraint, 'widthMeters', item.widthMeters);
|
||||
for (const side of ['left', 'right']) {
|
||||
const candidates = constraints.filter(
|
||||
(edit) =>
|
||||
@@ -1636,6 +1655,8 @@ function makeClusterCarriagewayHandles(model, junctionData, constraints, cluster
|
||||
);
|
||||
const edgeConstraint = candidates.at(-1);
|
||||
const edgeValue = edgeConstraint?.value || {};
|
||||
const current = Number(edgeValue[`${side}OffsetMeters`]) || 0;
|
||||
const sideAzimuth = effectiveTangent + (side === 'left' ? -90 : 90);
|
||||
handles.push({
|
||||
handleId: `handle:cluster-carriageway-edge-offset:${side}:${item.key}`,
|
||||
kind: 'cluster-carriageway-edge-offset',
|
||||
@@ -1647,9 +1668,10 @@ function makeClusterCarriagewayHandles(model, junctionData, constraints, cluster
|
||||
sourceNodeIds: item.sourceNodeIds,
|
||||
sourceRoadIds: item.sourceRoadIds,
|
||||
},
|
||||
position: point,
|
||||
axisAzimuth: (tangentAzimuth(line, station) + (side === 'left' ? 270 : 90)) % 360,
|
||||
value: { current: Number(edgeValue[`${side}OffsetMeters`]) || 0, min: -10, max: 10, unit: 'meter' },
|
||||
position: offsetCoordinate(effectiveCenter, sideAzimuth, effectiveWidth / 2 + current),
|
||||
// The client reverses this shared rightward normal for a left-side drag.
|
||||
axisAzimuth: (effectiveTangent + 90) % 360,
|
||||
value: { current, min: -10, max: 10, unit: 'meter' },
|
||||
...(edgeConstraint?.anchor.side === side ? { constraintId: edgeConstraint.id } : {}),
|
||||
affects: [`complex-junction:${clusterId}:carriageway:${item.approach.segmentId}`],
|
||||
editable: true,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
const assert = require('assert/strict');
|
||||
const { resolveDirectEditConstraints } = require('../src/compile/direct-edit-solver');
|
||||
const { complexJunctionMetrics } = require('../src/compile/junction-metrics');
|
||||
const { haversineMeters } = require('../src/geometry/lane-geometry');
|
||||
|
||||
const model = { roads: [], endpoints: [], connections: [], diagnostics: [] };
|
||||
|
||||
@@ -371,6 +372,10 @@ const clusterCutbackHandle = clusterHandleResolution.handles.handles.find(
|
||||
(handle) => handle.kind === 'cluster-carriageway-cutback',
|
||||
);
|
||||
assert.ok(clusterCutbackHandle, 'a cluster selection publishes its carriageway cutback handles');
|
||||
const clusterTransitionHandle = clusterHandleResolution.handles.handles.find(
|
||||
(handle) => handle.kind === 'cluster-carriageway-transition-length',
|
||||
);
|
||||
assert.ok(clusterTransitionHandle, 'a cluster selection publishes its carriageway transition handles');
|
||||
const clusterTransitionMetrics = complexJunctionMetrics({ id: 'cluster-1' });
|
||||
assert.ok(
|
||||
clusterTransitionMetrics.approachOuterRadius -
|
||||
@@ -472,6 +477,7 @@ for (const sides of [
|
||||
leftOffsetMeters: 0.4,
|
||||
rightOffsetMeters: 0.7,
|
||||
});
|
||||
const edgePositions = {};
|
||||
for (const side of sides) {
|
||||
const handle = result.handles.handles.find(
|
||||
(handle) =>
|
||||
@@ -481,7 +487,76 @@ for (const sides of [
|
||||
);
|
||||
assert.equal(handle.constraintId, `edge-${side}`);
|
||||
assert.equal(handle.value.current, side === 'left' ? 0.4 : 0.7);
|
||||
edgePositions[side] = handle.position;
|
||||
assert.equal(
|
||||
handle.axisAzimuth,
|
||||
clusterWidthHandle.axisAzimuth,
|
||||
'both edge handles publish the rightward normal; the client reverses the left side once',
|
||||
);
|
||||
}
|
||||
assert.ok(
|
||||
haversineMeters(edgePositions.left, edgePositions.right) > clusterWidthHandle.value.current,
|
||||
'independent edge handles must be placed on opposite sides of the effective entry section',
|
||||
);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
haversineMeters(edgePositions.left, edgePositions.right) - (clusterWidthHandle.value.current + 0.4 + 0.7),
|
||||
) < 0.02,
|
||||
'edge handle separation must equal the effective width plus both independent edge offsets',
|
||||
);
|
||||
}
|
||||
|
||||
const movedCluster = resolveDirectEditConstraints(
|
||||
junctionModel,
|
||||
document([
|
||||
constraint({
|
||||
kind: 'cluster-carriageway-position',
|
||||
anchor: clusterWidthHandle.anchor,
|
||||
value: { offsetMeters: 1 },
|
||||
}),
|
||||
constraint({
|
||||
kind: 'cluster-carriageway-direction',
|
||||
anchor: clusterWidthHandle.anchor,
|
||||
value: { offsetDegrees: 5 },
|
||||
}),
|
||||
]),
|
||||
{ junctionClusters: [{ id: 'cluster-1', nodeIds: ['junction'] }] },
|
||||
);
|
||||
const movedEdge = movedCluster.handles.handles.find(
|
||||
(handle) =>
|
||||
handle.kind === 'cluster-carriageway-edge-offset' &&
|
||||
handle.anchor.carriagewayKey === clusterWidthHandle.anchor.carriagewayKey &&
|
||||
handle.anchor.side === 'right',
|
||||
);
|
||||
assert.ok(haversineMeters(movedEdge.position, clusterWidthHandle.position) > clusterWidthHandle.value.current / 2);
|
||||
assert.notEqual(movedEdge.axisAzimuth, clusterWidthHandle.axisAzimuth);
|
||||
|
||||
const transitionedCluster = resolveDirectEditConstraints(
|
||||
junctionModel,
|
||||
document([
|
||||
constraint({
|
||||
kind: 'cluster-carriageway-transition-length',
|
||||
anchor: clusterWidthHandle.anchor,
|
||||
value: { transitionLengthMeters: clusterTransitionHandle.value.min },
|
||||
}),
|
||||
]),
|
||||
{ junctionClusters: [{ id: 'cluster-1', nodeIds: ['junction'] }] },
|
||||
);
|
||||
const transitionedHandle = transitionedCluster.handles.handles.find(
|
||||
(handle) =>
|
||||
handle.kind === 'cluster-carriageway-transition-length' &&
|
||||
handle.anchor.carriagewayKey === clusterWidthHandle.anchor.carriagewayKey,
|
||||
);
|
||||
const transitionedEdges = transitionedCluster.handles.handles.filter(
|
||||
(handle) =>
|
||||
handle.kind === 'cluster-carriageway-edge-offset' &&
|
||||
handle.anchor.carriagewayKey === clusterWidthHandle.anchor.carriagewayKey,
|
||||
);
|
||||
for (const edge of transitionedEdges) {
|
||||
assert.ok(
|
||||
Math.abs(haversineMeters(edge.position, transitionedHandle.position) - clusterWidthHandle.value.current / 2) < 0.02,
|
||||
'edge handles must use the same effective inner station as the transition handle',
|
||||
);
|
||||
}
|
||||
const recheckResolution = resolveDirectEditConstraints(
|
||||
junctionModel,
|
||||
|
||||
@@ -129,6 +129,40 @@ describe('complex carriageway width projection', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('complex carriageway edge projection', () => {
|
||||
for (const side of ['left', 'right'] as const) {
|
||||
it(`${side} edge widens outward and keeps its ghost on the dragged side`, () => {
|
||||
const handle = makeHandle(
|
||||
'cluster-carriageway-edge-offset',
|
||||
{
|
||||
type: 'cluster-carriageway',
|
||||
clusterId: 'cluster-1',
|
||||
carriagewayKey: 'carriageway-1',
|
||||
sourceNodeIds: ['node-1'],
|
||||
sourceRoadIds: ['road-1'],
|
||||
side,
|
||||
},
|
||||
0.5,
|
||||
-1,
|
||||
2,
|
||||
);
|
||||
const outward = side === 'left' ? OUTWARD_LEFT : OUTWARD_RIGHT;
|
||||
const value = projectHandleValue(handle, ...dragBy(outward, 1));
|
||||
expect(value).toBeCloseTo(1.5, 3);
|
||||
expect(constraintValueFor(handle, value)).toEqual({
|
||||
leftOffsetMeters: side === 'left' ? value : 0,
|
||||
rightOffsetMeters: side === 'right' ? value : 0,
|
||||
});
|
||||
const ghost = handlePositionFor(handle, value);
|
||||
expect(side === 'left' ? ghost[0] < CENTER[0] : ghost[0] > CENTER[0]).toBe(true);
|
||||
expect(haversineMeters(CENTER, ghost)).toBeCloseTo(1, 3);
|
||||
expect(projectHandleValue(handle, ...dragBy(outward + 180, 1))).toBeCloseTo(-0.5, 3);
|
||||
expect(projectHandleValue(handle, ...dragBy(outward, 10))).toBe(2);
|
||||
expect(haversineMeters(CENTER, handlePositionFor(handle, 2))).toBeCloseTo(1.5, 3);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('road-lane-divider projection', () => {
|
||||
it('is a signed lateral offset, with no side flip', () => {
|
||||
const handle = makeHandle('road-lane-divider', interval(undefined, 2), 0, -1.2, 1.2);
|
||||
|
||||
Reference in new issue
Block a user