fix bounding box in tracking mode
This commit is contained in:
parent
48140f0f77
commit
a617d40777
13 changed files with 392 additions and 16 deletions
|
|
@ -1,20 +1,25 @@
|
|||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { Map as MapView, plotAnimatedMarker, plotPrediction, type IMap } from '$map';
|
||||
import {
|
||||
Map as MapView,
|
||||
plotAnimatedMarker,
|
||||
plotPrediction,
|
||||
plotBoundingBox,
|
||||
type IMap,
|
||||
} from '$map';
|
||||
import { Navbar } from '$features/auth';
|
||||
import { PanelContainer, CollapsibleCard } from '$ui';
|
||||
import { TelemetryPanel, DeviationChart, telemetryStore } from '$features/tracking';
|
||||
import { workspacesStore } from '$features/workspaces';
|
||||
import { t } from '$i18n';
|
||||
import { requireAuthenticated } from '$auth';
|
||||
import { parseTelemetry } from '$domain';
|
||||
import { parseTelemetry, computeBoundingBox, DEFAULT_BBOX_MARGIN_KM } from '$domain';
|
||||
import type { Prediction } from '$domain';
|
||||
|
||||
let selectedId = $state('');
|
||||
const workspacesWithResult = $derived($workspacesStore.items.filter((w) => w.result !== null));
|
||||
const selectedPrediction = $derived<Prediction | null>(
|
||||
workspacesWithResult.find((w) => w.id === selectedId)?.result ?? null,
|
||||
);
|
||||
const selectedWorkspace = $derived(workspacesWithResult.find((w) => w.id === selectedId) ?? null);
|
||||
const selectedPrediction = $derived<Prediction | null>(selectedWorkspace?.result ?? null);
|
||||
|
||||
let map = $state<IMap | null>(null);
|
||||
// Tracks whether we've already fitted the map to the initial history load.
|
||||
|
|
@ -28,6 +33,7 @@
|
|||
onDestroy(() => {
|
||||
map?.disposeScene('telemetry');
|
||||
map?.disposeScene('prediction');
|
||||
map?.disposeScene('bbox');
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
|
|
@ -40,6 +46,23 @@
|
|||
}
|
||||
});
|
||||
|
||||
// Mirror the predict page: the bounding box is a per-workspace overlay drawn
|
||||
// only by WorkspaceRenderer (predict-only). Redraw it here for the selected
|
||||
// forecast so it doesn't vanish once tracking starts.
|
||||
$effect(() => {
|
||||
if (!map) return;
|
||||
const scene = map.scene('bbox');
|
||||
const box =
|
||||
selectedWorkspace?.result && selectedWorkspace.bboxVisible
|
||||
? computeBoundingBox(
|
||||
selectedWorkspace.result.flight_path,
|
||||
selectedWorkspace.bboxMargin ?? DEFAULT_BBOX_MARGIN_KM,
|
||||
)
|
||||
: null;
|
||||
if (box) plotBoundingBox(scene, box);
|
||||
else scene.clear();
|
||||
});
|
||||
|
||||
function onMapReady(m: IMap) {
|
||||
map = m;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue