mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-05-15 11:35:40 +08:00
feat(atc): integrate OSM taxi routing into engine
Fetches taxi route from /api/service/tools/taxiroute when request_taxi or contact_ground_arrival interactions are chosen. Populates vars.taxi_route or vars.arrival_taxi_route before ATC template is rendered. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -190,6 +190,29 @@ export function useAtcEngine() {
|
||||
const interaction = phase.interactions.find(i => i.id === res.chosen)
|
||||
if (!interaction) throw new Error(`Interaction not found: ${res.chosen}`)
|
||||
|
||||
// 4b. Fetch taxi route if needed (before rendering template)
|
||||
if (
|
||||
(interaction.id === 'request_taxi' || interaction.id === 'contact_ground_arrival')
|
||||
&& state.vars.dep
|
||||
) {
|
||||
try {
|
||||
const taxiField = interaction.id === 'request_taxi' ? 'taxi_route' : 'arrival_taxi_route'
|
||||
const originName = interaction.id === 'request_taxi' ? state.vars.stand : state.vars.arrival_runway
|
||||
const destName = interaction.id === 'request_taxi' ? state.vars.runway : state.vars.arrival_stand
|
||||
const airport = interaction.id === 'request_taxi' ? state.vars.dep : state.vars.dest
|
||||
if (originName && destName && airport) {
|
||||
const taxiRes = await $fetch<any>('/api/service/tools/taxiroute', {
|
||||
params: { airport, origin_name: originName, dest_name: destName },
|
||||
})
|
||||
if (taxiRes?.names_collapsed?.length) {
|
||||
state.vars[taxiField] = taxiRes.names_collapsed.join(' ')
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[engine] Taxi route fetch failed, using fallback:', e)
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Apply updates
|
||||
let variablesUpdated: Record<string, any> = {}
|
||||
if (interaction.updates) {
|
||||
|
||||
Reference in New Issue
Block a user