| src/robotaxi/pages/begin-route/hooks/use-route-manager.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/robotaxi/pages/begin-route/hooks/use-web-socket-events.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/robotaxi/pages/begin-route/hooks/use-route-manager.ts
@@ -114,17 +114,32 @@ }; // 擦除已行驶路段 const erasePassedRouteSegments = (newPoints: any[]) => { const erasePassedRouteSegments = (newPoints: any[], servedPoints: any[] = []) => { const oldPoints = currentFullRouteRef.current; if (!oldPoints?.length || !newPoints?.length) return; const newFirst = newPoints[0]; const servedLast = Array.isArray(servedPoints) && servedPoints.length > 0 ? servedPoints[servedPoints.length - 1] : null; const hasServedBoundary = !!( servedLast && typeof servedLast.latitude === 'number' && typeof servedLast.longitude === 'number' ); const boundaryPoint = hasServedBoundary ? servedLast : newPoints[0]; if ( !boundaryPoint || typeof boundaryPoint.latitude !== 'number' || typeof boundaryPoint.longitude !== 'number' ) { return; } let bestMatchIndex = -1; let bestDistance = Infinity; const startIndex = lastErasedIndexRef.current; for (let i = startIndex; i < oldPoints.length; i++) { const dist = getDistance( oldPoints[i].latitude, oldPoints[i].longitude, newFirst.latitude, newFirst.longitude boundaryPoint.latitude, boundaryPoint.longitude ); if (dist < bestDistance) { bestDistance = dist; @@ -138,13 +153,18 @@ id: 2001, index: Math.max(0, bestMatchIndex - 1), point: { latitude: newFirst.latitude, longitude: newFirst.longitude, latitude: boundaryPoint.latitude, longitude: boundaryPoint.longitude, }, clear: true }] }); lastErasedIndexRef.current = bestMatchIndex; if (hasServedBoundary) { currentFullRouteRef.current = [...newPoints]; lastErasedIndexRef.current = 0; } else { lastErasedIndexRef.current = bestMatchIndex; } return; } currentFullRouteRef.current = [...newPoints]; src/robotaxi/pages/begin-route/hooks/use-web-socket-events.ts
@@ -33,7 +33,7 @@ setVehicleMoveAlongPoints: (points: any[]) => void; setRouteDistance: (value: any) => void; setRouteDuration: (value: number) => void; erasePassedRouteSegments: (points: any[]) => void; erasePassedRouteSegments: (points: any[], servedPoints?: any[]) => void; applyRoutePoints: (points: any[]) => boolean; updateVehicleLocationThrottled: (lat: number, lng: number, force?: boolean) => void; }; @@ -176,10 +176,10 @@ deps.updateVehicleLocationThrottled(firstPoint.latitude, firstPoint.longitude, true); }; const handleEraseRouteStatus = (points: any[], deps: UseWebSocketEventsDeps) => { const handleEraseRouteStatus = (points: any[], servedPoints: any[], deps: UseWebSocketEventsDeps) => { const firstPoint = points?.[0]; if (deps.orderRouteInitializedRef.current && deps.currentFullRouteRef.current.length > 0) { deps.erasePassedRouteSegments(points); deps.erasePassedRouteSegments(points, servedPoints); } else { deps.orderRouteInitializedRef.current = true; deps.currentFullRouteRef.current = [...points]; @@ -239,7 +239,7 @@ } const isEraseStatus = [4, 6].includes(deps.tripStatusRef.current); if (isEraseStatus) { handleEraseRouteStatus(points, deps); handleEraseRouteStatus(points, servedPoints, deps); return; } handleNormalRouteStatus(points, deps);