fix: use live V2X vehicles only in preview

This commit is contained in:
2026-08-24 14:42:31 +08:00
parent ee273c5cd6
commit b7031f145a
10 changed files with 240 additions and 52 deletions

View File

@@ -307,6 +307,66 @@ npm run build:area -- --config config/areas/<area>.json --stages cesium
---
## 实时 V2X 车辆仅数据源
### 1. Scope / Trigger
适用于开启 `v2xPreview.enabled` 的 Cesium 运营预览。触发:修改
`v2x-cesium-overlay.js`、preview descriptor 的 `routeName`、或实时车辆展示。
### 2. Signatures
```text
WS /network/ws/network/obuPosition?authorization=<token>
WS /network/ws/network/targetPosition?authorization=<token>
```
OBU 消息使用 `carCode|obuCode``lon``lat``angle``speed`;目标识别消息使用
`data[deviceId][]` 内的 `id``longitude``latitude``type``subType``angle``speed`
### 3. Contracts
- 两条流均为 GCJ-02必须在实体创建前恰好调用一次 `gcj02ToWgs84`
- 本预览的 `routeName``vehicleModelName` 必须为 `null``vehicleModelNames` 必须为空;
原生 preview 不得生成 `trafficSimulation` 描述符。
- 每辆实时车保留最多 24 个已转换的位置作为实际轨迹;轨迹不是推测路径。
### 4. Validation & Error Matrix
| 条件 | 结果 |
|---|---|
| 未登录、令牌失效、REST/WS 不可用 | 静态路口继续显示,车辆层为空,并显示实时数据不可用状态 |
| 消息不是 JSON、心跳、坐标无效 | 忽略该消息,不创建车辆 |
| 收到有效车辆坐标 | 创建或更新真实车辆与实际轨迹 |
### 5. Good / Base / Bad Cases
- GoodOBU 和感知目标连续推送,页面只显示对应车辆的实际行驶轨迹。
- Base服务无数据页面没有车辆或线路。
- Bad将旧路线 JSON 或 `native-preview-traffic-simulation` 用作回退展示。
### 6. Tests Required
- `npm run test:v2x-cesium-preview`:校验两类消息解析与 GCJ-02 转换。
- `npm run test:preview-assets`:断言两条 WebSocket 存在,且 runtime 不调用
`addVehicleCruises`、不显示 simulation 诊断。
- 对目标区域运行 `npm run build:area -- --config config/areas/<area>.json --stages preview`
检查 descriptor 中 route/vehicle 字段为空,且不存在 traffic-simulation 文件。
### 7. Wrong vs Correct
错误:接口不可用时恢复构造路线。
```js
const cruise = addVehicleCruises(viewer, routeData, signalData, start);
```
正确:保持空车辆层,等待真实流。
```js
const cruise = createLiveVehicleState();
```
## 本地预览必须走 HTTP
```bash

View File

@@ -4,7 +4,9 @@
The native pipeline remains the source of static scene geometry and package
placement. The existing Cesium preview gains an operations overlay and a compact
V2X sign-in gate. The implementation stays in the current generated static
V2X sign-in gate. Vehicle entities and their trace lines exist only after the
authenticated V2X streams provide valid positions; no generated traffic route or
simulation is rendered. The implementation stays in the current generated static
preview architecture and does not import the source dashboard's Vue, AMap, or
Three dependencies.
@@ -65,11 +67,11 @@ so preserves its compiler behavior and test coverage.
## Compatibility And Failure Handling
- Existing Cesium preview and its static-only workflow remain usable.
- The V2X overlay is optional and starts only after successful sign-in.
- The V2X overlay starts only after successful sign-in.
- An expired token returns the user to sign-in and removes live entities rather
than presenting stale data as current.
- A REST/WS capability failure is shown in diagnostics; native scene, signals,
and traffic simulation remain usable.
- A REST/WS capability failure is shown in diagnostics; native scene and signals
remain usable, while the vehicle layer stays empty rather than simulating data.
- Removing the optional overlay/support files restores current preview behavior
without changing static package contracts.

View File

@@ -9,7 +9,8 @@
3. Implement the V2X browser client: login, session token lifecycle, REST
envelope handling, capability errors, and signal WebSocket lifecycle.
4. Extend the generated Cesium preview with V2X entities and operations controls
for links, devices, poles/configuration, metrics, and live signal state.
for links, devices, poles/configuration, metrics, live signal state, and the
OBU/target-vehicle streams. Do not load or generate simulated vehicle routes.
5. Add a local development/proxy configuration example and deployment
documentation for V2X REST/WS proxying. Do not add an AMap key, SDK, or page.
6. Add focused tests for HTML generation, configuration escaping, login/request

View File

@@ -38,6 +38,9 @@ retaining the native road compiler's WGS84/ENU output as the geometry authority.
loaded while leaving the native complex-intersection view usable.
- R6: Make endpoint origin, selected V2X intersection code, and authorization
mechanism deployment configuration rather than hard-coded source values.
- R7: Vehicle lines and moving vehicles must come only from the authenticated
V2X vehicle streams. Do not render or fall back to generated route/simulation
data when the service is unavailable.
## Candidate Upstream Resources
@@ -69,6 +72,7 @@ retaining the native road compiler's WGS84/ENU output as the geometry authority.
- Copying the source dashboard's Vue, AMap/Three, or proprietary UI component stack.
- Building a full user/role management service.
- Replacing native road geometry or traffic-signal contracts with V2X data.
- Generated vehicle-route or traffic-simulation fallback in the operations preview.
## Authentication Decision