feat(junction): project advanced facilities and associations
This commit is contained in:
1 parent
61ae90352a
commit
0065c3eaec
9 files changed
+111
-3
No files matched your search
@@ -0,0 +1,2 @@
|
||||
{"file":".trellis/spec/backend/direct-edit-api.md","reason":"Check compatibility and no new save path."}
|
||||
{"file":".trellis/spec/frontend/quality-guidelines.md","reason":"Run frontend gates."}
|
||||
@@ -0,0 +1,3 @@
|
||||
# 技术设计
|
||||
|
||||
扩展 `junction-projection` 的输入图层投影:道路臂从 road tags 和 sidewalk flags 得到 pedestrian/bicycle 状态;设施从显式 feature properties.kind 读取 island、median、sidewalk-turn;信号按 node/control/crossing 关联对象键。适配诊断只读,不改变 solver 或保存门禁。
|
||||
@@ -0,0 +1,3 @@
|
||||
{"file":".trellis/spec/backend/direct-edit-api.md","reason":"Keep compiler-owned structure and diagnostics authoritative."}
|
||||
{"file":".trellis/spec/frontend/quality-guidelines.md","reason":"Validate frontend structure rendering."}
|
||||
{"file":".trellis/spec/guides/cross-layer-thinking-guide.md","reason":"Avoid fabricating facilities at layer boundaries."}
|
||||
@@ -0,0 +1,5 @@
|
||||
# 实施清单
|
||||
|
||||
1. 扩展结构投影与设施关联。
|
||||
2. 增加形态适配诊断和投影单测。
|
||||
3. 更新前端设施类型显示并运行质量门禁。
|
||||
@@ -0,0 +1,12 @@
|
||||
# JunctionTools Stage 5:高级设施与形态适配
|
||||
|
||||
## 目标
|
||||
|
||||
在有真实编译证据时投影导流岛、中央分隔、步行转角和信号关联对象,并明确 T 字、十字、多臂、单行和单车道的适配状态;没有证据时不虚构设施。
|
||||
|
||||
## 验收标准
|
||||
|
||||
1. 信号对象关联同路口的横道/停止线(若存在),不编辑信号相位。
|
||||
2. 道路臂反映已知人行道/非机动车连接状态。
|
||||
3. 图层中明确标记为 island/median/sidewalk-turn 的要素才进入结构对象列表。
|
||||
4. 不适配或证据缺失以诊断/说明表达,不生成虚假几何;现有普通编辑和保存不受影响。
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"id": "junctiontools-stage5-advanced-facilities",
|
||||
"name": "junctiontools-stage5-advanced-facilities",
|
||||
"title": "JunctionTools Stage 5 高级设施与形态适配",
|
||||
"description": "",
|
||||
"status": "planning",
|
||||
"dev_type": null,
|
||||
"scope": null,
|
||||
"package": null,
|
||||
"priority": "P2",
|
||||
"creator": "dingkang",
|
||||
"assignee": "dingkang",
|
||||
"createdAt": "2026-09-07",
|
||||
"completedAt": null,
|
||||
"branch": null,
|
||||
"base_branch": "main",
|
||||
"worktree_path": null,
|
||||
"commit": null,
|
||||
"pr_url": null,
|
||||
"subtasks": [],
|
||||
"children": [],
|
||||
"parent": null,
|
||||
"relatedFiles": [],
|
||||
"notes": "",
|
||||
"meta": {}
|
||||
}
|
||||
@@ -56,6 +56,10 @@ function projectJunctionStructure({
|
||||
? 'two-way'
|
||||
: 'unknown',
|
||||
carriageway: { laneCount: Number(road.laneCount) || 0, effectiveWidthMeters: Number(road.widthMeters) || 0 },
|
||||
pedestrian: {
|
||||
connected: Boolean(road.sidewalkLeft || road.sidewalkRight),
|
||||
bicycleConnected: ['cycleway', 'path', 'living_street'].includes(String(road.highway || '').toLowerCase()),
|
||||
},
|
||||
geometryRef: String(road.id || `road:${index + 1}`),
|
||||
sourceRoadId: String(road.id || ''),
|
||||
};
|
||||
@@ -75,6 +79,7 @@ function projectJunctionStructure({
|
||||
})
|
||||
: [];
|
||||
const facilities = [];
|
||||
const crossingKeys = [];
|
||||
for (const [kind, collection] of [
|
||||
['crossing', layers.crosswalks],
|
||||
['stop-line', layers.vehicleStopLines],
|
||||
@@ -87,11 +92,41 @@ function projectJunctionStructure({
|
||||
label: kind === 'crossing' ? `人行横道 ${index + 1}` : `停止线 ${index + 1}`,
|
||||
geometryRef: String(id),
|
||||
});
|
||||
if (kind === 'crossing') crossingKeys.push(String(id));
|
||||
});
|
||||
}
|
||||
for (const [index, feature] of featureCollection(trafficSignals?.assemblies).entries()) {
|
||||
const id = feature.properties?.signal_uid || feature.properties?.id || `signal:${index + 1}`;
|
||||
facilities.push({ key: String(id), kind: 'signal', label: `信号灯 ${index + 1}`, geometryRef: String(id) });
|
||||
const signalNode = feature.properties?.node_id || feature.properties?.control_id;
|
||||
const related = crossingKeys.find((crossingKey) => String(crossingKey).includes(String(signalNode || '')));
|
||||
facilities.push({
|
||||
key: String(id),
|
||||
kind: 'signal',
|
||||
label: `信号灯 ${index + 1}`,
|
||||
geometryRef: String(id),
|
||||
...(related ? { relatedFacilityKey: related } : {}),
|
||||
});
|
||||
}
|
||||
for (const [kind, collection] of [
|
||||
['island', layers.islands],
|
||||
['median', layers.medians],
|
||||
['sidewalk-turn', layers.sidewalkTurns],
|
||||
]) {
|
||||
featureCollection(collection).forEach((feature, index) => {
|
||||
if (feature.properties?.kind !== kind) return;
|
||||
const id = feature.properties?.native_id || feature.properties?.id || `${kind}:${index + 1}`;
|
||||
facilities.push({
|
||||
key: String(id),
|
||||
kind,
|
||||
label:
|
||||
kind === 'island'
|
||||
? `导流岛 ${index + 1}`
|
||||
: kind === 'median'
|
||||
? `中央分隔 ${index + 1}`
|
||||
: `人行道转角 ${index + 1}`,
|
||||
geometryRef: String(id),
|
||||
});
|
||||
});
|
||||
}
|
||||
const shapeKind =
|
||||
shape?.kind ||
|
||||
|
||||
@@ -47,6 +47,20 @@ const structure = projectJunctionStructure({
|
||||
type: 'FeatureCollection',
|
||||
features: [{ type: 'Feature', properties: { native_id: 'stop-line:north' }, geometry: null }],
|
||||
},
|
||||
islands: {
|
||||
type: 'FeatureCollection',
|
||||
features: [{ type: 'Feature', properties: { kind: 'island', native_id: 'island:north' }, geometry: null }],
|
||||
},
|
||||
medians: {
|
||||
type: 'FeatureCollection',
|
||||
features: [{ type: 'Feature', properties: { kind: 'median', native_id: 'median:center' }, geometry: null }],
|
||||
},
|
||||
sidewalkTurns: {
|
||||
type: 'FeatureCollection',
|
||||
features: [
|
||||
{ type: 'Feature', properties: { kind: 'sidewalk-turn', native_id: 'sidewalk-turn:east' }, geometry: null },
|
||||
],
|
||||
},
|
||||
intersectionSurface: { type: 'FeatureCollection', features: [] },
|
||||
},
|
||||
trafficSignals: {
|
||||
@@ -64,10 +78,12 @@ assert.deepEqual(
|
||||
['北环路', '东环路'],
|
||||
);
|
||||
assert.equal(structure.arms[1].directionality, 'one-way');
|
||||
assert.equal(structure.arms[0].pedestrian.connected, false);
|
||||
assert.equal(structure.arms[1].pedestrian.bicycleConnected, false);
|
||||
assert.equal(structure.corners.length, 2);
|
||||
assert.deepEqual(
|
||||
structure.facilities.map((facility) => facility.kind),
|
||||
['crossing', 'stop-line', 'signal'],
|
||||
['crossing', 'stop-line', 'signal', 'island', 'median', 'sidewalk-turn'],
|
||||
);
|
||||
|
||||
const diagnostics = standardsDiagnostics(structure);
|
||||
|
||||
+7
-1
@@ -289,7 +289,7 @@ function state(area, junctionReference = null, debug = false) {
|
||||
}
|
||||
|
||||
function readWorkbenchLayers(nativeDir, osm2streetsRoadSurface) {
|
||||
return {
|
||||
const layers = {
|
||||
nativeRoadSurface: readLayer(path.join(nativeDir, 'layers', 'road_surface.geojson')),
|
||||
edgeLines: readLayer(path.join(nativeDir, 'layers', 'edge_lines.geojson')),
|
||||
nativeSidewalkSurface: readLayer(path.join(nativeDir, 'layers', 'sidewalk_surface.geojson')),
|
||||
@@ -305,6 +305,12 @@ function readWorkbenchLayers(nativeDir, osm2streetsRoadSurface) {
|
||||
osm2streetsRoadSurface:
|
||||
osm2streetsRoadSurface && fs.existsSync(osm2streetsRoadSurface) ? readLayer(osm2streetsRoadSurface) : null,
|
||||
};
|
||||
// Advanced facilities are only projected when compiler layers explicitly
|
||||
// carry their facility kind; these aliases keep the projection read-only.
|
||||
layers.islands = layers.nativeIntersectionSurface;
|
||||
layers.medians = layers.nativeIntersectionSurface;
|
||||
layers.sidewalkTurns = layers.nativeSidewalkSurface;
|
||||
return layers;
|
||||
}
|
||||
|
||||
function activeRevisionFields(area) {
|
||||
|
||||
Reference in new issue
Block a user