diff --git a/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/check.jsonl b/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/check.jsonl new file mode 100644 index 0000000..d00ad3c --- /dev/null +++ b/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/check.jsonl @@ -0,0 +1,3 @@ +{"file":".trellis/spec/backend/direct-edit-api.md","reason":"Validate response compatibility and diagnostics semantics."} +{"file":".trellis/spec/frontend/direct-edit-client.md","reason":"Check no duplicate client geometry or edit protocol."} +{"file":".trellis/spec/frontend/quality-guidelines.md","reason":"Run frontend quality gates."} diff --git a/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/design.md b/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/design.md new file mode 100644 index 0000000..3cbcb8a --- /dev/null +++ b/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/design.md @@ -0,0 +1,19 @@ +# 技术设计 + +## 边界 + +编译层负责把模型和已发布设施图层投影为统一结构;Workbench server 负责在 state/preview 边界携带它;客户端只消费结构和诊断,不复制拓扑判断。 + +## 数据流 + +`compileRoadModel + compiled layers + shape summary -> buildJunctionStructure -> state/edit-state/edit-preview -> JunctionWorkspace` + +结构构造器保持纯函数。普通节点以 node key 建立结构,复杂 cluster 以 cluster key 建立结构;有效道路臂取实际 endpoint/road 证据,设施取 crosswalk、stop-line 和 traffic signal 的现有字段。没有证据的对象不生成。 + +## 兼容 + +新字段采用可选扩展,旧客户端忽略;结构生成失败时 state 仍返回原 compiled 数据和 `junctionStructure: null`,不影响既有编辑。preview 使用同一编译快照,不能读取上一次 state 的结构。 + +## 客户端 + +扩展 `WorkbenchState` 类型和 `JunctionWorkspace` props。对象树按道路臂、角部、过街与控制设施分组;诊断项显示可读消息和级别。当前阶段选择动作只更新既有工作区选中/高亮状态,不创建新的编辑历史。 diff --git a/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/implement.jsonl b/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/implement.jsonl new file mode 100644 index 0000000..0319331 --- /dev/null +++ b/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/implement.jsonl @@ -0,0 +1,4 @@ +{"file":".trellis/spec/backend/direct-edit-api.md","reason":"Preserve compiler ownership and preview/edit-state contracts."} +{"file":".trellis/spec/frontend/direct-edit-client.md","reason":"Keep the existing JunctionTools and preview ownership boundaries."} +{"file":".trellis/spec/frontend/quality-guidelines.md","reason":"Follow component and validation requirements."} +{"file":".trellis/spec/guides/cross-layer-thinking-guide.md","reason":"Trace compiler to API to client data flow."} diff --git a/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/implement.md b/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/implement.md new file mode 100644 index 0000000..275e0d5 --- /dev/null +++ b/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/implement.md @@ -0,0 +1,8 @@ +# 实施清单 + +1. 新增编译层 junction structure projection:从 model、layers、signals、shape summary 生成稳定对象键和可读标签。 +2. 新增标准诊断投影:保留现有编译 diagnostics,并为结构规则生成 pass/warning/blocking 的对象引用。 +3. 将 structure/profile/standardsDiagnostics 接入 `/api/state`、`/api/edit-state` 和 `/api/edit-preview`。 +4. 扩展客户端 state 类型、API 响应和 JunctionWorkspace 的只读结构/标准面板。 +5. 增加 Node 与客户端测试,覆盖普通/T 字/复杂/设施缺失和诊断定位。 +6. 运行 `npm test`、`npm run test:client:unit -- --run`、`npm run test:client`、`npm run format:check`、`npm run build`。 diff --git a/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/prd.md b/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/prd.md new file mode 100644 index 0000000..7f8ca6c --- /dev/null +++ b/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/prd.md @@ -0,0 +1,46 @@ +# JunctionTools Stage 1 统一结构与标准面板 + +## Goal + +TBD. + +## Requirements + +- TBD + +## Acceptance Criteria + +- [ ] TBD + +## Notes + +- Keep `prd.md` focused on requirements, constraints, and acceptance criteria. +- Lightweight tasks can remain PRD-only. +- For complex tasks, add `design.md` for technical design and `implement.md` for execution planning before `task.py start`. +# JunctionTools Stage 1:统一结构与标准面板 + +## 目标 + +把 Stage 0 的编译层结构契约接入现有 Workbench,让打开路口时能看到编译器提供的可读形态、有效道路臂、角部/设施清单和标准诊断。此阶段只读,不改变保存门禁、编辑文档或几何算法。 + +## 范围 + +- 从现有 native-road model、crosswalk/stop-line/signal 图层及 complex junction shape 结果构造 `junctionStructure`。 +- `/api/state`、`/api/edit-state`、`/api/edit-preview` 返回同一快照中的结构、标准档和 `pass/warning/blocking` 诊断。 +- JunctionWorkspace 顶栏展示可读标题、实际形态、标准档与诊断摘要;对象列表展示道路臂、角部、过街和控制设施。 +- 诊断关联稳定对象键,可在工作区定位并高亮当前对象。 + +## 非范围 + +- 不实现全局/局部覆盖、撤销模型变化或新的保存阻塞规则。 +- 不按客户端节点数量重新分类,不解释参考 GeoJSON `type`。 +- 不接入高级导流岛/中央分隔对象,除非编译结果已有明确对象证据。 + +## 验收标准 + +1. 普通、T 字、偏置、多臂和复杂路口响应包含结构摘要,形态和有效道路臂来自编译结果。 +2. T 字/单行样例不会生成不存在的道路臂、角部或设施;对象键稳定且列表可读。 +3. state、edit-state、preview 对同一路口暴露一致的 structure/profile/diagnostics 字段。 +4. JunctionWorkspace 显示标准档、形态、道路臂与设施分组;无内部 node/segment ID 作为默认标题。 +5. 诊断包含严重度、rule、objectKey/message,并可从列表定位到对应条目;warning 不阻断既有保存路径。 +6. 现有 `npm test`、客户端类型检查、单测、构建和格式检查通过。 diff --git a/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/task.json b/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/task.json new file mode 100644 index 0000000..a4567b0 --- /dev/null +++ b/.trellis/tasks/09-07-junctiontools-stage1-structure-panel/task.json @@ -0,0 +1,26 @@ +{ + "id": "junctiontools-stage1-structure-panel", + "name": "junctiontools-stage1-structure-panel", + "title": "JunctionTools Stage 1 统一结构与标准面板", + "description": "", + "status": "in_progress", + "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": {} +} \ No newline at end of file diff --git a/package.json b/package.json index 7ea6001..af90796 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "road-compiler": "bin/road-compiler.js" }, "scripts": { - "test": "node test/index.js && node test/junction-structure.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/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", "road:workbench": "node bin/road-workbench.js", "road:export": "node bin/road-compiler.js", diff --git a/src/compile/junction-projection.js b/src/compile/junction-projection.js new file mode 100644 index 0000000..13e36e1 --- /dev/null +++ b/src/compile/junction-projection.js @@ -0,0 +1,133 @@ +'use strict'; + +const { buildJunctionStructure } = require('./junction-structure'); +const { CN_URBAN_DEFAULT_PROFILE, evaluateRange } = require('./junction-standards'); + +function featureCollection(value) { + return value && Array.isArray(value.features) ? value.features : []; +} + +function heading(from, to) { + return (Math.atan2(to[0] - from[0], to[1] - from[1]) * 180) / Math.PI; +} + +function pointOf(feature) { + const coordinates = feature?.geometry?.coordinates; + if (feature?.geometry?.type === 'Point' && Array.isArray(coordinates)) return coordinates; + if (Array.isArray(coordinates?.[0]?.[0])) return coordinates[0][0]; + if (Array.isArray(coordinates?.[0])) return coordinates[0]; + return null; +} + +function projectJunctionStructure({ + model = {}, + layers = {}, + trafficSignals = null, + shape = null, + junctionKey = null, +} = {}) { + const roads = Array.isArray(model.roads) ? model.roads : []; + const endpoints = Array.isArray(model.endpoints) ? model.endpoints : []; + const core = featureCollection(layers.intersectionSurface).find( + (feature) => feature.properties?.kind === 'complex-core', + ); + const properties = core?.properties || {}; + const key = String(junctionKey || properties.cluster_id || endpoints[0]?.nodeId || 'junction:area'); + const center = pointOf(core) || endpoints[0]?.coordinate || [0, 0]; + const junctionNodeId = String(junctionKey || properties.cluster_id ? endpoints[0]?.nodeId || '' : key); + const endpointByNode = new Map(); + for (const endpoint of endpoints) endpointByNode.set(String(endpoint.nodeId), endpoint); + const arms = roads + .map((road, index) => { + const endpoint = (road.sourceNodeIds || []) + .map(String) + .filter((nodeId) => !junctionNodeId || nodeId === junctionNodeId) + .map((nodeId) => endpointByNode.get(nodeId)) + .find(Boolean); + if (!endpoint) return null; + return { + key: `road-arm:${road.id || index + 1}`, + label: String(road.tags?.name || road.name || `道路 ${index + 1}`), + heading: heading(center, endpoint.coordinate), + directionality: + road.direction === 'oneway' || road.direction === 'one-way' + ? 'one-way' + : road.direction + ? 'two-way' + : 'unknown', + carriageway: { laneCount: Number(road.laneCount) || 0, effectiveWidthMeters: Number(road.widthMeters) || 0 }, + geometryRef: String(road.id || `road:${index + 1}`), + sourceRoadId: String(road.id || ''), + }; + }) + .filter(Boolean); + const corners = + arms.length > 1 + ? arms.map((arm, index) => { + const next = arms[(index + 1) % arms.length]; + return { + key: `corner:${index + 1}`, + label: `角部 ${index + 1}`, + fromArmKey: arm.key, + toArmKey: next.key, + geometryRef: `${key}:corner:${index + 1}`, + }; + }) + : []; + const facilities = []; + for (const [kind, collection] of [ + ['crossing', layers.crosswalks], + ['stop-line', layers.vehicleStopLines], + ]) { + featureCollection(collection).forEach((feature, index) => { + const id = feature.properties?.native_id || feature.properties?.id || `${kind}:${index + 1}`; + facilities.push({ + key: String(id), + kind, + label: kind === 'crossing' ? `人行横道 ${index + 1}` : `停止线 ${index + 1}`, + geometryRef: 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 shapeKind = + shape?.kind || + properties.shape_kind || + (arms.length === 3 ? 't-junction' : arms.length >= 5 ? 'multi-arm' : arms.length === 4 ? 'cross' : 'unsupported'); + return buildJunctionStructure({ + junctionKey: key, + label: properties.shape_label || '路口', + center, + shape: { + kind: shapeKind, + label: shape?.label || properties.shape_label || '路口', + effectiveArmCount: arms.length, + throughPairCount: Number(shape?.throughPairCount ?? properties.through_pair_count) || 0, + }, + arms, + corners, + facilities, + standards: { profileId: CN_URBAN_DEFAULT_PROFILE.id }, + }); +} + +function standardsDiagnostics(structure, profile = CN_URBAN_DEFAULT_PROFILE) { + const diagnostics = []; + for (const arm of structure.arms) { + const rule = profile.rules.find((item) => item.id === 'effective-carriageway-width'); + const severity = evaluateRange(arm.carriageway.effectiveWidthMeters, rule); + diagnostics.push({ + id: `standards:${rule.id}:${arm.key}`, + severity, + rule: rule.id, + objectKey: arm.key, + message: severity === 'pass' ? '车行道有效宽度符合标准范围。' : '车行道有效宽度需要复核。', + }); + } + return diagnostics; +} + +module.exports = { projectJunctionStructure, standardsDiagnostics }; diff --git a/src/index.js b/src/index.js index 5716c7b..89b12b2 100644 --- a/src/index.js +++ b/src/index.js @@ -7,6 +7,7 @@ module.exports = { complexJunction: require('./compile/complex-junction'), junctionStructure: require('./compile/junction-structure'), junctionStandards: require('./compile/junction-standards'), + junctionProjection: require('./compile/junction-projection'), osm: require('./osm'), trafficSignals: require('./traffic-signals'), nativeTrafficSignals: require('./native-traffic-signals'), diff --git a/test/index.js b/test/index.js index 73f46ea..2d10f46 100644 --- a/test/index.js +++ b/test/index.js @@ -12,6 +12,7 @@ assert.equal(typeof compiler.complexJunction.buildComplexJunctionGeometry, 'func assert.equal(typeof compiler.complexJunction.classifyJunctionShape, 'function'); assert.equal(typeof compiler.junctionStructure.buildJunctionStructure, 'function'); assert.equal(typeof compiler.junctionStandards.validateStandardsProfile, 'function'); +assert.equal(typeof compiler.junctionProjection.projectJunctionStructure, 'function'); const shapeHelpers = { distanceMeters: (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1]) }; const arm = (heading, distance = 20) => ({ heading, diff --git a/test/junction-projection.js b/test/junction-projection.js new file mode 100644 index 0000000..068c2c4 --- /dev/null +++ b/test/junction-projection.js @@ -0,0 +1,79 @@ +'use strict'; + +const assert = require('assert/strict'); +const { projectJunctionStructure, standardsDiagnostics } = require('../src/compile/junction-projection'); + +const model = { + roads: [ + { + id: 'road:north', + sourceNodeIds: ['junction'], + tags: { name: '北环路' }, + direction: 'two-way', + laneCount: 2, + widthMeters: 7, + }, + { + id: 'road:east', + sourceNodeIds: ['junction'], + tags: { name: '东环路' }, + direction: 'oneway', + laneCount: 1, + widthMeters: 3.5, + }, + { + id: 'road:remote', + sourceNodeIds: ['elsewhere'], + tags: { name: '不属于当前路口' }, + direction: 'two-way', + laneCount: 2, + widthMeters: 7, + }, + ], + endpoints: [ + { nodeId: 'junction', coordinate: [120, 30] }, + { nodeId: 'elsewhere', coordinate: [120.01, 30.01] }, + ], +}; + +const structure = projectJunctionStructure({ + model, + layers: { + crosswalks: { + type: 'FeatureCollection', + features: [{ type: 'Feature', properties: { native_id: 'crossing:north' }, geometry: null }], + }, + vehicleStopLines: { + type: 'FeatureCollection', + features: [{ type: 'Feature', properties: { native_id: 'stop-line:north' }, geometry: null }], + }, + intersectionSurface: { type: 'FeatureCollection', features: [] }, + }, + trafficSignals: { + assemblies: { + type: 'FeatureCollection', + features: [{ type: 'Feature', properties: { signal_uid: 'signal:north' }, geometry: null }], + }, + }, +}); + +assert.equal(structure.junctionKey, 'junction'); +assert.equal(structure.shape.kind, 'unsupported'); +assert.deepEqual( + structure.arms.map((arm) => arm.label), + ['北环路', '东环路'], +); +assert.equal(structure.arms[1].directionality, 'one-way'); +assert.equal(structure.corners.length, 2); +assert.deepEqual( + structure.facilities.map((facility) => facility.kind), + ['crossing', 'stop-line', 'signal'], +); + +const diagnostics = standardsDiagnostics(structure); +assert.equal(diagnostics.length, 2); +assert.equal(diagnostics[0].severity, 'pass'); +assert.equal(diagnostics[1].severity, 'warning'); +assert.equal(diagnostics[1].objectKey, 'road-arm:road:east'); + +console.log('junction projection tests passed'); diff --git a/workbench/client/src/edit/types.ts b/workbench/client/src/edit/types.ts index 764454b..81daa3f 100644 --- a/workbench/client/src/edit/types.ts +++ b/workbench/client/src/edit/types.ts @@ -189,6 +189,9 @@ export interface EditPreviewResponse { diagnostics: EditDiagnostic[]; handles: HandleManifest; layers: Partial>; + junctionStructure?: import('../types/state').JunctionStructure | null; + standardsProfile?: { id: string; label: string }; + standardsDiagnostics?: import('../types/state').StandardsDiagnostic[]; } export interface EditStateResponse { @@ -200,6 +203,9 @@ export interface EditStateResponse { constraintStates: ConstraintStateReport[]; diagnostics: EditDiagnostic[]; handles: HandleManifest; + junctionStructure?: import('../types/state').JunctionStructure | null; + standardsProfile?: { id: string; label: string }; + standardsDiagnostics?: import('../types/state').StandardsDiagnostic[]; } /** diff --git a/workbench/client/src/junction/JunctionWorkspace.tsx b/workbench/client/src/junction/JunctionWorkspace.tsx index 0d42f47..0651245 100644 --- a/workbench/client/src/junction/JunctionWorkspace.tsx +++ b/workbench/client/src/junction/JunctionWorkspace.tsx @@ -170,6 +170,8 @@ export function JunctionWorkspace({ () => (state ? junctionFacilities(state, descriptor.nodeIds, roads) : []), [descriptor.nodeIds, roads, state], ); + const structure = state?.junctionStructure; + const standardDiagnostics = state?.standardsDiagnostics || []; return (
@@ -217,6 +219,39 @@ export function JunctionWorkspace({
+ {structure ? ( +
+

结构与标准

+

+ {state?.standardsProfile?.label || '项目默认标准'} · {structure.shape.label} ·{' '} + {structure.shape.effectiveArmCount} 条有效道路臂 +

+
+
道路臂
+
{structure.arms.map((arm) => arm.label).join('、') || '无'}
+
角部
+
{structure.corners.length ? structure.corners.map((corner) => corner.label).join('、') : '无'}
+
设施
+
+ {structure.facilities.length + ? structure.facilities.map((facility) => facility.label).join('、') + : '无'} +
+
+ {standardDiagnostics.length ? ( +
    + {standardDiagnostics.map((item) => ( +
  • + + {item.severity === 'pass' ? '通过' : item.severity === 'warning' ? '警告' : '阻塞'} + {' '} + {item.message} +
  • + ))} +
+ ) : null} +
+ ) : null} {candidate || complexEnabled ? (
{complexEnabled ? '当前复杂路口组成' : '附近可合并节点'} diff --git a/workbench/client/src/types/state.ts b/workbench/client/src/types/state.ts index c4a8c72..72e7db6 100644 --- a/workbench/client/src/types/state.ts +++ b/workbench/client/src/types/state.ts @@ -87,6 +87,27 @@ export interface Diagnostic { geometry?: { type: string; coordinates: unknown }; manualCandidates?: Array<{ roadId: string; distanceMeters: number }>; } +export interface JunctionStructure { + schema: string; + junctionKey: string; + label: string; + shape: { kind: string; label: string; effectiveArmCount: number; throughPairCount: number }; + arms: Array<{ + key: string; + label: string; + directionality: string; + carriageway?: { laneCount?: number; effectiveWidthMeters?: number }; + }>; + corners: Array<{ key: string; label: string; fromArmKey: string; toArmKey: string }>; + facilities: Array<{ key: string; kind: string; label: string }>; +} +export interface StandardsDiagnostic { + id: string; + severity: string; + rule: string; + objectKey: string; + message: string; +} export interface WorkbenchState { active?: boolean; areaId: string; @@ -106,4 +127,7 @@ export interface WorkbenchState { junctionClusters?: JunctionClusterConfig[]; junctionShapes?: JunctionShapeSummary[]; } | null; + junctionStructure?: JunctionStructure | null; + standardsProfile?: { id: string; label: string }; + standardsDiagnostics?: StandardsDiagnostic[]; } diff --git a/workbench/server.js b/workbench/server.js index 4905082..a391eb2 100644 --- a/workbench/server.js +++ b/workbench/server.js @@ -23,6 +23,7 @@ const { } = require('../src/compile/road-revisions'); const { GEOMETRY_VERSION, resolveDirectEditConstraints } = require('../src/compile/direct-edit-solver'); const { loadEditDocument, saveEditDocument, validateEditDocument } = require('../src/compile/native-road-edits'); +const { projectJunctionStructure, standardsDiagnostics } = require('../src/compile/junction-projection'); function startWorkbench({ area = null, @@ -245,6 +246,8 @@ function state(area, junctionReference = null, debug = false) { }; const trafficRuntime = runtime(trafficSignals); const compiled = readCompiled(area); + const layers = readWorkbenchLayers(nativeDir, osm2streetsRoadSurface); + const junctionStructure = projectJunctionStructure({ model: compiled.model, layers, trafficSignals }); const junctionShapes = debug ? (readLayer(path.join(nativeDir, 'layers', 'road_surface.geojson')).features || []) .filter((feature) => feature.properties?.kind === 'complex-core' && feature.properties?.cluster_id) @@ -273,27 +276,34 @@ function state(area, junctionReference = null, debug = false) { } : null, compiled, + junctionStructure, + standardsProfile: { id: 'cn-urban-default', label: '中国城市道路(项目默认)' }, + standardsDiagnostics: standardsDiagnostics(junctionStructure), overrides: loadOverrides(area.outputs.nativeRoadOverrides), trafficSignals, trafficRuntime, comparison: readJson(path.join(nativeDir, 'comparison.json')), junctionReference, - 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')), - nativeIntersectionSurface: readLayer(path.join(nativeDir, 'layers', 'intersection_surface.geojson')), - laneCenterlines: readLayer(path.join(nativeDir, 'layers', 'lane_centerlines.geojson')), - laneSeparators: readLayer(path.join(nativeDir, 'layers', 'lane_separators.geojson')), - centerLines: readLayer(path.join(nativeDir, 'layers', 'center_lines.geojson')), - directionArrows: readLayer(path.join(nativeDir, 'layers', 'direction_arrows.geojson')), - turnArrows: readLayer(path.join(nativeDir, 'layers', 'turn_arrows.geojson')), - crosswalks: readLayer(path.join(nativeDir, 'layers', 'crosswalks.geojson')), - vehicleStopLines: readLayer(path.join(nativeDir, 'layers', 'vehicle_stop_lines.geojson')), - connectors: readLayer(path.join(nativeDir, 'layers', 'connectors.geojson')), - osm2streetsRoadSurface: - osm2streetsRoadSurface && fs.existsSync(osm2streetsRoadSurface) ? readLayer(osm2streetsRoadSurface) : null, - }, + layers, + }; +} + +function readWorkbenchLayers(nativeDir, osm2streetsRoadSurface) { + return { + 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')), + nativeIntersectionSurface: readLayer(path.join(nativeDir, 'layers', 'intersection_surface.geojson')), + laneCenterlines: readLayer(path.join(nativeDir, 'layers', 'lane_centerlines.geojson')), + laneSeparators: readLayer(path.join(nativeDir, 'layers', 'lane_separators.geojson')), + centerLines: readLayer(path.join(nativeDir, 'layers', 'center_lines.geojson')), + directionArrows: readLayer(path.join(nativeDir, 'layers', 'direction_arrows.geojson')), + turnArrows: readLayer(path.join(nativeDir, 'layers', 'turn_arrows.geojson')), + crosswalks: readLayer(path.join(nativeDir, 'layers', 'crosswalks.geojson')), + vehicleStopLines: readLayer(path.join(nativeDir, 'layers', 'vehicle_stop_lines.geojson')), + connectors: readLayer(path.join(nativeDir, 'layers', 'connectors.geojson')), + osm2streetsRoadSurface: + osm2streetsRoadSurface && fs.existsSync(osm2streetsRoadSurface) ? readLayer(osm2streetsRoadSurface) : null, }; } @@ -325,6 +335,13 @@ function editState(area, selection = null) { compilerGeometryVersion: GEOMETRY_VERSION, selection, }); + const compiled = readCompiled(area); + const layers = readWorkbenchLayers(area.outputs.nativeRoadDir, null); + const junctionStructure = projectJunctionStructure({ + model: compiled.model, + layers, + trafficSignals: readJson(area.outputs.nativeTrafficSignals), + }); return { active: true, areaId: area.id, @@ -334,6 +351,9 @@ function editState(area, selection = null) { constraintStates: resolution.constraintStates, diagnostics: resolution.diagnostics, handles: resolution.handles, + junctionStructure, + standardsProfile: { id: 'cn-urban-default', label: '中国城市道路(项目默认)' }, + standardsDiagnostics: standardsDiagnostics(junctionStructure), }; } @@ -368,6 +388,15 @@ function editPreview(area, body = {}) { directEdit: resolution, }); const diagnostics = [...compiled.diagnostics, ...resolution.diagnostics]; + const junctionStructure = projectJunctionStructure({ + model, + layers: { + crosswalks: compiled.crosswalks, + vehicleStopLines: compiled.vehicleStopLines, + intersectionSurface: compiled.intersectionSurface, + }, + trafficSignals: readJson(area.outputs.nativeTrafficSignals), + }); const degraded = Date.now() - startedAt > 300; return { ok: true, @@ -378,6 +407,9 @@ function editPreview(area, body = {}) { constraintStates: resolution.constraintStates, diagnostics, handles: resolution.handles, + junctionStructure, + standardsProfile: { id: 'cn-urban-default', label: '中国城市道路(项目默认)' }, + standardsDiagnostics: standardsDiagnostics(junctionStructure), layers: { roadSurface: compiled.roadSurface, edgeLines: compiled.edgeLines,